@elyra/canvas 12.43.0 → 12.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{canvas-constants-acb99f64.js → canvas-constants-3bbfc8b1.js} +2 -2
- package/dist/{canvas-constants-acb99f64.js.map → canvas-constants-3bbfc8b1.js.map} +1 -1
- package/dist/{canvas-constants-ff5cf88e.js → canvas-constants-8d240dc6.js} +2 -2
- package/dist/{canvas-constants-ff5cf88e.js.map → canvas-constants-8d240dc6.js.map} +1 -1
- package/dist/canvas-controller-a926ab2b.js +2 -0
- package/dist/canvas-controller-a926ab2b.js.map +1 -0
- package/dist/canvas-controller-e2503333.js +2 -0
- package/dist/canvas-controller-e2503333.js.map +1 -0
- package/dist/{canvas-logger-295dafe4.js → canvas-logger-6f4b2551.js} +2 -2
- package/dist/{canvas-logger-295dafe4.js.map → canvas-logger-6f4b2551.js.map} +1 -1
- package/dist/{canvas-logger-e07a0b4a.js → canvas-logger-ab9d9048.js} +2 -2
- package/dist/{canvas-logger-e07a0b4a.js.map → canvas-logger-ab9d9048.js.map} +1 -1
- package/dist/common-canvas-41b0454f.js +2 -0
- package/dist/common-canvas-41b0454f.js.map +1 -0
- package/dist/common-canvas-460a4434.js +2 -0
- package/dist/common-canvas-460a4434.js.map +1 -0
- package/dist/common-canvas.es.js +1 -1
- package/dist/common-canvas.js +1 -1
- package/dist/common-properties-b25b4855.js +2 -0
- package/dist/{common-properties-08707efe.js.map → common-properties-b25b4855.js.map} +1 -1
- package/dist/common-properties-e262caa2.js +2 -0
- package/dist/{common-properties-acd55e94.js.map → common-properties-e262caa2.js.map} +1 -1
- package/dist/context-menu-wrapper-949393c7.js +2 -0
- package/dist/{context-menu-wrapper-e4a7ab4d.js.map → context-menu-wrapper-949393c7.js.map} +1 -1
- package/dist/context-menu-wrapper-f62dfcdb.js +2 -0
- package/dist/{context-menu-wrapper-271eb2df.js.map → context-menu-wrapper-f62dfcdb.js.map} +1 -1
- package/dist/{createClass-440000a3.js → createClass-02596015.js} +2 -2
- package/dist/createClass-02596015.js.map +1 -0
- package/dist/createClass-155bf7da.js +2 -0
- package/dist/createClass-155bf7da.js.map +1 -0
- package/dist/datarecord-metadata-v3-schema-2311ecab.js +2 -0
- package/dist/{datarecord-metadata-v3-schema-03427296.js.map → datarecord-metadata-v3-schema-2311ecab.js.map} +1 -1
- package/dist/datarecord-metadata-v3-schema-d279dbb0.js +2 -0
- package/dist/{datarecord-metadata-v3-schema-dba0b214.js.map → datarecord-metadata-v3-schema-d279dbb0.js.map} +1 -1
- package/dist/defineProperty-ad55dbff.js +2 -0
- package/dist/{defineProperty-3dc7d8d0.js.map → defineProperty-ad55dbff.js.map} +1 -1
- package/dist/{defineProperty-6d406743.js → defineProperty-bcc9968d.js} +2 -2
- package/dist/{defineProperty-6d406743.js.map → defineProperty-bcc9968d.js.map} +1 -1
- package/dist/flexible-table-c6a8b402.js +2 -0
- package/dist/{flexible-table-107ca2fd.js.map → flexible-table-c6a8b402.js.map} +1 -1
- package/dist/flexible-table-f7b294a0.js +2 -0
- package/dist/{flexible-table-5cc1ad6b.js.map → flexible-table-f7b294a0.js.map} +1 -1
- package/dist/{icon-2caf035c.js → icon-65758bb8.js} +2 -2
- package/dist/{icon-2caf035c.js.map → icon-65758bb8.js.map} +1 -1
- package/dist/{icon-e622f99b.js → icon-b3738f1f.js} +2 -2
- package/dist/{icon-e622f99b.js.map → icon-b3738f1f.js.map} +1 -1
- package/dist/index-9eeda306.js +2 -0
- package/dist/{index-5dac3da8.js.map → index-9eeda306.js.map} +1 -1
- package/dist/index-d3371fd0.js +2 -0
- package/dist/{index-fee06179.js.map → index-d3371fd0.js.map} +1 -1
- package/dist/inherits-42ae8426.js +2 -0
- package/dist/inherits-42ae8426.js.map +1 -0
- package/dist/inherits-75817f22.js +2 -0
- package/dist/inherits-75817f22.js.map +1 -0
- package/dist/isArrayLikeObject-04f333a5.js +1 -1
- package/dist/isArrayLikeObject-04f333a5.js.map +1 -1
- package/dist/isArrayLikeObject-7a30aa4b.js +1 -1
- package/dist/isArrayLikeObject-7a30aa4b.js.map +1 -1
- package/dist/lib/canvas-controller.es.js +1 -1
- package/dist/lib/canvas-controller.js +1 -1
- package/dist/lib/canvas.es.js +1 -1
- package/dist/lib/canvas.js +1 -1
- package/dist/lib/command-stack.es.js +1 -1
- package/dist/lib/command-stack.es.js.map +1 -1
- package/dist/lib/command-stack.js +1 -1
- package/dist/lib/command-stack.js.map +1 -1
- package/dist/lib/context-menu.es.js +1 -1
- package/dist/lib/context-menu.js +1 -1
- package/dist/lib/properties/field-picker.es.js +1 -1
- package/dist/lib/properties/field-picker.js +1 -1
- package/dist/lib/properties/flexible-table.es.js +1 -1
- package/dist/lib/properties/flexible-table.js +1 -1
- package/dist/lib/properties.es.js +1 -1
- package/dist/lib/properties.js +1 -1
- package/dist/lib/tooltip.es.js +1 -1
- package/dist/lib/tooltip.es.js.map +1 -1
- package/dist/lib/tooltip.js +1 -1
- package/dist/lib/tooltip.js.map +1 -1
- package/dist/styles/common-canvas.min.css +1 -1
- package/dist/styles/common-canvas.min.css.map +1 -1
- package/dist/toolbar-6af353fa.js +2 -0
- package/dist/toolbar-6af353fa.js.map +1 -0
- package/dist/toolbar-c4e22755.js +2 -0
- package/dist/toolbar-c4e22755.js.map +1 -0
- package/locales/command-actions/locales/en.json +1 -0
- package/locales/command-actions/locales/eo.json +1 -0
- package/package.json +2 -2
- package/src/command-actions/sizeAndPositionObjectsAction.js +4 -0
- package/src/command-stack/command-stack.js +4 -0
- package/src/common-canvas/canvas-controller.js +47 -10
- package/src/common-canvas/cc-context-toolbar.jsx +46 -2
- package/src/common-canvas/cc-toolbar.jsx +12 -4
- package/src/common-canvas/common-canvas-utils.js +73 -2
- package/src/common-canvas/common-canvas.scss +5 -5
- package/src/common-canvas/constants/canvas-constants.js +1 -0
- package/src/common-canvas/svg-canvas-d3.js +2 -2
- package/src/common-canvas/svg-canvas-pipeline.js +1 -1
- package/src/common-canvas/svg-canvas-renderer.js +142 -75
- package/src/common-canvas/svg-canvas-utils-drag-objects.js +3 -0
- package/src/common-canvas/svg-canvas-utils-external.js +1 -1
- package/src/common-canvas/svg-canvas-utils-links.js +28 -32
- package/src/common-canvas/svg-canvas-utils-nodes.js +5 -13
- package/src/common-canvas/svg-canvas-utils-zoom.js +5 -4
- package/src/icons/icon.scss +1 -1
- package/src/object-model/config-utils.js +2 -2
- package/src/object-model/layout-dimensions.js +82 -87
- package/src/object-model/object-model-utils.js +271 -0
- package/src/object-model/object-model.js +28 -240
- package/src/toolbar/toolbar-action-item.jsx +2 -1
- package/src/toolbar/toolbar-button-item.jsx +3 -2
- package/src/toolbar/toolbar-overflow-item.jsx +10 -4
- package/src/toolbar/toolbar.jsx +5 -2
- package/src/toolbar/toolbar.scss +28 -31
- package/stats.html +1 -1
- package/dist/canvas-controller-6726b9ac.js +0 -2
- package/dist/canvas-controller-6726b9ac.js.map +0 -1
- package/dist/canvas-controller-6c6bc68f.js +0 -2
- package/dist/canvas-controller-6c6bc68f.js.map +0 -1
- package/dist/common-canvas-9374ef35.js +0 -2
- package/dist/common-canvas-9374ef35.js.map +0 -1
- package/dist/common-canvas-a6435bdb.js +0 -2
- package/dist/common-canvas-a6435bdb.js.map +0 -1
- package/dist/common-properties-08707efe.js +0 -2
- package/dist/common-properties-acd55e94.js +0 -2
- package/dist/context-menu-wrapper-271eb2df.js +0 -2
- package/dist/context-menu-wrapper-e4a7ab4d.js +0 -2
- package/dist/createClass-440000a3.js.map +0 -1
- package/dist/createClass-5ca26865.js +0 -2
- package/dist/createClass-5ca26865.js.map +0 -1
- package/dist/datarecord-metadata-v3-schema-03427296.js +0 -2
- package/dist/datarecord-metadata-v3-schema-dba0b214.js +0 -2
- package/dist/defineProperty-3dc7d8d0.js +0 -2
- package/dist/flexible-table-107ca2fd.js +0 -2
- package/dist/flexible-table-5cc1ad6b.js +0 -2
- package/dist/index-5dac3da8.js +0 -2
- package/dist/index-fee06179.js +0 -2
- package/dist/inherits-226dfdb2.js +0 -2
- package/dist/inherits-226dfdb2.js.map +0 -1
- package/dist/inherits-41673c87.js +0 -2
- package/dist/inherits-41673c87.js.map +0 -1
- package/dist/toolbar-ccc1d600.js +0 -2
- package/dist/toolbar-ccc1d600.js.map +0 -1
- package/dist/toolbar-e4445bf8.js +0 -2
- package/dist/toolbar-e4445bf8.js.map +0 -1
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 Elyra Authors
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import CanvasUtils from "../common-canvas/common-canvas-utils";
|
|
18
|
+
import { isEmpty } from "lodash";
|
|
19
|
+
|
|
20
|
+
import {
|
|
21
|
+
SUPER_NODE,
|
|
22
|
+
SNAP_TO_GRID_AFTER, SNAP_TO_GRID_DURING,
|
|
23
|
+
} from "../common-canvas/constants/canvas-constants.js";
|
|
24
|
+
|
|
25
|
+
// Does all preparation needed for nodes in all pipelines before they are saved into Redux. This includes:
|
|
26
|
+
// * setting isSupernodeInputBinding and isSupernodeOutputBinding booleans if approrpiate
|
|
27
|
+
// * calculating snap-to-grid positions
|
|
28
|
+
// * calculating the dimensions of nodes based on the space needed to accomodate the ports
|
|
29
|
+
export function prepareNodes(pipelines, nodeLayout, canvasLayout, layoutHandler, supernode) {
|
|
30
|
+
const newPipelines = setSupernodesBindingStatus(pipelines, supernode);
|
|
31
|
+
return newPipelines.map((pipeline) => setPipelineObjectAttributes(pipeline, nodeLayout, canvasLayout, layoutHandler));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Loops through all the pipelines and adds the appropriate supernode binding
|
|
35
|
+
// attribute to any binding nodes that are referenced by the ports of a supernode.
|
|
36
|
+
function setSupernodesBindingStatus(pipelines, supernode) {
|
|
37
|
+
// First, clear all supernode binding statuses from nodes
|
|
38
|
+
pipelines.forEach((pipeline) => {
|
|
39
|
+
if (pipeline.nodes) {
|
|
40
|
+
pipeline.nodes.forEach((node) => {
|
|
41
|
+
delete node.isSupernodeInputBinding;
|
|
42
|
+
delete node.isSupernodeOutputBinding;
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
if (supernode) {
|
|
48
|
+
setSupernodesBindingStatusForNode(supernode, pipelines);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Set the supernode binding statuses as appropriate.
|
|
52
|
+
pipelines.forEach((pipeline) => {
|
|
53
|
+
if (pipeline.nodes) {
|
|
54
|
+
CanvasUtils.filterSupernodes(pipeline.nodes).forEach((node) => {
|
|
55
|
+
setSupernodesBindingStatusForNode(node, pipelines);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
return pipelines;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
function setSupernodesBindingStatusForNode(node, pipelines) {
|
|
64
|
+
const snPipelineId = CanvasUtils.getSupernodePipelineId(node);
|
|
65
|
+
if (snPipelineId) {
|
|
66
|
+
if (node.inputs) {
|
|
67
|
+
node.inputs.forEach((input) => {
|
|
68
|
+
if (input.subflow_node_ref) {
|
|
69
|
+
const subNode = findNode(input.subflow_node_ref, snPipelineId, pipelines);
|
|
70
|
+
if (subNode) {
|
|
71
|
+
subNode.isSupernodeInputBinding = true;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
if (node.outputs) {
|
|
77
|
+
node.outputs.forEach((output) => {
|
|
78
|
+
if (output.subflow_node_ref) {
|
|
79
|
+
const subNode = findNode(output.subflow_node_ref, snPipelineId, pipelines);
|
|
80
|
+
if (subNode) {
|
|
81
|
+
subNode.isSupernodeOutputBinding = true;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
// Sets the auto-calculated attributes for nodes and comments based on different layout
|
|
91
|
+
// informaiton for the pipeline passed in.
|
|
92
|
+
function setPipelineObjectAttributes(inPipeline, nodeLayout, canvasLayout, layoutHandler) {
|
|
93
|
+
const pipeline = Object.assign({}, inPipeline);
|
|
94
|
+
if (pipeline.nodes) {
|
|
95
|
+
pipeline.nodes = pipeline.nodes.map((node) => setNodeAttributesWithLayout(node, nodeLayout, canvasLayout, layoutHandler));
|
|
96
|
+
} else {
|
|
97
|
+
pipeline.nodes = [];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (pipeline.comments) {
|
|
101
|
+
pipeline.comments = pipeline.comments.map((comment) => setCommentAttributesWithLayout(comment, canvasLayout));
|
|
102
|
+
} else {
|
|
103
|
+
pipeline.comments = [];
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return pipeline;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Returns a copy of the node passed in using the layout info provided. The
|
|
110
|
+
// returned node is augmented with additional fields which contain
|
|
111
|
+
// layout, dimension and supernode binding status info.
|
|
112
|
+
export function setNodeAttributesWithLayout(node, nodeLayout, canvasLayout, layoutHandler) {
|
|
113
|
+
let newNode = Object.assign({}, node);
|
|
114
|
+
newNode = setNodeLayoutAttributes(newNode, nodeLayout, layoutHandler);
|
|
115
|
+
|
|
116
|
+
if (canvasLayout.linkDirection === "TopBottom" ||
|
|
117
|
+
canvasLayout.linkDirection === "BottomTop") {
|
|
118
|
+
newNode = setNodeDimensionAttributesVertical(newNode, canvasLayout);
|
|
119
|
+
} else {
|
|
120
|
+
newNode = setNodeDimensionAttributesHoriz(newNode, canvasLayout);
|
|
121
|
+
}
|
|
122
|
+
if (canvasLayout.snapToGridType === SNAP_TO_GRID_DURING ||
|
|
123
|
+
canvasLayout.snapToGridType === SNAP_TO_GRID_AFTER) {
|
|
124
|
+
newNode.x_pos = CanvasUtils.snapToGrid(newNode.x_pos, canvasLayout.snapToGridXPx);
|
|
125
|
+
newNode.y_pos = CanvasUtils.snapToGrid(newNode.y_pos, canvasLayout.snapToGridYPx);
|
|
126
|
+
}
|
|
127
|
+
return newNode;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Returns the node passed in with additional fields which contains
|
|
131
|
+
// the layout info.
|
|
132
|
+
function setNodeLayoutAttributes(node, nodeLayout, layoutHandler) {
|
|
133
|
+
node.layout = nodeLayout;
|
|
134
|
+
|
|
135
|
+
if (layoutHandler) {
|
|
136
|
+
let customLayout = layoutHandler(node);
|
|
137
|
+
|
|
138
|
+
// If using the layoutHandler we must make a copy of the layout info
|
|
139
|
+
// for each node so the original single version of layout info attached
|
|
140
|
+
// to the node doesn't get overwritten.
|
|
141
|
+
if (customLayout && !isEmpty(customLayout)) {
|
|
142
|
+
// TODO - This should be removed in a future major release.
|
|
143
|
+
// This method converts now deprecated layout variables from customLayout
|
|
144
|
+
// to the new port positions arrays for input and output ports.
|
|
145
|
+
customLayout = CanvasUtils.convertPortPosInfo(customLayout);
|
|
146
|
+
|
|
147
|
+
const decs = CanvasUtils.getCombinedDecorations(node.layout.decorations, customLayout.decorations);
|
|
148
|
+
node.layout = Object.assign({}, node.layout, customLayout, { decorations: decs });
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return node;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Returns the node passed in with additional fields which contains
|
|
155
|
+
// the height occupied by the input ports and output ports, based on the
|
|
156
|
+
// layout info passed in, as well as the node width.
|
|
157
|
+
function setNodeDimensionAttributesHoriz(node, canvasLayout) {
|
|
158
|
+
node.inputPortsHeight = node.inputs ? getInputPortsHeight(node) : 0;
|
|
159
|
+
node.outputPortsHeight = node.outputs ? getOutputPortsHeight(node) : 0;
|
|
160
|
+
|
|
161
|
+
if (node.layout.autoSizeNode) {
|
|
162
|
+
node.height = Math.max(node.inputPortsHeight, node.outputPortsHeight, node.layout.defaultNodeHeight);
|
|
163
|
+
|
|
164
|
+
} else {
|
|
165
|
+
node.height = node.layout.defaultNodeHeight;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
node.width = node.layout.defaultNodeWidth;
|
|
169
|
+
|
|
170
|
+
if (node.type === SUPER_NODE && node.is_expanded) {
|
|
171
|
+
node.height += canvasLayout.supernodeTopAreaHeight + canvasLayout.supernodeSVGAreaPadding;
|
|
172
|
+
// If an expanded height is provided make sure it is at least as big
|
|
173
|
+
// as the node height.
|
|
174
|
+
if (node.expanded_height) {
|
|
175
|
+
node.expanded_height = Math.max(node.expanded_height, node.height);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
node.width = CanvasUtils.getSupernodeExpandedWidth(node, canvasLayout);
|
|
179
|
+
node.height = CanvasUtils.getSupernodeExpandedHeight(node, canvasLayout);
|
|
180
|
+
|
|
181
|
+
} else if (node.isResized) {
|
|
182
|
+
node.height = node.resizeHeight ? node.resizeHeight : node.height;
|
|
183
|
+
node.width = node.resizeWidth ? node.resizeWidth : node.width;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return node;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// Returns the height of the input ports for the node if they are automatically
|
|
190
|
+
// positioned by common-canvas.
|
|
191
|
+
function getInputPortsHeight(node) {
|
|
192
|
+
return (node.inputs.length * (node.layout.portArcRadius * 2)) +
|
|
193
|
+
((node.inputs.length - 1) * node.layout.portArcSpacing) + (node.layout.portArcOffset * 2);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// Returns the height of the output ports for the node if they are automatically
|
|
197
|
+
// positioned by common-canvas.
|
|
198
|
+
function getOutputPortsHeight(node) {
|
|
199
|
+
return (node.outputs.length * (node.layout.portArcRadius * 2)) +
|
|
200
|
+
((node.outputs.length - 1) * node.layout.portArcSpacing) + (node.layout.portArcOffset * 2);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// Returns the node passed in with additional fields which contains
|
|
204
|
+
// the width occupied by the input ports and output ports, based on the
|
|
205
|
+
// layout info passed in, as well as the node height.
|
|
206
|
+
function setNodeDimensionAttributesVertical(node, canvasLayout) {
|
|
207
|
+
node.inputPortsWidth = node.inputs ? getInputPortsWidth(node) : 0;
|
|
208
|
+
node.outputPortsWidth = node.outputs ? getOutputPortsWidth(node) : 0;
|
|
209
|
+
|
|
210
|
+
node.height = node.layout.defaultNodeHeight;
|
|
211
|
+
|
|
212
|
+
if (node.layout.autoSizeNode) {
|
|
213
|
+
node.width = Math.max(node.inputPortsWidth, node.outputPortsWidth, node.layout.defaultNodeWidth);
|
|
214
|
+
|
|
215
|
+
} else {
|
|
216
|
+
node.width = node.layout.defaultNodeWidth;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
if (node.type === SUPER_NODE && node.is_expanded) {
|
|
220
|
+
node.width += (2 * canvasLayout.supernodeSVGAreaPadding);
|
|
221
|
+
// If an expanded width is provided make sure it is at least as big
|
|
222
|
+
// as the node width.
|
|
223
|
+
if (node.expanded_width) {
|
|
224
|
+
node.expanded_width = Math.max(node.expanded_width, node.width);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
node.width = CanvasUtils.getSupernodeExpandedWidth(node, canvasLayout);
|
|
228
|
+
node.height = CanvasUtils.getSupernodeExpandedHeight(node, canvasLayout);
|
|
229
|
+
|
|
230
|
+
} else if (node.isResized) {
|
|
231
|
+
node.height = node.resizeHeight ? node.resizeHeight : node.height;
|
|
232
|
+
node.width = node.resizeWidth ? node.resizeWidth : node.width;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
return node;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// Returns the width of the input ports for the node if they are automatically
|
|
239
|
+
// positioned by common-canvas or zero if ports will be manually positioned..
|
|
240
|
+
function getInputPortsWidth(node) {
|
|
241
|
+
return (node.inputs.length * (node.layout.portArcRadius * 2)) +
|
|
242
|
+
((node.inputs.length - 1) * node.layout.portArcSpacing) + (node.layout.portArcOffset * 2);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// Returns the width of the output ports for the node if they are automatically
|
|
246
|
+
// positioned by common-canvas or zero if ports will be manually positioned..
|
|
247
|
+
function getOutputPortsWidth(node) {
|
|
248
|
+
return (node.outputs.length * (node.layout.portArcRadius * 2)) +
|
|
249
|
+
((node.outputs.length - 1) * node.layout.portArcSpacing) + (node.layout.portArcOffset * 2);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function findNode(nodeId, pipelineId, pipelines) {
|
|
253
|
+
const targetPipeline = pipelines.find((p) => p.id === pipelineId);
|
|
254
|
+
|
|
255
|
+
if (targetPipeline && targetPipeline.nodes) {
|
|
256
|
+
return targetPipeline.nodes.find((node) => node.id === nodeId);
|
|
257
|
+
}
|
|
258
|
+
return null;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// Returns a copy of the comment passed using the layout info provided. The
|
|
262
|
+
// returned comment has its position adjusted for snap to grid, if necessary.
|
|
263
|
+
export function setCommentAttributesWithLayout(comment, canvasLayout) {
|
|
264
|
+
const newComment = Object.assign({}, comment);
|
|
265
|
+
if (canvasLayout.snapToGridType === SNAP_TO_GRID_DURING ||
|
|
266
|
+
canvasLayout.snapToGridType === SNAP_TO_GRID_AFTER) {
|
|
267
|
+
newComment.x_pos = CanvasUtils.snapToGrid(newComment.x_pos, canvasLayout.snapToGridXPx);
|
|
268
|
+
newComment.y_pos = CanvasUtils.snapToGrid(newComment.y_pos, canvasLayout.snapToGridYPx);
|
|
269
|
+
}
|
|
270
|
+
return newComment;
|
|
271
|
+
}
|