restore old logic (just in case), and treat promises correctly
don't think it was used, nor is it really a promise, but in case there is an edge case we aren't considering...
diff --git a/ui-modules/utils/quick-launch/quick-launch.js b/ui-modules/utils/quick-launch/quick-launch.js
index 3db4b0d..6f8c341 100644
--- a/ui-modules/utils/quick-launch/quick-launch.js
+++ b/ui-modules/utils/quick-launch/quick-launch.js
@@ -376,11 +376,6 @@
$scope.yamlViewDisplayed = false;
}
- function setComposerLink() {
- $scope.composerLink = getComposerHref({ expanded:false , validateYaml: true });
- $scope.composerLinkExpanded = getComposerHref({ expanded:true , validateYaml: true });
- }
-
function getPlanObject({expanded, validateYaml=true}) {
if ($scope.yamlViewDisplayed) {
return {format: $scope.editorFormat, yaml: angular.copy($scope.editorYaml)};
@@ -417,6 +412,47 @@
return result + 'graphical?'+stringifyForQuery(plan);
}
+
+ function setComposerLink() {
+ Promise.resolve(getComposerLinkWithFallback(false)).then(href => {
+ $scope.composerLink = href;
+ });
+ Promise.resolve(getComposerLinkWithFallback(true)).then(href => {
+ $scope.composerLinkExpanded = href;
+ });
+ }
+
+ function openComposer($event, expanded) {
+ $event.preventDefault();
+ Promise.resolve(getComposerLinkWithFallback(expanded)).then(href => {
+ window.location.href = href;
+ });
+ }
+
+ function getComposerLinkWithFallback(expanded) {
+ if (!brBrandInfo.blueprintComposerBaseUrl) {
+ console.warn("Composer unavailable in this build");
+ return;
+ }
+ return Promise.resolve(quickLaunch.getComposerHref({ expanded, validateYaml: true }))
+ .then(href => {
+ return href;
+ })
+ .catch((error) => {
+ console.warn("Will open composer in YAML text editor mode because we cannot generate a model for this configuration:", error);
+ Promise.resolve(quickLaunch.getComposerHref({
+ expanded, yamlEditor: true, validateYaml: false,
+ yamlPrefix:
+ "# This plan may have items which require attention so is being opened in YAML text editor mode.\n"+
+ "# The YAML was autogenerated by merging the plan with any values provided in UI, but issues were\n"+
+ "# detected that mean it might not be correct. Please check the blueprint below carefully.\n"+
+ "\n" }))
+ .then(href => {
+ return href;
+ })
+ });
+ }
+
function convertPlanToPreferredFormat(plan) { return plan; }
function getOriginalPlanFormat(scope) {