diff options
author | Andrej Mihajlov <and@mullvad.net> | 2020-12-02 12:27:39 +0100 |
---|---|---|
committer | Andrej Mihajlov <and@mullvad.net> | 2020-12-03 13:32:24 +0100 |
commit | ec574085703ea1c8b2d4538596961beb910c4382 (patch) | |
tree | 73cf8bbdb74fe5575606664bccd0232ffa911803 /Sources/WireGuardApp/UI/macOS/ImportPanelPresenter.swift | |
parent | WireGuardKit: Assert that resolutionResults must not contain failures (diff) | |
download | wireguard-apple-ec574085703ea1c8b2d4538596961beb910c4382.tar.xz wireguard-apple-ec574085703ea1c8b2d4538596961beb910c4382.zip |
Move all source files to `Sources/` and rename WireGuardKit targets
Signed-off-by: Andrej Mihajlov <and@mullvad.net>
Diffstat (limited to 'Sources/WireGuardApp/UI/macOS/ImportPanelPresenter.swift')
-rw-r--r-- | Sources/WireGuardApp/UI/macOS/ImportPanelPresenter.swift | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Sources/WireGuardApp/UI/macOS/ImportPanelPresenter.swift b/Sources/WireGuardApp/UI/macOS/ImportPanelPresenter.swift new file mode 100644 index 0000000..d081f8c --- /dev/null +++ b/Sources/WireGuardApp/UI/macOS/ImportPanelPresenter.swift @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: MIT +// Copyright © 2018-2019 WireGuard LLC. All Rights Reserved. + +import Cocoa + +class ImportPanelPresenter { + static func presentImportPanel(tunnelsManager: TunnelsManager, sourceVC: NSViewController?) { + guard let window = sourceVC?.view.window else { return } + let openPanel = NSOpenPanel() + openPanel.prompt = tr("macSheetButtonImport") + openPanel.allowedFileTypes = ["conf", "zip"] + openPanel.allowsMultipleSelection = true + openPanel.beginSheetModal(for: window) { [weak tunnelsManager] response in + guard let tunnelsManager = tunnelsManager else { return } + guard response == .OK else { return } + TunnelImporter.importFromFile(urls: openPanel.urls, into: tunnelsManager, sourceVC: sourceVC, errorPresenterType: ErrorPresenter.self) + } + } +} |