From b2bdf23c540029cc7da9a547f40da5da29e94898 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Sat, 29 Oct 2022 13:23:43 +0200 Subject: [PATCH] Revisit pull section in OpenVPN Endpoint - Hide from server diagnostics - Use a better section title --- .../Views/EndpointAdvancedView+OpenVPN.swift | 121 +++++++++--------- .../Constants/SwiftGen+Strings.swift | 10 +- .../AppShared/de.lproj/Localizable.strings | 1 + .../AppShared/el.lproj/Localizable.strings | 1 + .../AppShared/en.lproj/Localizable.strings | 1 + .../AppShared/es.lproj/Localizable.strings | 1 + .../AppShared/fr.lproj/Localizable.strings | 1 + .../AppShared/it.lproj/Localizable.strings | 1 + .../AppShared/nl.lproj/Localizable.strings | 1 + .../AppShared/pl.lproj/Localizable.strings | 1 + .../AppShared/pt.lproj/Localizable.strings | 1 + .../AppShared/ru.lproj/Localizable.strings | 1 + .../AppShared/sv.lproj/Localizable.strings | 1 + .../zh-Hans.lproj/Localizable.strings | 1 + 14 files changed, 81 insertions(+), 62 deletions(-) diff --git a/Passepartout/App/Views/EndpointAdvancedView+OpenVPN.swift b/Passepartout/App/Views/EndpointAdvancedView+OpenVPN.swift index ac5320b8..606c4e4a 100644 --- a/Passepartout/App/Views/EndpointAdvancedView+OpenVPN.swift +++ b/Passepartout/App/Views/EndpointAdvancedView+OpenVPN.swift @@ -40,9 +40,15 @@ extension EndpointAdvancedView { var body: some View { List { let cfg = builder.build() - ipv4Section - ipv6Section - pullSection(configuration: cfg) + if !isServerPushed { + pullSection(configuration: cfg) + } + if builder.ipv4 != nil || builder.routes4 != nil { + ipv4Section + } + if builder.ipv6 != nil || builder.routes6 != nil { + ipv6Section + } dnsSection(configuration: cfg) proxySection(configuration: cfg) if !isReadonly { @@ -62,63 +68,6 @@ extension EndpointAdvancedView { } extension EndpointAdvancedView.OpenVPNView { - - @ViewBuilder - private var ipv4Section: some View { - if builder.ipv4 != nil || builder.routes4 != nil { - Section { - if let settings = builder.ipv4 { - themeLongContentLinkDefault( - L10n.Global.Strings.address, - content: .constant(settings.localizedAddress) - ) - themeLongContentLinkDefault( - L10n.NetworkSettings.Gateway.title, - content: .constant(settings.localizedDefaultGateway) - ) - } - builder.routes4.map { routes in - ForEach(routes, id: \.self) { route in - themeLongContentLinkDefault( - L10n.Endpoint.Advanced.Openvpn.Items.Route.caption, - content: .constant(route.localizedDescription) - ) - } - } - } header: { - Text(Unlocalized.Network.ipv4) - } - } - } - - @ViewBuilder - private var ipv6Section: some View { - if builder.ipv6 != nil || builder.routes6 != nil { - Section { - if let settings = builder.ipv6 { - themeLongContentLinkDefault( - L10n.Global.Strings.address, - content: .constant(settings.localizedAddress) - ) - themeLongContentLinkDefault( - L10n.NetworkSettings.Gateway.title, - content: .constant(settings.localizedDefaultGateway) - ) - } - builder.routes6.map { routes in - ForEach(routes, id: \.self) { route in - themeLongContentLinkDefault( - L10n.Endpoint.Advanced.Openvpn.Items.Route.caption, - content: .constant(route.localizedDescription) - ) - } - } - } header: { - Text(Unlocalized.Network.ipv6) - } - } - } - private func pullSection(configuration: OpenVPN.Configuration) -> some View { configuration.pullMask.map { mask in Section { @@ -126,11 +75,61 @@ extension EndpointAdvancedView.OpenVPNView { Text($0.localizedDescription) } } header: { - Text(L10n.Global.Strings.download) + Text(L10n.Endpoint.Advanced.Openvpn.Sections.Pull.header) } } } + private var ipv4Section: some View { + Section { + if let settings = builder.ipv4 { + themeLongContentLinkDefault( + L10n.Global.Strings.address, + content: .constant(settings.localizedAddress) + ) + themeLongContentLinkDefault( + L10n.NetworkSettings.Gateway.title, + content: .constant(settings.localizedDefaultGateway) + ) + } + builder.routes4.map { routes in + ForEach(routes, id: \.self) { route in + themeLongContentLinkDefault( + L10n.Endpoint.Advanced.Openvpn.Items.Route.caption, + content: .constant(route.localizedDescription) + ) + } + } + } header: { + Text(Unlocalized.Network.ipv4) + } + } + + private var ipv6Section: some View { + Section { + if let settings = builder.ipv6 { + themeLongContentLinkDefault( + L10n.Global.Strings.address, + content: .constant(settings.localizedAddress) + ) + themeLongContentLinkDefault( + L10n.NetworkSettings.Gateway.title, + content: .constant(settings.localizedDefaultGateway) + ) + } + builder.routes6.map { routes in + ForEach(routes, id: \.self) { route in + themeLongContentLinkDefault( + L10n.Endpoint.Advanced.Openvpn.Items.Route.caption, + content: .constant(route.localizedDescription) + ) + } + } + } header: { + Text(Unlocalized.Network.ipv6) + } + } + private func communicationSection(configuration: OpenVPN.Configuration) -> some View { configuration.communicationSettings.map { settings in Section { diff --git a/Passepartout/AppShared/Constants/SwiftGen+Strings.swift b/Passepartout/AppShared/Constants/SwiftGen+Strings.swift index fa7b308e..70ab6eaa 100644 --- a/Passepartout/AppShared/Constants/SwiftGen+Strings.swift +++ b/Passepartout/AppShared/Constants/SwiftGen+Strings.swift @@ -194,7 +194,7 @@ internal enum L10n { /// MARK: DiagnosticsView -> DebugLogView internal static let title = L10n.tr("Localizable", "debug_log.title", fallback: "Debug log") internal enum Buttons { - /// Copy + /// MARK: DiagnosticsView -> DebugLogView internal static let copy = L10n.tr("Localizable", "debug_log.buttons.copy", fallback: "Copy") } } @@ -384,6 +384,10 @@ internal enum L10n { /// Other internal static let header = L10n.tr("Localizable", "endpoint.advanced.openvpn.sections.other.header", fallback: "Other") } + internal enum Pull { + /// Pull from server + internal static let header = L10n.tr("Localizable", "endpoint.advanced.openvpn.sections.pull.header", fallback: "Pull from server") + } internal enum Reset { /// If you ended up with broken connectivity after changing the communication parameters, tap to revert to the original configuration. internal static let footer = L10n.tr("Localizable", "endpoint.advanced.openvpn.sections.reset.footer", fallback: "If you ended up with broken connectivity after changing the communication parameters, tap to revert to the original configuration.") @@ -571,6 +575,10 @@ internal enum L10n { internal static func title(_ p1: Any) -> String { return L10n.tr("Localizable", "menu.system.quit.title", String(describing: p1), fallback: "Quit %@") } + internal enum Messages { + /// The VPN, if enabled, will still run in the background. Do you want to quit? + internal static let confirm = L10n.tr("Localizable", "menu.system.quit.messages.confirm", fallback: "The VPN, if enabled, will still run in the background. Do you want to quit?") + } } } } diff --git a/Passepartout/AppShared/de.lproj/Localizable.strings b/Passepartout/AppShared/de.lproj/Localizable.strings index 5db2d76e..aed87984 100644 --- a/Passepartout/AppShared/de.lproj/Localizable.strings +++ b/Passepartout/AppShared/de.lproj/Localizable.strings @@ -203,6 +203,7 @@ "endpoint.wireguard.items.allowed_ip.caption" = "Zulässige IP"; "endpoint.advanced.title" = "Technische Details"; +"endpoint.advanced.openvpn.sections.pull.header" = "Vom Server ziehen"; "endpoint.advanced.openvpn.sections.communication.header" = "Kommunikation"; "endpoint.advanced.openvpn.sections.reset.footer" = "Wenn du nach einer Änderung der Kommunikations-Parameter dich nicht mehr verbinden kannst, hier tippen um zur originalen Konfiguration zurückzukehren."; "endpoint.advanced.openvpn.sections.compression.header" = "Komprimierung"; diff --git a/Passepartout/AppShared/el.lproj/Localizable.strings b/Passepartout/AppShared/el.lproj/Localizable.strings index 0041dfca..43a9200f 100644 --- a/Passepartout/AppShared/el.lproj/Localizable.strings +++ b/Passepartout/AppShared/el.lproj/Localizable.strings @@ -203,6 +203,7 @@ "endpoint.wireguard.items.allowed_ip.caption" = "Επιτρεπόμενη IP"; "endpoint.advanced.title" = "Τεχνικές Λεπτομέρειες"; +"endpoint.advanced.openvpn.sections.pull.header" = "Τραβήξτε από τον διακομιστή"; "endpoint.advanced.openvpn.sections.communication.header" = "Επικοινωνία"; "endpoint.advanced.openvpn.sections.reset.footer" = "Αν καταλήξατε σε κατεστραμένη συνδεσιμότητα μετά την αλλαγή των παραμέτρων επικοινωνίας, πατήστε για να επανέλθετε στην αρχική διαμόρφωση."; "endpoint.advanced.openvpn.sections.compression.header" = "Συμπίεση"; diff --git a/Passepartout/AppShared/en.lproj/Localizable.strings b/Passepartout/AppShared/en.lproj/Localizable.strings index 7c46429e..c5b557b5 100644 --- a/Passepartout/AppShared/en.lproj/Localizable.strings +++ b/Passepartout/AppShared/en.lproj/Localizable.strings @@ -203,6 +203,7 @@ "endpoint.wireguard.items.allowed_ip.caption" = "Allowed IP"; "endpoint.advanced.title" = "Technical details"; +"endpoint.advanced.openvpn.sections.pull.header" = "Pull from server"; "endpoint.advanced.openvpn.sections.communication.header" = "Communication"; "endpoint.advanced.openvpn.sections.reset.footer" = "If you ended up with broken connectivity after changing the communication parameters, tap to revert to the original configuration."; "endpoint.advanced.openvpn.sections.compression.header" = "Compression"; diff --git a/Passepartout/AppShared/es.lproj/Localizable.strings b/Passepartout/AppShared/es.lproj/Localizable.strings index 0088e69e..34612623 100644 --- a/Passepartout/AppShared/es.lproj/Localizable.strings +++ b/Passepartout/AppShared/es.lproj/Localizable.strings @@ -203,6 +203,7 @@ "endpoint.wireguard.items.allowed_ip.caption" = "IP permitida"; "endpoint.advanced.title" = "Detalles técnicos"; +"endpoint.advanced.openvpn.sections.pull.header" = "Obtener del servidor"; "endpoint.advanced.openvpn.sections.communication.header" = "Comunicación"; "endpoint.advanced.openvpn.sections.reset.footer" = "Si acabaste estropeando tu conectividad tras cambiar los parámetros de comunicación, pulsa para volver a la configuración inicial."; "endpoint.advanced.openvpn.sections.compression.header" = "Compresión"; diff --git a/Passepartout/AppShared/fr.lproj/Localizable.strings b/Passepartout/AppShared/fr.lproj/Localizable.strings index e5a1dc40..9269f51a 100644 --- a/Passepartout/AppShared/fr.lproj/Localizable.strings +++ b/Passepartout/AppShared/fr.lproj/Localizable.strings @@ -203,6 +203,7 @@ "endpoint.wireguard.items.allowed_ip.caption" = "IP autorisée"; "endpoint.advanced.title" = "Détails techniques"; +"endpoint.advanced.openvpn.sections.pull.header" = "Tirer du serveur"; "endpoint.advanced.openvpn.sections.communication.header" = "Communications"; "endpoint.advanced.openvpn.sections.reset.footer" = "Si vous obtenez une connection erronnée après le changement des parameters de communication, tapotez pour revenir à la configuration initiale."; "endpoint.advanced.openvpn.sections.compression.header" = "Compression"; diff --git a/Passepartout/AppShared/it.lproj/Localizable.strings b/Passepartout/AppShared/it.lproj/Localizable.strings index 86866ff2..0539a836 100644 --- a/Passepartout/AppShared/it.lproj/Localizable.strings +++ b/Passepartout/AppShared/it.lproj/Localizable.strings @@ -203,6 +203,7 @@ "endpoint.wireguard.items.allowed_ip.caption" = "IP ammesso"; "endpoint.advanced.title" = "Dettagli tecnici"; +"endpoint.advanced.openvpn.sections.pull.header" = "Ottieni dal server"; "endpoint.advanced.openvpn.sections.communication.header" = "Comunicazione"; "endpoint.advanced.openvpn.sections.reset.footer" = "Se ti trovi con una connettività compromessa dopo aver cambiato i parametri di comunicazione, tocca per tornare alla configurazione originale."; "endpoint.advanced.openvpn.sections.compression.header" = "Compressione"; diff --git a/Passepartout/AppShared/nl.lproj/Localizable.strings b/Passepartout/AppShared/nl.lproj/Localizable.strings index 8471b09e..ce605c1b 100644 --- a/Passepartout/AppShared/nl.lproj/Localizable.strings +++ b/Passepartout/AppShared/nl.lproj/Localizable.strings @@ -203,6 +203,7 @@ "endpoint.wireguard.items.allowed_ip.caption" = "Toegestane IP"; "endpoint.advanced.title" = "Technische details"; +"endpoint.advanced.openvpn.sections.pull.header" = "Pull van server"; "endpoint.advanced.openvpn.sections.communication.header" = "Communicatie"; "endpoint.advanced.openvpn.sections.reset.footer" = "Tik hier als de connectiviteit niet meer werkt na het aanpassen van instellingen, om terug te gaan naar de originele configuratie."; "endpoint.advanced.openvpn.sections.compression.header" = "Compressie"; diff --git a/Passepartout/AppShared/pl.lproj/Localizable.strings b/Passepartout/AppShared/pl.lproj/Localizable.strings index 13d02ce6..f89307b2 100644 --- a/Passepartout/AppShared/pl.lproj/Localizable.strings +++ b/Passepartout/AppShared/pl.lproj/Localizable.strings @@ -203,6 +203,7 @@ "endpoint.wireguard.items.allowed_ip.caption" = "IP z zezwoleniem"; "endpoint.advanced.title" = "Dane techniczne"; +"endpoint.advanced.openvpn.sections.pull.header" = "Pobierz z serwera"; "endpoint.advanced.openvpn.sections.communication.header" = "Komunikacja"; "endpoint.advanced.openvpn.sections.reset.footer" = "Jeśli masz problemy z połączeniem po zmianie konfiguracji komunikacji, kliknij żeby przywrócić domyślną konfigurację."; "endpoint.advanced.openvpn.sections.compression.header" = "Kompresja"; diff --git a/Passepartout/AppShared/pt.lproj/Localizable.strings b/Passepartout/AppShared/pt.lproj/Localizable.strings index 508e71b5..4b57cdc4 100644 --- a/Passepartout/AppShared/pt.lproj/Localizable.strings +++ b/Passepartout/AppShared/pt.lproj/Localizable.strings @@ -203,6 +203,7 @@ "endpoint.wireguard.items.allowed_ip.caption" = "IP Permitido"; "endpoint.advanced.title" = "Detalhes técnicos"; +"endpoint.advanced.openvpn.sections.pull.header" = "Puxar do servidor"; "endpoint.advanced.openvpn.sections.communication.header" = "Comunicação"; "endpoint.advanced.openvpn.sections.reset.footer" = "Se você foi desconectado após mudar parâmetros de comunicação, toque para restaurar a configuração original."; "endpoint.advanced.openvpn.sections.compression.header" = "Compressão"; diff --git a/Passepartout/AppShared/ru.lproj/Localizable.strings b/Passepartout/AppShared/ru.lproj/Localizable.strings index 1d39e198..e11b7bff 100644 --- a/Passepartout/AppShared/ru.lproj/Localizable.strings +++ b/Passepartout/AppShared/ru.lproj/Localizable.strings @@ -203,6 +203,7 @@ "endpoint.wireguard.items.allowed_ip.caption" = "Допустимый IP"; "endpoint.advanced.title" = "Техническая информация"; +"endpoint.advanced.openvpn.sections.pull.header" = "Вытащить с сервера"; "endpoint.advanced.openvpn.sections.communication.header" = "Связь"; "endpoint.advanced.openvpn.sections.reset.footer" = "Если после изменения параметров связи у Вас разорвалось соединение, нажмите, чтобы вернуться к исходной конфигурации."; "endpoint.advanced.openvpn.sections.compression.header" = "Компресия"; diff --git a/Passepartout/AppShared/sv.lproj/Localizable.strings b/Passepartout/AppShared/sv.lproj/Localizable.strings index 83f1f7f3..da28cfbb 100644 --- a/Passepartout/AppShared/sv.lproj/Localizable.strings +++ b/Passepartout/AppShared/sv.lproj/Localizable.strings @@ -203,6 +203,7 @@ "endpoint.wireguard.items.allowed_ip.caption" = "Tillåtet IP"; "endpoint.advanced.title" = "Tekniska detaljer"; +"endpoint.advanced.openvpn.sections.pull.header" = "Dra från servern"; "endpoint.advanced.openvpn.sections.communication.header" = "Communication"; "endpoint.advanced.openvpn.sections.reset.footer" = "Om du slutade med bruten anslutning efter att ha ändrat kommunikationsparametrarna trycker du på för att återgå till den ursprungliga konfigurationen."; "endpoint.advanced.openvpn.sections.compression.header" = "Kompression"; diff --git a/Passepartout/AppShared/zh-Hans.lproj/Localizable.strings b/Passepartout/AppShared/zh-Hans.lproj/Localizable.strings index 310355c9..69e83732 100644 --- a/Passepartout/AppShared/zh-Hans.lproj/Localizable.strings +++ b/Passepartout/AppShared/zh-Hans.lproj/Localizable.strings @@ -203,6 +203,7 @@ "endpoint.wireguard.items.allowed_ip.caption" = "允许的IP"; "endpoint.advanced.title" = "技术细节"; +"endpoint.advanced.openvpn.sections.pull.header" = "从服务器拉取"; "endpoint.advanced.openvpn.sections.communication.header" = "通信"; "endpoint.advanced.openvpn.sections.reset.footer" = "如果你在更改连接参数后变成断开状态,点按已恢复到原始的配置。"; "endpoint.advanced.openvpn.sections.compression.header" = "压缩";