diff --git a/Passepartout/Library/Sources/AppUI/L10n/SwiftGen+Strings.swift b/Passepartout/Library/Sources/AppUI/L10n/SwiftGen+Strings.swift index 789bf488..b8036c1a 100644 --- a/Passepartout/Library/Sources/AppUI/L10n/SwiftGen+Strings.swift +++ b/Passepartout/Library/Sources/AppUI/L10n/SwiftGen+Strings.swift @@ -464,8 +464,8 @@ public enum Strings { public static let onDemandSuffix = Strings.tr("Localizable", "ui.connection_status.on_demand_suffix", fallback: " (on-demand)") } public enum ProfileContext { - /// Move to... - public static let moveTo = Strings.tr("Localizable", "ui.profile_context.move_to", fallback: "Move to...") + /// Connect to... + public static let connectTo = Strings.tr("Localizable", "ui.profile_context.connect_to", fallback: "Connect to...") } } public enum Views { diff --git a/Passepartout/Library/Sources/AppUI/Resources/en.lproj/Localizable.strings b/Passepartout/Library/Sources/AppUI/Resources/en.lproj/Localizable.strings index 55922e6a..763fdcf5 100644 --- a/Passepartout/Library/Sources/AppUI/Resources/en.lproj/Localizable.strings +++ b/Passepartout/Library/Sources/AppUI/Resources/en.lproj/Localizable.strings @@ -235,7 +235,7 @@ // MARK: - Components "ui.connection_status.on_demand_suffix" = " (on-demand)"; -"ui.profile_context.move_to" = "Move to..."; +"ui.profile_context.connect_to" = "Connect to..."; // MARK: - Alerts diff --git a/Passepartout/Library/Sources/AppUI/Views/App/AppInlineCoordinator.swift b/Passepartout/Library/Sources/AppUI/Views/App/AppInlineCoordinator.swift index 6b29fd9a..1af6bb76 100644 --- a/Passepartout/Library/Sources/AppUI/Views/App/AppInlineCoordinator.swift +++ b/Passepartout/Library/Sources/AppUI/Views/App/AppInlineCoordinator.swift @@ -145,6 +145,7 @@ private extension AppInlineCoordinator { case .editProviderEntity(let profile, let module, let provider): ProviderSelectorView( profileManager: profileManager, + tunnel: tunnel, profile: profile, module: module, provider: provider diff --git a/Passepartout/Library/Sources/AppUI/Views/App/AppModalCoordinator.swift b/Passepartout/Library/Sources/AppUI/Views/App/AppModalCoordinator.swift index 933af07b..b0b87b08 100644 --- a/Passepartout/Library/Sources/AppUI/Views/App/AppModalCoordinator.swift +++ b/Passepartout/Library/Sources/AppUI/Views/App/AppModalCoordinator.swift @@ -137,6 +137,7 @@ extension AppModalCoordinator { case .editProviderEntity(let profile, let module, let provider): ProviderSelectorView( profileManager: profileManager, + tunnel: tunnel, profile: profile, module: module, provider: provider diff --git a/Passepartout/Library/Sources/AppUI/Views/App/ProviderSelectorView.swift b/Passepartout/Library/Sources/AppUI/Views/App/ProviderSelectorView.swift index b996aab6..4973e5fe 100644 --- a/Passepartout/Library/Sources/AppUI/Views/App/ProviderSelectorView.swift +++ b/Passepartout/Library/Sources/AppUI/Views/App/ProviderSelectorView.swift @@ -29,9 +29,15 @@ import SwiftUI struct ProviderSelectorView: View { + @EnvironmentObject + private var profileProcessor: ProfileProcessor + @ObservedObject var profileManager: ProfileManager + @ObservedObject + var tunnel: Tunnel + let profile: Profile let module: Module @@ -49,9 +55,19 @@ struct ProviderSelectorView: View { private extension ProviderSelectorView { func onSelect(_ entity: any ProviderEntity & Encodable) async throws { + pp_log(.app, .info, "Select new provider entity: \(entity)") + var builder = profile.builder() try builder.setProviderEntity(entity, forModuleWithId: module.id) let newProfile = try builder.tryBuild() try await profileManager.save(newProfile) + + Task { + do { + try await tunnel.connect(with: newProfile, processor: profileProcessor) + } catch { + pp_log(.app, .error, "Unable to connect with new provider entity: \(error)") + } + } } } diff --git a/Passepartout/Library/Sources/AppUI/Views/UI/ProfileContextMenu.swift b/Passepartout/Library/Sources/AppUI/Views/UI/ProfileContextMenu.swift index 0282bc2a..b1c8fb3d 100644 --- a/Passepartout/Library/Sources/AppUI/Views/UI/ProfileContextMenu.swift +++ b/Passepartout/Library/Sources/AppUI/Views/UI/ProfileContextMenu.swift @@ -45,7 +45,7 @@ struct ProfileContextMenu: View, Routable { var body: some View { tunnelToggleButton - providerEntityButton + providerConnectToButton if isInstalledProfile { tunnelRestartButton } @@ -78,11 +78,11 @@ private extension ProfileContextMenu { } } - var providerEntityButton: some View { + var providerConnectToButton: some View { profile? .firstProviderModule .map { _ in - Button(Strings.Ui.ProfileContext.moveTo) { + Button(Strings.Ui.ProfileContext.connectTo) { flow?.onEditProviderEntity(profile!) } }