New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug 1796465: Fix for aggregate edge selection #4081
Bug 1796465: Fix for aggregate edge selection #4081
Conversation
@@ -78,6 +78,6 @@ export const createKebabAction: KebabFactory = (label, icon, importType, checkAc | |||
icon, | |||
path: getMenuPath(hasApplication, connectorSourceContext), | |||
href: getAddPageUrl(obj, importType, hasApplication, connectorSourceContext), | |||
accessReview: checkAccess && asAccessReview(resourceModel, obj, 'create'), | |||
accessReview: checkAccess ? asAccessReview(resourceModel, obj, 'create') : null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixes a warning that shows up in the console stating a boolean was being passed when an object is expected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've removed the change for easy rebasing..
f3ce3a2
to
ad6f2c2
Compare
ea45188
to
0c8782e
Compare
@@ -49,10 +49,11 @@ const connectorTypeToTitle = (type: string): string => { | |||
}; | |||
|
|||
const TopologyEdgePanel: React.FC<TopologyEdgePanelProps> = ({ edge, data, consoleLinks }) => { | |||
const source: TopologyDataObject = edge.getSource().getData(); | |||
const target: TopologyDataObject = edge.getTarget().getData(); | |||
const panelEdge = edge.getChildren()?.length === 1 ? (edge.getChildren()[0] as Edge) : edge; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of checking edge.getChildren()?.length === 1
could we be specific and check the edge type for the aggregate edge?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type for aggregate edges depicting a single edge is the original edge type allowing it to create the correct Edge element for display purposes.
@@ -28,11 +28,12 @@ export const removeConnection = (edge: Edge): Promise<any> => { | |||
btnText: 'Delete', | |||
submitDanger: true, | |||
executeFn: () => { | |||
const removeEdge = edge.getChildren()?.length === 1 ? (edge.getChildren()[0] as Edge) : edge; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment.
/kind bug |
0c8782e
to
d9abc4d
Compare
615a9b4
to
28619c0
Compare
/retitle Bug 1796465: Fix for aggregate edge selection |
@jeff-phillips-18: This pull request references Bugzilla bug 1796465, which is valid. The bug has been moved to the POST state. The bug has been updated to refer to the pull request using the external bug tracker. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
if (isEdge(element)) { | ||
const source = element.getSource(); | ||
const target = element.getTarget(); | ||
const source = element.getSourceAnchorNode(); | ||
const target = element.getTargetAnchorNode(); | ||
if ((source && !source.isVisible()) || (target && !target.isVisible())) { | ||
return null; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why the isVisible
checks were done in ElementComponent
but it makes sense to move all these checks to ElementWrapper
instead.
Also please change the comment of this component so that interaction handlers
=> behaviors
let { visible } = this; | ||
try { | ||
let parent = this.getParent(); | ||
|
||
while (visible && parent) { | ||
visible = parent.isVisible() && (!isNode(parent) || !(parent as Node).isCollapsed()); | ||
parent = parent.getParent(); | ||
} | ||
// eslint-disable-next-line no-empty | ||
} catch (e) {} | ||
|
||
return visible; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You shouldn't need a loop because each call to parent.isVisible()
will move up.
Use this.parent
to avoid the try / catch.
return (
this.visible &&
(!this.parent ||
(this.parent.isVisible() && (!isNode(this.parent) || !this.parent.isCollapsed())))
);
if (!this.source) { | ||
throw new Error(`Edge with ID '${this.getId()}' has no source.`); | ||
} | ||
return getClosestVisibleParent(this.source); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the we should be involving visibility at this point.
We should only be looking at anchoring to a different source if a parent is collapsed. Therefore we should find the last collapsed parent in the hierarchy. Otherwise return this.source
.
This would also mean that we can ensure a source anchor is always present getSourceAnchorNode(): Node {
It may not be visible, but always present. Otherwise we throw.
} | ||
return this.sourceAnchor.getLocation(referencePoint); | ||
return this.sourceAnchor ? this.sourceAnchor.getLocation(referencePoint) : Point.EMPTY; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should always have an anchor. If not the topology will be broken with a Point at 0,0.
With the other suggested changes, we can omit this change.
@@ -130,6 +130,8 @@ export interface Edge<E extends EdgeModel = EdgeModel, D = any> extends GraphEle | |||
setSource(source: Node): void; | |||
getTarget(): Node; | |||
setTarget(target: Node): void; | |||
getSourceAnchorNode(): Node | null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getSourceAnchorNode(): Node | null; | |
getSourceAnchorNode(): Node; |
return _.reduce( | ||
edges, | ||
(newEdges: EdgeModel[], edge: EdgeModel) => { | ||
const source = getDisplayedNodeForNode(edge.source, nodes); | ||
const target = getDisplayedNodeForNode(edge.target, nodes); | ||
|
||
// Make sure visible is defined so that changes override what could already be in the element | ||
edge.visible = edge.visible === undefined ? true : edge.visible; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
edge.visible = edge.visible === undefined ? true : edge.visible; | |
edge.visible = typeof edge.visible === 'undefined' ? true : edge.visible; |
or
edge.visible = edge.visible === undefined ? true : edge.visible; | |
edge.visible = 'visible' in edge ? edge.visible : true; |
@@ -55,13 +81,14 @@ const createAggregateEdges = ( | |||
source, | |||
target, | |||
id: `${source}_${target}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to be safe, could we prefix this id:
id: `${source}_${target}`, | |
id: `aggregate:${source}_${target}`, |
d8fc36a
to
552a551
Compare
/retest |
/lgtm |
/retest Please review the full test history for this PR and help us cut down flakes. |
1 similar comment
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
3 similar comments
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
552a551
to
5487537
Compare
@christianvogt Rebased |
/retest |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: christianvogt, jeff-phillips-18 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/retest Please review the full test history for this PR and help us cut down flakes. |
1 similar comment
/retest Please review the full test history for this PR and help us cut down flakes. |
@jeff-phillips-18: All pull requests linked via external trackers have merged. Bugzilla bug 1796465 has been moved to the MODIFIED state. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Fixes https://issues.redhat.com/browse/ODC-2852