Tunnel edit: Error out on duplicate name when creating / modifying a tunnel
Signed-off-by: Roopesh Chander <roop@roopc.net>
This commit is contained in:
parent
bd1820e9f5
commit
050f8aa679
|
@ -71,14 +71,13 @@ class TunnelEditTableViewController: UITableViewController {
|
||||||
switch (tunnelSaveResult) {
|
switch (tunnelSaveResult) {
|
||||||
case .error(let errorMessage):
|
case .error(let errorMessage):
|
||||||
let erroringConfiguration = (tunnelViewModel.interfaceData.validatedConfiguration == nil) ? "Interface" : "Peer"
|
let erroringConfiguration = (tunnelViewModel.interfaceData.validatedConfiguration == nil) ? "Interface" : "Peer"
|
||||||
showErrorAlert(title: "Invalid \(erroringConfiguration)", message: errorMessage)
|
ErrorPresenter.showErrorAlert(title: "Invalid \(erroringConfiguration)", message: errorMessage, from: self)
|
||||||
case .saved(let tunnelConfiguration):
|
case .saved(let tunnelConfiguration):
|
||||||
if let tunnel = tunnel {
|
if let tunnel = tunnel {
|
||||||
// We're modifying an existing tunnel
|
// We're modifying an existing tunnel
|
||||||
tunnelsManager.modify(tunnel: tunnel, with: tunnelConfiguration) { [weak self] (error) in
|
tunnelsManager.modify(tunnel: tunnel, with: tunnelConfiguration) { [weak self] (error) in
|
||||||
if let error = error {
|
if let error = error {
|
||||||
print("Could not modify tunnel: \(error)")
|
ErrorPresenter.showErrorAlert(error: error, from: self)
|
||||||
self?.showErrorAlert(title: "Could not save", message: "Internal error")
|
|
||||||
} else {
|
} else {
|
||||||
self?.dismiss(animated: true, completion: nil)
|
self?.dismiss(animated: true, completion: nil)
|
||||||
self?.delegate?.tunnelSaved(tunnel: tunnel)
|
self?.delegate?.tunnelSaved(tunnel: tunnel)
|
||||||
|
@ -88,8 +87,7 @@ class TunnelEditTableViewController: UITableViewController {
|
||||||
// We're adding a new tunnel
|
// We're adding a new tunnel
|
||||||
tunnelsManager.add(tunnelConfiguration: tunnelConfiguration) { [weak self] (tunnel, error) in
|
tunnelsManager.add(tunnelConfiguration: tunnelConfiguration) { [weak self] (tunnel, error) in
|
||||||
if let error = error {
|
if let error = error {
|
||||||
print("Could not add tunnel: \(error)")
|
ErrorPresenter.showErrorAlert(error: error, from: self)
|
||||||
self?.showErrorAlert(title: "Could not save", message: "Internal error")
|
|
||||||
} else {
|
} else {
|
||||||
self?.dismiss(animated: true, completion: nil)
|
self?.dismiss(animated: true, completion: nil)
|
||||||
if let tunnel = tunnel {
|
if let tunnel = tunnel {
|
||||||
|
|
Loading…
Reference in New Issue