2019-01-05 13:46:16 +00:00
|
|
|
// SPDX-License-Identifier: MIT
|
2021-06-17 14:56:46 +00:00
|
|
|
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
|
2019-01-05 13:46:16 +00:00
|
|
|
|
|
|
|
import Cocoa
|
|
|
|
|
|
|
|
class ImportPanelPresenter {
|
2019-01-17 19:57:17 +00:00
|
|
|
static func presentImportPanel(tunnelsManager: TunnelsManager, sourceVC: NSViewController?) {
|
|
|
|
guard let window = sourceVC?.view.window else { return }
|
2019-01-05 13:46:16 +00:00
|
|
|
let openPanel = NSOpenPanel()
|
2019-01-08 20:57:59 +00:00
|
|
|
openPanel.prompt = tr("macSheetButtonImport")
|
2019-01-05 13:46:16 +00:00
|
|
|
openPanel.allowedFileTypes = ["conf", "zip"]
|
2019-02-25 10:52:52 +00:00
|
|
|
openPanel.allowsMultipleSelection = true
|
2019-01-05 13:46:16 +00:00
|
|
|
openPanel.beginSheetModal(for: window) { [weak tunnelsManager] response in
|
|
|
|
guard let tunnelsManager = tunnelsManager else { return }
|
|
|
|
guard response == .OK else { return }
|
2019-03-20 03:24:23 +00:00
|
|
|
TunnelImporter.importFromFile(urls: openPanel.urls, into: tunnelsManager, sourceVC: sourceVC, errorPresenterType: ErrorPresenter.self)
|
2019-01-05 13:46:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|