macOS: Tunnel edit: Disable user interaction when OS VPN prompt is shown

This commit is contained in:
Roopesh Chander 2019-02-24 16:05:13 +05:30
parent e8c81904db
commit e86c0d239a
1 changed files with 10 additions and 0 deletions

View File

@ -198,6 +198,12 @@ class TunnelEditViewController: NSViewController {
self.view = containerView self.view = containerView
} }
func setUserInteractionEnabled(_ enabled: Bool) {
view.window?.ignoresMouseEvents = !enabled
nameRow.valueLabel.isEditable = enabled
textView.isEditable = enabled
}
@objc func handleSaveAction() { @objc func handleSaveAction() {
let name = nameRow.value let name = nameRow.value
guard !name.isEmpty else { guard !name.isEmpty else {
@ -242,9 +248,12 @@ class TunnelEditViewController: NSViewController {
} }
} }
setUserInteractionEnabled(false)
if let tunnel = tunnel { if let tunnel = tunnel {
// We're modifying an existing tunnel // We're modifying an existing tunnel
tunnelsManager.modify(tunnel: tunnel, tunnelConfiguration: tunnelConfiguration, activateOnDemandSetting: onDemandSetting) { [weak self] error in tunnelsManager.modify(tunnel: tunnel, tunnelConfiguration: tunnelConfiguration, activateOnDemandSetting: onDemandSetting) { [weak self] error in
self?.setUserInteractionEnabled(true)
if let error = error { if let error = error {
ErrorPresenter.showErrorAlert(error: error, from: self) ErrorPresenter.showErrorAlert(error: error, from: self)
return return
@ -256,6 +265,7 @@ class TunnelEditViewController: NSViewController {
// We're creating a new tunnel // We're creating a new tunnel
AppStorePrivacyNotice.show(from: self, into: tunnelsManager) { [weak self] in AppStorePrivacyNotice.show(from: self, into: tunnelsManager) { [weak self] in
self?.tunnelsManager.add(tunnelConfiguration: tunnelConfiguration, activateOnDemandSetting: onDemandSetting) { [weak self] result in self?.tunnelsManager.add(tunnelConfiguration: tunnelConfiguration, activateOnDemandSetting: onDemandSetting) { [weak self] result in
self?.setUserInteractionEnabled(true)
if let error = result.error { if let error = result.error {
ErrorPresenter.showErrorAlert(error: error, from: self) ErrorPresenter.showErrorAlert(error: error, from: self)
return return