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

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


The following commit(s) were added to refs/heads/master by this push:
     new 3691789c more faithful preservation of format and content for plans 
being quick launched
3691789c is described below

commit 3691789c4ea25b466dcf83cca0ba244a3b993296
Author: Alex Heneveld <[email protected]>
AuthorDate: Fri Feb 24 15:16:30 2023 +0000

    more faithful preservation of format and content for plans being quick 
launched
---
 .../catalog/app/views/bundle/type/type.state.js    | 24 +++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/ui-modules/catalog/app/views/bundle/type/type.state.js 
b/ui-modules/catalog/app/views/bundle/type/type.state.js
index c84d32cd..e5d4f3bf 100644
--- a/ui-modules/catalog/app/views/bundle/type/type.state.js
+++ b/ui-modules/catalog/app/views/bundle/type/type.state.js
@@ -125,9 +125,27 @@ export function typeController($scope, $state, 
$stateParams, $q, $uibModal, brBr
     .then(responses => {
         $scope.bundle = responses[0];
         $scope.type = responses[1];
-        this.specItem = $scope.type.specList[0];
-        $scope.typeFormat = this.specItem.format ? 'format=' + 
this.specItem.format + '&' : '';
-        $scope.type.plan.format = this.specItem.format;
+
+        // this is the initially selected item in the dropdown of the 
definition
+        const specItem = this.specItem = $scope.type.specList[0];
+
+        // if the implementation plan does not declare its format but the 
first spec list item does
+        // then we should replace the low-level implementation plan (probably 
auto-generated) with 
+        // the first spec list item (which is what the user created)
+        var preferredContents = $scope.type.plan && $scope.type.plan.data;
+        var preferredFormat = $scope.type.plan && $scope.type.plan.format;
+        if (!preferredFormat) {
+          if (specItem && specItem.format && specItem.contents) {
+            preferredFormat = specItem.format;
+            // also take those contents
+            preferredContents = specItem.contents;
+            $scope.type.plan = { data: preferredContents, format: 
preferredFormat };
+          }
+        }
+
+        // this is used to link to the right editor in composer, preserve the 
format used to define the item being quick-launched
+        $scope.typeFormat = preferredFormat ? 'format=' + preferredFormat + 
'&' : '';
+
         $scope.versions = responses[2].map(typeVersion => ({
             bundleSymbolicName: typeVersion.containingBundle.split(':')[0],
             bundleVersion: typeVersion.containingBundle.split(':')[1],

Reply via email to