better handling for edge conditions
diff --git a/ui-modules/utils/quick-launch/quick-launch.js b/ui-modules/utils/quick-launch/quick-launch.js
index 4d53cc3..e4b1a67 100644
--- a/ui-modules/utils/quick-launch/quick-launch.js
+++ b/ui-modules/utils/quick-launch/quick-launch.js
@@ -64,9 +64,15 @@
$scope.$watch('app', () => {
$scope.clearError();
- $scope.appHasWizard = !checkForLocationTags($scope.app.plan.data);
- $scope.yamlViewDisplayed = !$scope.appHasWizard;
$scope.editorYaml = $scope.app.plan.data;
+ var parsedPlan = null;
+ try {
+ parsedPlan = yaml.safeLoad($scope.editorYaml);
+ } catch (e) { /* ignore, it's an unparseable template */ }
+ // enable wizard if it's parseble and doesn't specify a location
+ // (if it's not parseable, or it specifies a location, then the YAML view is displayed)
+ $scope.appHasWizard = parsedPlan!=null && !checkForLocationTags(parsedPlan);
+ $scope.yamlViewDisplayed = !$scope.appHasWizard;
$scope.entityToDeploy = {
type: $scope.app.symbolicName
};
@@ -172,16 +178,21 @@
}
function buildComposerYaml() {
- let newApp = {
- name: $scope.model.name || $scope.app.displayName,
- };
- if ($scope.model.location) {
- newApp.location = $scope.model.location;
+ if ($scope.yamlViewDisplayed) {
+ return angular.copy($scope.editorYaml);
+ } else {
+ let newApp = {
+ name: $scope.model.name || $scope.app.displayName,
+ };
+ if ($scope.model.location) {
+ newApp.location = $scope.model.location;
+ }
+ if ($scope.entityToDeploy[BROOKLYN_CONFIG]) {
+ newApp[BROOKLYN_CONFIG] = $scope.entityToDeploy[BROOKLYN_CONFIG]
+ }
+ // TODO if plan data has config in the root (unlikely) this will have errors
+ return yaml.safeDump(newApp) + "\n" + $scope.app.plan.data;
}
- if ($scope.entityToDeploy[BROOKLYN_CONFIG]) {
- newApp[BROOKLYN_CONFIG] = $scope.entityToDeploy[BROOKLYN_CONFIG]
- }
- return yaml.safeDump(newApp) + "\n" + $scope.app.plan.data;
}
function showEditor() {
@@ -203,8 +214,8 @@
}
}
- function checkForLocationTags(planYaml) {
- return reduceFunction(false, yaml.safeLoad(planYaml));
+ function checkForLocationTags(parsedPlan) {
+ return reduceFunction(false, parsedPlan);
function reduceFunction(locationFound, entity) {
if (entity.hasOwnProperty('location') || entity.hasOwnProperty('location')) {