Skip to content

Commit f445ddc

Browse files
authored
elyra-ai#1987 Enable option to allow link lines to be drawn over nodes using enableLinksOverNodes config. (elyra-ai#1988)
Signed-off-by: srikant <[email protected]>
1 parent f825b44 commit f445ddc

File tree

6 files changed

+30
-7
lines changed

6 files changed

+30
-7
lines changed

canvas_modules/common-canvas/src/common-canvas/svg-canvas-renderer.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -4131,7 +4131,7 @@ export default class SVGCanvasRenderer {
41314131
});
41324132
}
41334133

4134-
if (!this.isMoving() && !this.isSizing()) {
4134+
if (!this.isMoving() && !this.isSizing() && !this.config.enableLinksOverNodes) {
41354135
this.setDisplayOrder(joinedLinkGrps);
41364136
}
41374137

@@ -4206,7 +4206,7 @@ export default class SVGCanvasRenderer {
42064206
.on("mouseleave", (d3Event, link) => {
42074207
const targetObj = d3Event.currentTarget;
42084208

4209-
if (!targetObj.getAttribute("data-selected")) {
4209+
if (!targetObj.getAttribute("data-selected") && !this.config.enableLinksOverNodes) {
42104210
this.lowerLinkToBottom(targetObj);
42114211
}
42124212
this.setLinkLineStyles(targetObj, link, "default");
@@ -4460,11 +4460,14 @@ export default class SVGCanvasRenderer {
44604460
// * We are currently dragging to create a new link, or to move objects or detached links
44614461
// * There are one or more selected links
44624462
// * We are editing text
4463+
// * The app has indicated links should be displayed over nodes
44634464
raiseNodeToTop(nodeGrp) {
44644465
if (this.config.enableRaiseNodesToTopOnHover &&
44654466
!this.isDragging() &&
44664467
this.activePipeline.getSelectedLinksCount() === 0 &&
4467-
!this.isEditingText()) {
4468+
!this.isEditingText() &&
4469+
!this.config.enableLinksOverNodes
4470+
) {
44684471
nodeGrp.raise();
44694472
}
44704473
}

canvas_modules/harness/src/client/App.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ class App extends React.Component {
239239
selectedNodeLayout: null,
240240
selectedCanvasLayout: null,
241241
selectedStateTagTip: "",
242+
selectedLinksOverNodes: false,
242243

243244
// Common properties state variables
244245
propertiesInfo: {},
@@ -2079,7 +2080,8 @@ class App extends React.Component {
20792080
enableZoomIntoSubFlows: this.state.selectedZoomIntoSubFlows,
20802081
enableSingleOutputPortDisplay: this.state.selectedSingleOutputPortDisplay,
20812082
enableNodeLayout: this.state.selectedNodeLayout,
2082-
enableCanvasLayout: this.state.selectedCanvasLayout
2083+
enableCanvasLayout: this.state.selectedCanvasLayout,
2084+
enableLinksOverNodes: this.state.selectedLinksOverNodes
20832085
};
20842086

20852087
return canvasConfig;

canvas_modules/harness/src/client/components/custom-canvases/react-nodes-mapping/mapping-container-node.jsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ const CONTAINER_GAP = 48;
3232
const DEFAUT_NODE_WIDTH = 400;
3333
const DEFAUT_NODE_HEIGHT = 30;
3434

35+
// Amount in pixels to move the ports over the nodes
36+
const PORT_POS_INDENT = 8;
37+
3538

3639
class MappingContainerNode extends React.Component {
3740
constructor(props) {
@@ -356,7 +359,7 @@ class MappingContainerNode extends React.Component {
356359
: this.props.nodeData.inputs.map((port) =>
357360
({
358361
id: port.id,
359-
cx: 0,
362+
cx: PORT_POS_INDENT,
360363
cy: this.isContainerResized() ? this.getFieldElementPortPosY(port.id, nodeDivRect, scrollDivRect) : (headerDivRect.height / 2)
361364
}));
362365

@@ -365,7 +368,7 @@ class MappingContainerNode extends React.Component {
365368
: this.props.nodeData.outputs.map((port) =>
366369
({
367370
id: port.id,
368-
cx: nodeDivRect.width,
371+
cx: nodeDivRect.width - PORT_POS_INDENT,
369372
cy: this.isContainerResized() ? this.getFieldElementPortPosY(port.id, nodeDivRect, scrollDivRect) : (headerDivRect.height / 2)
370373
}));
371374

canvas_modules/harness/src/client/components/custom-canvases/react-nodes-mapping/react-nodes-mapping.jsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ export default class ReactNodesMappingCanvas extends React.Component {
8080
enableCanvasLayout: {
8181
dataLinkArrowHead: true,
8282
linkGap: 4
83-
}
83+
},
84+
enableLinksOverNodes: true
8485
});
8586
return config;
8687
}

canvas_modules/harness/src/client/components/sidepanel/canvas/sidepanel-canvas.jsx

+11
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,15 @@ export default class SidePanelForms extends React.Component {
756756
/>
757757
</div>);
758758

759+
var enableLinksOverNodes = (<div className="harness-sidepanel-children">
760+
<Toggle
761+
id="selectedLinksOverNodes"
762+
labelText="Enable Links Over Nodes"
763+
toggled={this.props.getStateValue("selectedLinksOverNodes")}
764+
onToggle={(val) => this.setStateValue(val, "selectedLinksOverNodes")}
765+
/>
766+
</div>);
767+
759768
var enableImageDisplay = (<div className="harness-sidepanel-children" id="harness-sidepanel-link-selection">
760769
<FormGroup
761770
legendText="Enable Image Display"
@@ -1565,6 +1574,8 @@ export default class SidePanelForms extends React.Component {
15651574
{divider}
15661575
{enableAssocLinkCreation}
15671576
{divider}
1577+
{enableLinksOverNodes}
1578+
{divider}
15681579
{assocLinkType}
15691580
{divider}
15701581
<div className="harness-side-panel-header">Comments</div>

docs/pages/03.02.01-canvas-config.md

+3
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ This is a Boolean. The default is `false`. If set to `true` it changes the natur
111111
#### **enableAssocLinkType**
112112
This can be "Straight" or "RightSideCurve". The default it "Straight". This field changes the way association links are drawn on the canvas.
113113
114+
#### **enableLinksOverNodes**
115+
This is a boolean. The default value is `false`. If set to `true` links are placed above nodes in the canvas. Hover over nodes/links would still have links above nodes if `enableLinksOverNodes` is set to `true`. This is useful if the ports are positioned within the boundaries of the node and the link lines need to be displayed to those positions.
116+
114117
## Comments
115118
116119
#### **enableMarkdownInComments**

0 commit comments

Comments
 (0)