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 f111229bf6e2d394160ec694905cbbb525204b6d Author: Alex Heneveld <[email protected]> AuthorDate: Mon Aug 22 12:55:51 2022 +0100 handle `null` values for config better, and bogus port range match --- .../app/components/util/model/dsl.model.js | 4 ++-- .../app/components/util/model/entity.model.js | 20 +++++++++++++------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/ui-modules/blueprint-composer/app/components/util/model/dsl.model.js b/ui-modules/blueprint-composer/app/components/util/model/dsl.model.js index 7617af6d..a05365d5 100644 --- a/ui-modules/blueprint-composer/app/components/util/model/dsl.model.js +++ b/ui-modules/blueprint-composer/app/components/util/model/dsl.model.js @@ -87,7 +87,7 @@ export class Dsl { ID.set(this, Math.random().toString(36).slice(2)); PARAMS.set(this, new Array()); KINDS.set(this, kind); - NAME.set(this, name === undefined ? ID.get(this).toString() : name.toString()); + NAME.set(this, name === undefined || name === null ? ID.get(this).toString() : name.toString()); RELATIONSHIPS.set(this, new Array()); ISSUES.set(this, new Array()); } @@ -1026,7 +1026,7 @@ export class Tokenizer { * @return {boolean} */ peekPortRange() { - return this.s.search(portRangeRegex) >= 0; + return this.s.search("^"+portRangeRegex) >= 0; } /** 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 22e9d4a7..faa260a0 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 @@ -676,7 +676,7 @@ export const PREDICATE_MEMBERSPEC = (config, entity)=> { */ function addConfig(key, value) { try { - if (value.hasOwnProperty(DSL.ENTITY_SPEC)) { + if (value && value.hasOwnProperty(DSL.ENTITY_SPEC)) { if (value[DSL.ENTITY_SPEC] instanceof Entity) { value[DSL.ENTITY_SPEC].family = EntityFamily.SPEC.id; value[DSL.ENTITY_SPEC].parent = this; @@ -694,7 +694,7 @@ function addConfig(key, value) { let entity = null; if (value instanceof Entity) { entity = value; - } else if (value['type']) { + } else if (value && value['type']) { entity = new Entity().setEntityFromJson(value); } if (entity) { @@ -927,8 +927,11 @@ function getClusterMemberspecEntities() { .filter((config)=>isPossiblyEntitySpec(baseType(config.type))) .reduce((acc, config)=> { if (CONFIG.get(this).has(config.name)) { - const val = CONFIG.get(this).get(config.name)[DSL.ENTITY_SPEC]; - if (val) acc[config.name] = val; + const v0 = CONFIG.get(this).get(config.name); + if (v0) { + const val = v0[DSL.ENTITY_SPEC]; + if (val) acc[config.name] = val; + } } return acc; }, {}); @@ -949,9 +952,12 @@ function getClusterMemberspecEntity(predicate = ()=>(true)) { .filter((config)=>isPossiblyEntitySpec(baseType(config.type))) .reduce((acc, config)=> { if (CONFIG.get(this).has(config.name)) { - let entityV = CONFIG.get(this).get(config.name)[DSL.ENTITY_SPEC]; - if (entityV && predicate(config, entityV)) { - return entityV; + const v0 = CONFIG.get(this).get(config.name); + if (v0) { + let entityV = v0[DSL.ENTITY_SPEC]; + if (entityV && predicate(config, entityV)) { + return entityV; + } } } return acc;
