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 2021/04/27 15:12:50 UTC

[brooklyn-ui] 08/15: add quick fix tooltip and sketch set_from_ quick fixes

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

commit ff755eea2e5957a9d28a9abdc60dda9cb03ea57c
Author: Alex Heneveld <al...@cloudsoftcorp.com>
AuthorDate: Fri Apr 23 18:00:15 2021 +0100

    add quick fix tooltip and sketch set_from_ quick fixes
---
 docs/basic-with-constraint.bom                     | 23 +++++++++++++++++-
 .../app/components/quick-fix/quick-fix.js          | 27 +++++++++++++++++++++-
 .../spec-editor/spec-editor.template.html          |  2 +-
 .../app/views/main/graphical/graphical.state.html  |  3 ++-
 4 files changed, 51 insertions(+), 4 deletions(-)

diff --git a/docs/basic-with-constraint.bom b/docs/basic-with-constraint.bom
index b3f440a..3ca3e3c 100644
--- a/docs/basic-with-constraint.bom
+++ b/docs/basic-with-constraint.bom
@@ -24,6 +24,8 @@ brooklyn.catalog:
     type: org.apache.brooklyn.entity.stock.BasicEntity
     brooklyn.parameters:
     - name: post_code
+      constraints:
+      - requiredUnless: zip-code
     - name: zip_code
       constraints:
       - forbiddenIf: post_code
@@ -32,5 +34,24 @@ brooklyn.catalog:
       config-quick-fixes:
       - key: zip_code
         fix: clear_config
-        message-regex: .*cannot both be set.*
+        message-regex: cannot both be set
+
+      - key: post_code
+        fix: set_from_parameter
+        message-regex: required
+
+        source-mode: suggested
+        source-hierarchy: root
+        source-types: [ org.apache.brooklyn.api.entity.Application ]
+        source-parameter: postal_code
+        source-constraints:
+        - required
+
+      - key: post_code
+        fix: set_from_config_key
+        message-regex: required
 
+        source-mode: enforced
+        source-types: [ basic-with-constraint ]
+        source-key: post_code
+        source-hierarchy: anywhere
diff --git a/ui-modules/blueprint-composer/app/components/quick-fix/quick-fix.js b/ui-modules/blueprint-composer/app/components/quick-fix/quick-fix.js
index bd96735..a542742 100644
--- a/ui-modules/blueprint-composer/app/components/quick-fix/quick-fix.js
+++ b/ui-modules/blueprint-composer/app/components/quick-fix/quick-fix.js
@@ -81,13 +81,38 @@ const QUICK_FIX_PROPOSERS = {
             if (!proposals) proposals = {};
             if (!proposals.clear_config) {
                 proposals.clear_config = {
-                    text: "Remove the current value (clear config \""+issue.ref+"\")",
+                    text: "Remove value",
+                    tooltip: "This will clear the value currently set for config \""+issue.ref+"\".",
                     apply: (issue, entity) => (entity || issue.entity).removeConfig(issue.ref),
                     issues: [],
                 };
             }
             proposals.clear_config.issues.push(issue);
         },
+    },
+    set_from_parameter: {
+        propose: (issue, proposals) => {}
+      // - key: post_code
+      //   fix: set_from_parameter
+      //   message-regex: required
+      //   source-mode: suggested
+      //   source-hierarchy: root
+      //   source-types: [ org.apache.brooklyn.api.entity.Application ]
+      //   source-parameter: postal_code
+      //   source-constraints:
+      //   - required
+
+    },
+    set_from_config_key: {
+        propose: (issue, proposals) => {}
+        // - key: post_code
+        //   fix: set_from_config_key
+        //   message-regex: required
+        //   source-mode: enforced
+        //   source-types: [ basic-with-constraint ]
+        //   source-key: post_code
+        //   source-hierarchy: anywhere
+
     }
 };
 
diff --git a/ui-modules/blueprint-composer/app/components/spec-editor/spec-editor.template.html b/ui-modules/blueprint-composer/app/components/spec-editor/spec-editor.template.html
index d6ae606..6050219 100644
--- a/ui-modules/blueprint-composer/app/components/spec-editor/spec-editor.template.html
+++ b/ui-modules/blueprint-composer/app/components/spec-editor/spec-editor.template.html
@@ -551,7 +551,7 @@
                         <span ng-bind-html="issue.message"></span>
                         <div ng-if="getObjectSize(issue.quickFixes)" class="quick-fix">
                             <div ng-repeat="fix in issue.quickFixes">
-                                <a ng-click="applyQuickFix(issue, fix)" class="btn btn-xs btn-primary">{{ fix.text }}</a>
+                                <a ng-click="applyQuickFix(issue, fix)" class="btn btn-xs btn-primary" ng-attr-title="{{ fix.tooltip }}">{{ fix.text }}</a>
                             </div>
                         </div>
                     </small>
diff --git a/ui-modules/blueprint-composer/app/views/main/graphical/graphical.state.html b/ui-modules/blueprint-composer/app/views/main/graphical/graphical.state.html
index dba01b1..986279b 100644
--- a/ui-modules/blueprint-composer/app/views/main/graphical/graphical.state.html
+++ b/ui-modules/blueprint-composer/app/views/main/graphical/graphical.state.html
@@ -187,7 +187,8 @@
                               <div class="error-line-text">
                                   {{ fix.text }}
                                   <a class="hand btn btn-xs btn-primary" style="float: right;" ng-click="vm.applyQuickFix(fix)"
-                                  >Apply
+                                     ng-attr-title="{{ fix.tooltip }}"
+                                    >Apply
                                       ({{ vm.size(fix.issues) }}
                                       <span ng-if="vm.size(fix.issues) == 1">entity</span
                                       ><span ng-if="vm.size(fix.issues) != 1">entities</span