Repository: brooklyn-ui Updated Branches: refs/heads/master f45d697b1 -> 9c2d7f706
Use the "itemType" to redirect the user to the right page after a catalog import Project: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/repo Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/commit/e0e02e04 Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/tree/e0e02e04 Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/diff/e0e02e04 Branch: refs/heads/master Commit: e0e02e04a0f3b720808a4e3b2984b3289595117b Parents: f45d697 Author: Thomas Bouron <thomas.bou...@cloudsoftcorp.com> Authored: Tue Feb 21 17:46:35 2017 +0000 Committer: Thomas Bouron <thomas.bou...@cloudsoftcorp.com> Committed: Tue Feb 21 17:46:35 2017 +0000 ---------------------------------------------------------------------- src/main/webapp/assets/js/view/editor.js | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/e0e02e04/src/main/webapp/assets/js/view/editor.js ---------------------------------------------------------------------- diff --git a/src/main/webapp/assets/js/view/editor.js b/src/main/webapp/assets/js/view/editor.js index 53f12f3..5d10100 100644 --- a/src/main/webapp/assets/js/view/editor.js +++ b/src/main/webapp/assets/js/view/editor.js @@ -335,7 +335,30 @@ define([ if(succeeded){ log("Submit [succeeded] ... redirecting back to " + type); if(type && type === 'catalog'){ - Backbone.history.navigate('v1/catalog', {trigger: true}); + var firstItem; + var keys = _.keys(data); + if (keys.length > 0) { + firstItem = data[keys[0]]; + } + var url = 'v1/catalog'; + if (firstItem) { + switch (firstItem.itemType) { + case 'template': + url += '/applications'; + break; + case 'entity': + url += '/entities'; + break; + case 'policy': + url += '/policies'; + break; + case 'location': + url += '/locations'; + break; + } + url += '/' + firstItem.id; + } + Backbone.history.navigate(url, {trigger: true}); }else{ // no need to refresh apps (this.collection) because homePage route does that Backbone.history.navigate('v1/home', {trigger: true});