You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by jc...@apache.org on 2022/07/04 08:16:47 UTC
[brooklyn-ui] branch master updated: fix issues around quick fixes
This is an automated email from the ASF dual-hosted git repository.
jcabrerizo 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 cd5b4090 fix issues around quick fixes
new 93dca5ae Merge pull request #342 from ahgittin/fix-quick-fixes
cd5b4090 is described below
commit cd5b409074204e756a9c55ec931e8cddb206a138
Author: Alex Heneveld <al...@cloudsoft.io>
AuthorDate: Fri Jul 1 15:01:54 2022 +0100
fix issues around quick fixes
- reference to ancestor without ID caused null, now it sets the id
- reference to ancestor fix always just pointed at parent, not where config was defined
- count of errors was sometimes not reset so was too high
- alignment of error line marker was wrong
---
.../providers/blueprint-service.provider.js | 3 +-
.../app/components/quick-fix/quick-fix.js | 34 +++++++++++++++++-----
.../app/components/util/model/entity.model.js | 5 +++-
.../app/views/main/graphical/graphical.state.less | 1 +
4 files changed, 34 insertions(+), 9 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 fc1e8cec..b682c1fb 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
@@ -346,6 +346,7 @@ function BlueprintService($log, $q, $sce, paletteApi, iconGenerator, dslService,
entity.miscData.set('loading', false);
return refreshRelationships(entity);
}).then(() => {
+ entity.clearIssues({group: 'config'});
return $q.all([
refreshConfigConstraints(entity),
refreshConfigMemberspecsMetadata(entity),
@@ -603,7 +604,7 @@ function BlueprintService($log, $q, $sce, paletteApi, iconGenerator, dslService,
.group('config')
.ref(definition.name)
.level(ISSUE_LEVEL.WARN)
- .message(`Implicitly defined from one of its ancestor`)
+ .message(`Implicitly defined (inherited from an ancestor)`)
.build());
}
});
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 a42d7148..8a4d7459 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
@@ -45,7 +45,6 @@ export function computeQuickFixes(blueprintService, allIssues) {
quickFixes: {},
};
}
-
let issueO = {
issue,
//quickFixes: {},
@@ -70,7 +69,6 @@ export function computeQuickFixes(blueprintService, allIssues) {
quickFixes: {},
};
}
-
let issueO = {
issue,
//quickFixes: {},
@@ -124,13 +122,35 @@ const QUICK_FIX_PROPOSERS = {
proposals = {};
}
+ // refer directly to the ancestor, and refer to it as scope root (if root) or using id
+ // no option to refer to parent because that gets weird if things are rearranged
+ // (application root is usually not rearranged)
if (!proposals.explicit_config) {
- let entityToReference = (entity || issue.entity).parent;
- let scopeRootOrComponent = blueprintService.get() === entityToReference ? 'scopeRoot()' : `component("${entityToReference.id}")`;
+ let parent = (entity || issue.entity).parent;
+ let entityToReference = parent;
+ while (entityToReference && !entityToReference.config.has(issue.ref)) {
+ entityToReference = entityToReference.parent;
+ }
+ if (!entityToReference) entityToReference = parent;
+ const isParent = entityToReference === parent;
+ const isScopeRoot = blueprintService.get() === entityToReference;
+ const referrent = isParent ? 'parent' : isScopeRoot ? 'root' : 'ancestor';
+
proposals.explicit_config = {
- text: 'Set explicit config from parent',
- tooltip: `This will set the config "${issue.ref}" to its parent value, explicitly`,
- apply: (issue, entity) => (entity || issue.entity).addConfig(issue.ref, `$brooklyn:${scopeRootOrComponent}.config("${issue.ref}")`),
+ text: 'Set explicit config from '+referrent,
+ tooltip: `This will set the config "${issue.ref}" to refer explicitly to the value set at the `+referrent,
+ apply: (issue, entity) => {
+ let scopeRootOrComponent;
+ if (isScopeRoot) scopeRootOrComponent = 'scopeRoot()';
+ else {
+ if (!entityToReference.id) {
+ // we could try to make a good uid from the name or type, but for now just make random to ensure it isn't null
+ entityToReference.id = entityToReference._id;
+ }
+ scopeRootOrComponent = `component("${entityToReference.id}")`;
+ }
+ (entity || issue.entity).addConfig(issue.ref, `$brooklyn:${scopeRootOrComponent}.config("${issue.ref}")`);
+ },
issues: []
};
}
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 b0c884c8..590a6fd0 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
@@ -1053,7 +1053,7 @@ function hasIssues() {
return this.issues.length > 0;
}
-function clearIssues(predicate) {
+function clearIssues(predicate, recursive) {
if (this.hasIssues()) {
if (predicate && predicate instanceof Object) {
MISC_DATA.get(this).set('issues', this.issues.filter(issue => {
@@ -1070,6 +1070,9 @@ function clearIssues(predicate) {
}
this.touch();
}
+ if (recursive) {
+ this.children.forEach(child => child.clearIssues(predicate, recursive));
+ }
return this;
}
diff --git a/ui-modules/blueprint-composer/app/views/main/graphical/graphical.state.less b/ui-modules/blueprint-composer/app/views/main/graphical/graphical.state.less
index 5b3c136f..0ae8097b 100644
--- a/ui-modules/blueprint-composer/app/views/main/graphical/graphical.state.less
+++ b/ui-modules/blueprint-composer/app/views/main/graphical/graphical.state.less
@@ -137,6 +137,7 @@
}
.error-line-text {
flex: 1 1 auto;
+ margin-top: 4px; // match marker
}
.error-line-marker {
color: @brand-danger;