This is an automated email from the ASF dual-hosted git repository.

heneveld pushed a commit to branch fix-ctrl-click
in repository https://gitbox.apache.org/repos/asf/brooklyn-ui.git


The following commit(s) were added to refs/heads/fix-ctrl-click by this push:
     new f85bdc31 restore old logic (just in case), and treat promises correctly
f85bdc31 is described below

commit f85bdc31930c6af4fe4b6c09d8c90489e4bc5847
Author: Alex Heneveld <[email protected]>
AuthorDate: Tue May 21 12:35:37 2024 +0100

    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...
---
 ui-modules/utils/quick-launch/quick-launch.js | 46 ++++++++++++++++++++++++---
 1 file changed, 41 insertions(+), 5 deletions(-)

diff --git a/ui-modules/utils/quick-launch/quick-launch.js 
b/ui-modules/utils/quick-launch/quick-launch.js
index 3db4b0d4..6f8c341f 100644
--- a/ui-modules/utils/quick-launch/quick-launch.js
+++ b/ui-modules/utils/quick-launch/quick-launch.js
@@ -376,11 +376,6 @@ export function quickLaunchDirective() {
             $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 @@ export function quickLaunchDirective() {
             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) {

Reply via email to