ui: ask for confirmation before deleting keys #520

This commit is contained in:
Marin 2014-12-05 17:14:11 -08:00
parent b4021621b5
commit bed14bb96f
1 changed files with 26 additions and 22 deletions

View File

@ -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);
});
}
}
}