You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2016/02/01 18:52:40 UTC

[41/71] [abbrv] brooklyn-ui git commit: if the yaml template does not include a location, don't show the yaml-edit tab but instead show the wizard to select location

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/brooklyn-ui/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/commit/8925128b
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/tree/8925128b
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/diff/8925128b

Branch: refs/heads/0.7.0-incubating
Commit: 8925128b2a0122d110160255e002453de7da8c80
Parents: 2d6f77d
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Sat Mar 28 20:02:10 2015 -0500
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
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/brooklyn-ui/blob/8925128b/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()
                     }