Skip to content
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

Merged

Conversation

jeff-phillips-18
Copy link
Member

@jeff-phillips-18 jeff-phillips-18 commented Jan 27, 2020

@openshift-ci-robot openshift-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. component/dev-console Related to dev-console labels Jan 27, 2020
@@ -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,
Copy link
Member Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

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..

@jeff-phillips-18 jeff-phillips-18 changed the title Fix for aggregate edge selection, display Fix for aggregate edge selection Jan 29, 2020
@jeff-phillips-18 jeff-phillips-18 force-pushed the aggregate-edges branch 2 times, most recently from ea45188 to 0c8782e Compare January 29, 2020 14:28
@openshift-ci-robot openshift-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jan 29, 2020
@@ -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;
Copy link
Contributor

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?

Copy link
Member Author

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment.

@andrewballantyne
Copy link
Contributor

/kind bug

@openshift-ci-robot openshift-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Jan 29, 2020
@openshift-ci-robot openshift-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 30, 2020
@jeff-phillips-18 jeff-phillips-18 force-pushed the aggregate-edges branch 2 times, most recently from 615a9b4 to 28619c0 Compare January 30, 2020 13:25
@jeff-phillips-18
Copy link
Member Author

/retitle Bug 1796465: Fix for aggregate edge selection

@openshift-ci-robot openshift-ci-robot changed the title Fix for aggregate edge selection Bug 1796465: Fix for aggregate edge selection Jan 30, 2020
@openshift-ci-robot openshift-ci-robot added the bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. label Jan 30, 2020
@openshift-ci-robot
Copy link
Contributor

@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:

Bug 1796465: Fix for aggregate edge selection

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.

Comment on lines 16 to 21
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;
}
Copy link
Contributor

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

Comment on lines 132 to 143
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;
Copy link
Contributor

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);
Copy link
Contributor

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;
Copy link
Contributor

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
edge.visible = edge.visible === undefined ? true : edge.visible;
edge.visible = typeof edge.visible === 'undefined' ? true : edge.visible;

or

Suggested change
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}`,
Copy link
Contributor

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:

Suggested change
id: `${source}_${target}`,
id: `aggregate:${source}_${target}`,

@jeff-phillips-18
Copy link
Member Author

/retest

@christianvogt
Copy link
Contributor

/lgtm
/approve

@openshift-ci-robot openshift-ci-robot added lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Feb 3, 2020
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

1 similar comment
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

3 similar comments
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 4, 2020
@openshift-ci-robot openshift-ci-robot removed lgtm Indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Feb 4, 2020
@jeff-phillips-18
Copy link
Member Author

@christianvogt Rebased

@jeff-phillips-18
Copy link
Member Author

/retest

@christianvogt
Copy link
Contributor

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Feb 5, 2020
@openshift-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

1 similar comment
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot openshift-merge-robot merged commit 333b7ac into openshift:master Feb 5, 2020
@openshift-ci-robot
Copy link
Contributor

@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:

Bug 1796465: Fix for aggregate edge selection

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.

@spadgett spadgett added this to the v4.4 milestone Feb 6, 2020
@jeff-phillips-18 jeff-phillips-18 deleted the aggregate-edges branch December 2, 2020 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. component/dev-console Related to dev-console kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants