if the yaml template does not include a location, don't show the yaml-edit tab but instead show the wizard to select location
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/795106f5 Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/795106f5 Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/795106f5 Branch: refs/heads/master Commit: 795106f5941ac59660d50eb87adc08a494831ded Parents: 46c3620 Author: Alex Heneveld <[email protected]> Authored: Sat Mar 28 20:02:10 2015 -0500 Committer: Alex Heneveld <[email protected]> Committed: Sat Mar 28 20:03:12 2015 -0500 ---------------------------------------------------------------------- .../assets/js/view/application-add-wizard.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/795106f5/usage/jsgui/src/main/webapp/assets/js/view/application-add-wizard.js ---------------------------------------------------------------------- diff --git a/usage/jsgui/src/main/webapp/assets/js/view/application-add-wizard.js b/usage/jsgui/src/main/webapp/assets/js/view/application-add-wizard.js index bc5ae07..8a999d2 100644 --- a/usage/jsgui/src/main/webapp/assets/js/view/application-add-wizard.js +++ b/usage/jsgui/src/main/webapp/assets/js/view/application-add-wizard.js @@ -21,7 +21,7 @@ * Also creates an empty Application model. */ define([ - "underscore", "jquery", "backbone", "brooklyn-utils", + "underscore", "jquery", "backbone", "brooklyn-utils", "js-yaml", "model/entity", "model/application", "model/location", "text!tpl/app-add-wizard/modal-wizard.html", "text!tpl/app-add-wizard/create.html", @@ -35,7 +35,7 @@ define([ "text!tpl/app-add-wizard/preview.html", "bootstrap" -], function (_, $, Backbone, Util, Entity, Application, Location, +], function (_, $, Backbone, Util, JsYaml, Entity, Application, Location, ModalHtml, CreateHtml, CreateStepTemplateEntryHtml, CreateEntityEntryHtml, RequiredConfigEntryHtml, EditConfigEntryHtml, DeployHtml, DeployLocationRowHtml, DeployLocationOptionHtml, PreviewHtml @@ -250,13 +250,21 @@ define([ nextStep:function () { if (this.currentStep < 2) { if (this.currentView.validate()) { - var isYaml = (this.currentView && this.currentView.selectedTemplate && this.currentView.selectedTemplate.yaml); - if (isYaml) { - // it's a yaml catalog template, show the yaml tab + var yaml = (this.currentView && this.currentView.selectedTemplate && this.currentView.selectedTemplate.yaml); + if (yaml) { + try { + yaml = JsYaml.safeLoad(yaml); + yaml = (yaml.location || yaml.locations ? true : false); + } catch (e) { + yaml = false; + } + } + if (yaml) { + // it's a yaml catalog template which includes a location, show the yaml tab $("ul#app-add-wizard-create-tab").find("a[href='#yamlTab']").tab('show'); $("#yaml_code").focus() } else { - // it's a java catalog template, go to wizard for location + config + // it's a java catalog template or yaml template without a location, go to wizard this.currentStep += 1 this.renderCurrentStep() }
