From bed14bb96f1e89cdc9cef0a9378fbe99d034a2df Mon Sep 17 00:00:00 2001 From: Marin Date: Fri, 5 Dec 2014 17:14:11 -0800 Subject: [PATCH 1/2] ui: ask for confirmation before deleting keys #520 --- ui/javascripts/app/controllers.js | 48 +++++++++++++++++-------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/ui/javascripts/app/controllers.js b/ui/javascripts/app/controllers.js index 4aad1f42e..a06901764 100644 --- a/ui/javascripts/app/controllers.js +++ b/ui/javascripts/app/controllers.js @@ -161,23 +161,25 @@ App.KvShowController.reopen({ }, deleteFolder: function() { - this.set('isLoading', true); + this.set('isLoading', true); var controller = this; var dc = controller.get('dc').get('datacenter'); var grandParent = controller.get('grandParentKey'); var token = App.get('settings.token'); - // Delete the folder - Ember.$.ajax({ - url: (formatUrl("/v1/kv/" + controller.get('parentKey') + '?recurse', dc, token)), - type: 'DELETE' - }).then(function(response) { - controller.transitionToNearestParent(grandParent); - }).fail(function(response) { - // Render the error message on the form if the request failed - controller.set('errorMessage', 'Received error while processing: ' + response.statusText); - }); + if (window.confirm("Are you sure you want to delete this folder?")) { + // Delete the folder + Ember.$.ajax({ + url: (formatUrl("/v1/kv/" + controller.get('parentKey') + '?recurse', dc, token)), + type: 'DELETE' + }).then(function(response) { + controller.transitionToNearestParent(grandParent); + }).fail(function(response) { + // Render the error message on the form if the request failed + controller.set('errorMessage', 'Received error while processing: ' + response.statusText); + }); + } } } }); @@ -219,24 +221,26 @@ App.KvEditController = KvBaseController.extend({ }, deleteKey: function() { - this.set('isLoading', true); + this.set('isLoading', true); var controller = this; var dc = controller.get('dc').get('datacenter'); var key = controller.get("model"); var parent = controller.getParentKeyRoute(); var token = App.get('settings.token'); - // Delete the key - Ember.$.ajax({ - url: (formatUrl("/v1/kv/" + key.get('Key'), dc, token)), - type: 'DELETE' - }).then(function(data) { - controller.transitionToNearestParent(parent); - }).fail(function(response) { - // Render the error message on the form if the request failed - controller.set('errorMessage', 'Received error while processing: ' + response.statusText); - }); + if (window.confirm("Are you sure you want to delete this key?")) { + // Delete the key + Ember.$.ajax({ + url: (formatUrl("/v1/kv/" + key.get('Key'), dc, token)), + type: 'DELETE' + }).then(function(data) { + controller.transitionToNearestParent(parent); + }).fail(function(response) { + // Render the error message on the form if the request failed + controller.set('errorMessage', 'Received error while processing: ' + response.statusText); + }); + } } } From 781692e3a856cc647e457b45cbabdcb91d3a0088 Mon Sep 17 00:00:00 2001 From: Marin Date: Sat, 6 Dec 2014 11:55:26 -0800 Subject: [PATCH 2/2] ui: confirm dialog only when deleting key directories #521 --- ui/javascripts/app/controllers.js | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/ui/javascripts/app/controllers.js b/ui/javascripts/app/controllers.js index a06901764..f475fb673 100644 --- a/ui/javascripts/app/controllers.js +++ b/ui/javascripts/app/controllers.js @@ -221,26 +221,24 @@ App.KvEditController = KvBaseController.extend({ }, deleteKey: function() { - this.set('isLoading', true); + var controller = this; var dc = controller.get('dc').get('datacenter'); var key = controller.get("model"); var parent = controller.getParentKeyRoute(); var token = App.get('settings.token'); - if (window.confirm("Are you sure you want to delete this key?")) { - // Delete the key - Ember.$.ajax({ - url: (formatUrl("/v1/kv/" + key.get('Key'), dc, token)), - type: 'DELETE' - }).then(function(data) { - controller.transitionToNearestParent(parent); - }).fail(function(response) { - // Render the error message on the form if the request failed - controller.set('errorMessage', 'Received error while processing: ' + response.statusText); - }); - } + // Delete the key + Ember.$.ajax({ + url: (formatUrl("/v1/kv/" + key.get('Key'), dc, token)), + type: 'DELETE' + }).then(function(data) { + controller.transitionToNearestParent(parent); + }).fail(function(response) { + // Render the error message on the form if the request failed + controller.set('errorMessage', 'Received error while processing: ' + response.statusText); + }); } }