1
0
mirror of https://git.zx2c4.com/wireguard-apple synced 2025-08-12 17:52:53 +00:00
Files
wireguard-apple/Sources/WireGuardApp/UI/macOS/ImportPanelPresenter.swift
Jason A. Donenfeld 7b279383d1 App: bump copyright
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-02-15 14:20:35 +01:00

20 lines
863 B
Swift

// SPDX-License-Identifier: MIT
// Copyright © 2018-2023 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)
}
}
}