This is an automated email from the ASF dual-hosted git repository.
iuliana 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 f247ecd9 Cover visibility edge-case for moved entities in a praticular
view
new 139df59e Merge pull request #343 from
algairim/fixes/app-inspector-relationsips
f247ecd9 is described below
commit f247ecd91e821a5b95a9f27a18bd081b87563f54
Author: Mykola Mandra <[email protected]>
AuthorDate: Tue Jul 5 18:37:38 2022 +0100
Cover visibility edge-case for moved entities in a praticular view
Signed-off-by: Mykola Mandra <[email protected]>
---
.../entity-tree/entity-tree.directive.js | 46 +++++++++++++++++-----
1 file changed, 36 insertions(+), 10 deletions(-)
diff --git
a/ui-modules/app-inspector/app/components/entity-tree/entity-tree.directive.js
b/ui-modules/app-inspector/app/components/entity-tree/entity-tree.directive.js
index ba19860e..b5215723 100644
---
a/ui-modules/app-inspector/app/components/entity-tree/entity-tree.directive.js
+++
b/ui-modules/app-inspector/app/components/entity-tree/entity-tree.directive.js
@@ -201,16 +201,21 @@ export function entityTreeDirective() {
// Get relationship roles for an entity.
const {parentRole, childRole} =
getRelationshipRoles(relationships, entity.id, OTHER_PARENT, OTHER_CHILD);
- if (parentRole && childRole) {
- // Find new position where entity is an
'OTHER_CHILD' already, but to become 'OTHER_PARENT' as well.
- let newParentPosition =
findEntityInOtherNodes(entities, entity.id);
-
- // Move 'OTHER_CHILD' entities added in Phase 1 to
a new parent.
- if (entity.otherNodes && newParentPosition) {
- entity.otherNodes.forEach(entityToMove => {
- moveEntityToParent(entityToMove,
newParentPosition, entities, view, false);
- });
+ if (childRole) {
+
+ if (parentRole) {
+ // Find new position where entity is an
'OTHER_CHILD' already, but to become 'OTHER_PARENT' as well.
+ let newParentPosition =
findEntityInOtherNodes(entities, entity.id);
+
+ // Move 'OTHER_CHILD' entities added in Phase
1 to a new parent.
+ if (entity.otherNodes && newParentPosition) {
+ entity.otherNodes.forEach(entityToMove => {
+ moveEntityToParent(entityToMove,
newParentPosition, entities, view, false);
+ });
+ }
}
+
+ adjustVisibilityOfMovedEntity(entity, view);
}
});
});
@@ -277,7 +282,14 @@ export function entityTreeDirective() {
entityCopy.viewModes = null;
displayEntityInView(entityCopy, viewMode);
- // 4. Add copy under otherNodes.
+ // 4. Mark original entity as been "moved" in this view.
+ if (!entity.movedInView) {
+ entity.movedInView = new Set([viewMode]);
+ } else {
+ entity.movedInView.add(viewMode);
+ }
+
+ // 5. Add copy under otherNodes.
if (!parent.otherNodes) {
parent.otherNodes = [entityCopy];
} else {
@@ -359,6 +371,20 @@ export function entityTreeDirective() {
}
}
+ /**
+ * Hides entity if marked as moved in a particular view, and
displays it otherwise.
+ *
+ * @param {Object} entity The entity to adjust visibility for.
+ * @param {string} viewMode The view mode to check visibility of a
moved entity
+ */
+ function adjustVisibilityOfMovedEntity(entity, viewMode) {
+ if (entity.movedInView && entity.movedInView.has(viewMode)) {
+ hideEntityInView(entity, viewMode);
+ } else {
+ displayEntityInView(entity, viewMode);
+ }
+ }
+
/**
* Labels entity to highlight in particular view mode.
*