From 17e37562000a8727da6e0bfd3e240b5e8e472845 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?William=20Tis=C3=A4ter?= Date: Mon, 5 May 2014 02:51:34 +0200 Subject: [PATCH] Redirect to correct root path when deleting keys --- ui/javascripts/app/controllers.js | 11 ++++++++--- ui/javascripts/app/routes.js | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ui/javascripts/app/controllers.js b/ui/javascripts/app/controllers.js index 8b04a55e64..3b70d8115f 100644 --- a/ui/javascripts/app/controllers.js +++ b/ui/javascripts/app/controllers.js @@ -171,9 +171,14 @@ App.KvEditController = Ember.Controller.extend({ deleteKey: function() { this.set('isLoading', true); - var dc = this.get('dc').get('datacenter'); - var key = this.get("model"); var controller = this; + var dc = controller.get('dc').get('datacenter'); + var key = controller.get("model"); + var parent = key.get('parentKey'); + + if (parent === '/') { + parent = controller.get('rootKey'); + } // Delete the key Ember.$.ajax({ @@ -181,7 +186,7 @@ App.KvEditController = Ember.Controller.extend({ type: 'DELETE' }).then(function(response) { // Tranisiton back up a level - controller.transitionToRoute('kv.show', key.get('parentKey')); + controller.transitionToRoute('kv.show', parent); controller.set('isLoading', false); }).fail(function(response) { // Render the error message on the form if the request failed diff --git a/ui/javascripts/app/routes.js b/ui/javascripts/app/routes.js index 0daa17d1db..12d867ade1 100644 --- a/ui/javascripts/app/routes.js +++ b/ui/javascripts/app/routes.js @@ -167,6 +167,7 @@ App.KvEditRoute = App.BaseRoute.extend({ controller.set('parentKey', parentKeys.parent); controller.set('grandParentKey', parentKeys.grandParent); controller.set('siblings', models.keys); + controller.set('rootKey', this.rootKey); } });