From 99e572cffbd40a1d729327599dfa6e3b9caa3fa0 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 4aad1f42ed..a069017641 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 d0994d2fceb68540d3b5527274ef645910182a35 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 a069017641..f475fb673b 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); + }); } }