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/08/06 08:16:41 UTC

[brooklyn-ui] 01/03: instead of checking `default`, make sure we convert from `default` to `defaultValue` when merging parameters

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 682a6530acfc9260bc2708ea2c9a83ff2179f3c8
Author: Alex Heneveld <al...@cloudsoftcorp.com>
AuthorDate: Thu Aug 5 15:52:26 2021 +0100

    instead of checking `default`, make sure we convert from `default` to `defaultValue` when merging parameters
---
 .../app/components/providers/blueprint-service.provider.js |  2 +-
 .../app/components/util/model/entity.model.js              | 14 ++++++++++++--
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/ui-modules/blueprint-composer/app/components/providers/blueprint-service.provider.js b/ui-modules/blueprint-composer/app/components/providers/blueprint-service.provider.js
index 86547cf..c4325e2 100644
--- a/ui-modules/blueprint-composer/app/components/providers/blueprint-service.provider.js
+++ b/ui-modules/blueprint-composer/app/components/providers/blueprint-service.provider.js
@@ -445,7 +445,7 @@ function BlueprintService($log, $q, $sce, paletteApi, iconGenerator, dslService,
                     if (!k || !Array.isArray(k)) return false;
                     return k.some(isSet);
                 }
-                const hasDefault = (typeof config.default) !== 'undefined';
+                const hasDefault = (typeof config.defaultValue) !== 'undefined';
 
                 switch (key) {
                     case 'Predicates.notNull()':
diff --git a/ui-modules/blueprint-composer/app/components/util/model/entity.model.js b/ui-modules/blueprint-composer/app/components/util/model/entity.model.js
index c30176a..c2446c8 100644
--- a/ui-modules/blueprint-composer/app/components/util/model/entity.model.js
+++ b/ui-modules/blueprint-composer/app/components/util/model/entity.model.js
@@ -685,7 +685,17 @@ function addConfigKeyDefinition(param, overwrite, skipUpdatesDuringBatch) {
         let key = (param || {}).name;
         if (!key) throw new Error("'name' field must be included when adding parameter; was", param);
 
-        allConfig[key] = Object.assign(allConfig[key] || {}, param, overwrite ? null : allConfig[key]);
+        let paramMapped = Object.assign({}, param);
+        let configDef = allConfig[key] || {};
+        if (typeof paramMapped.default !== 'undefined') {
+            /* Annoyingly, in parameters, we call the default value "default",
+             * but in config, we call them "defaultValue";
+             * when params are merged to config we need to rename
+             */
+            paramMapped.defaultValue = paramMapped.default;
+            delete paramMapped['default'];
+        }
+        allConfig[key] = Object.assign(configDef, paramMapped, overwrite ? null : configDef);
     }
     if (!skipUpdatesDuringBatch) {
         this.miscData.set('config', Object.values(allConfig));
@@ -1345,4 +1355,4 @@ export class EntityError extends Error {
             this.stack = (new Error(message)).stack;
         }
     }
-}
\ No newline at end of file
+}