macOS: Update detail view after editing
Signed-off-by: Roopesh Chander <roop@roopc.net>
This commit is contained in:
parent
80977b95de
commit
fc9e2de72c
|
@ -192,6 +192,7 @@ class TunnelDetailTableViewController: NSViewController {
|
|||
|
||||
@objc func editButtonClicked() {
|
||||
let tunnelEditVC = TunnelEditViewController(tunnelsManager: tunnelsManager, tunnel: tunnel)
|
||||
tunnelEditVC.delegate = self
|
||||
presentAsSheet(tunnelEditVC)
|
||||
}
|
||||
|
||||
|
@ -234,3 +235,14 @@ extension TunnelDetailTableViewController: NSTableViewDelegate {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension TunnelDetailTableViewController: TunnelEditViewControllerDelegate {
|
||||
func tunnelSaved(tunnel: TunnelContainer) {
|
||||
tunnelViewModel = TunnelViewModel(tunnelConfiguration: tunnel.tunnelConfiguration)
|
||||
tableView.reloadData()
|
||||
}
|
||||
|
||||
func tunnelEditingCancelled() {
|
||||
// Nothing to do
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,11 @@
|
|||
|
||||
import Cocoa
|
||||
|
||||
protocol TunnelEditViewControllerDelegate: class {
|
||||
func tunnelSaved(tunnel: TunnelContainer)
|
||||
func tunnelEditingCancelled()
|
||||
}
|
||||
|
||||
class TunnelEditViewController: NSViewController {
|
||||
|
||||
let nameRow: EditableKeyValueRow = {
|
||||
|
@ -62,6 +67,8 @@ class TunnelEditViewController: NSViewController {
|
|||
let tunnelsManager: TunnelsManager
|
||||
let tunnel: TunnelContainer?
|
||||
|
||||
weak var delegate: TunnelEditViewControllerDelegate?
|
||||
|
||||
var textViewObservationToken: AnyObject?
|
||||
|
||||
init(tunnelsManager: TunnelsManager, tunnel: TunnelContainer?) {
|
||||
|
@ -149,6 +156,7 @@ class TunnelEditViewController: NSViewController {
|
|||
return
|
||||
}
|
||||
self?.dismiss(self)
|
||||
self?.delegate?.tunnelSaved(tunnel: tunnel)
|
||||
}
|
||||
} catch let error as WireGuardAppError {
|
||||
ErrorPresenter.showErrorAlert(error: error, from: self)
|
||||
|
@ -159,6 +167,7 @@ class TunnelEditViewController: NSViewController {
|
|||
}
|
||||
|
||||
@objc func discardButtonClicked() {
|
||||
delegate?.tunnelEditingCancelled()
|
||||
dismiss(self)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue