From 6d6a7e6923286584d14ffbf2976c235e87eb6950 Mon Sep 17 00:00:00 2001 From: Anthony Lapenna Date: Thu, 1 Sep 2016 11:31:25 +1200 Subject: [PATCH] feat(network): display the correct error message when a network deletion failure occurs --- app/components/network/networkController.js | 12 +++++++++--- app/components/networks/networksController.js | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/components/network/networkController.js b/app/components/network/networkController.js index a38c5474f..05b70e462 100644 --- a/app/components/network/networkController.js +++ b/app/components/network/networkController.js @@ -17,9 +17,15 @@ function ($scope, Network, Messages, $state, $stateParams, errorMsgFilter) { $scope.remove = function remove(networkId) { $('#loadingViewSpinner').show(); Network.remove({id: $stateParams.id}, function (d) { - $('#loadingViewSpinner').hide(); - Messages.send("Network removed", ""); - $state.go('networks', {}); + var error = errorMsgFilter(d); + if (error) { + $('#loadingViewSpinner').hide(); + Messages.send("Error", error); + } else { + $('#loadingViewSpinner').hide(); + Messages.send("Network deleted", $stateParams.id); + $state.go('networks', {}); + } }, function (e) { $('#loadingViewSpinner').hide(); Messages.error("Failure", e.data); diff --git a/app/components/networks/networksController.js b/app/components/networks/networksController.js index 79347b6e1..217f23559 100644 --- a/app/components/networks/networksController.js +++ b/app/components/networks/networksController.js @@ -47,7 +47,7 @@ function ($scope, $state, Network, Config, Messages, errorMsgFilter) { Network.remove({id: network.Id}, function (d) { var error = errorMsgFilter(d); if (error) { - Messages.send("Error", "Unable to remove network with active endpoints"); + Messages.send("Error", error); } else { Messages.send("Network deleted", network.Id); var index = $scope.networks.indexOf(network);