From f33cd0b6fd1dac1c8e72edd0b950c231f6242918 Mon Sep 17 00:00:00 2001 From: Roopesh Chander Date: Thu, 3 Jan 2019 22:48:05 +0530 Subject: [PATCH] macOS: Manage tunnels: Import pulldown menu implementation Signed-off-by: Roopesh Chander --- .../TunnelsListTableViewController.swift | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift b/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift index ca24acc..5ceb2a1 100644 --- a/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift +++ b/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift @@ -127,7 +127,15 @@ class TunnelsListTableViewController: NSViewController { } @objc func importTunnelClicked() { - print("importTunnelClicked") + guard let window = view.window else { return } + let openPanel = NSOpenPanel() + openPanel.allowedFileTypes = ["conf", "zip"] + openPanel.beginSheetModal(for: window) { [weak tunnelsManager] response in + guard let tunnelsManager = tunnelsManager else { return } + guard response == .OK else { return } + guard let url = openPanel.url else { return } + TunnelImporter.importFromFile(url: url, into: tunnelsManager, sourceVC: nil, errorPresenterType: ErrorPresenter.self) + } } @objc func removeTunnelClicked() {