@elyra/canvas 12.42.0 → 12.44.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.
Files changed (185) hide show
  1. package/dist/{canvas-constants-ff5cf88e.js → canvas-constants-089e7830.js} +2 -2
  2. package/dist/{canvas-constants-ff5cf88e.js.map → canvas-constants-089e7830.js.map} +1 -1
  3. package/dist/{canvas-constants-13b58448.js → canvas-constants-69e90162.js} +2 -2
  4. package/dist/{canvas-constants-13b58448.js.map → canvas-constants-69e90162.js.map} +1 -1
  5. package/dist/canvas-controller-3e6b8ce4.js +2 -0
  6. package/dist/canvas-controller-3e6b8ce4.js.map +1 -0
  7. package/dist/canvas-controller-c6274fad.js +2 -0
  8. package/dist/canvas-controller-c6274fad.js.map +1 -0
  9. package/dist/{canvas-logger-295dafe4.js → canvas-logger-6f4b2551.js} +2 -2
  10. package/dist/{canvas-logger-295dafe4.js.map → canvas-logger-6f4b2551.js.map} +1 -1
  11. package/dist/{canvas-logger-e07a0b4a.js → canvas-logger-ab9d9048.js} +2 -2
  12. package/dist/{canvas-logger-e07a0b4a.js.map → canvas-logger-ab9d9048.js.map} +1 -1
  13. package/dist/common-canvas-6ed21ab6.js +2 -0
  14. package/dist/common-canvas-6ed21ab6.js.map +1 -0
  15. package/dist/common-canvas-8abf016c.js +2 -0
  16. package/dist/common-canvas-8abf016c.js.map +1 -0
  17. package/dist/common-canvas.es.js +1 -1
  18. package/dist/common-canvas.es.js.map +1 -1
  19. package/dist/common-canvas.js +1 -1
  20. package/dist/common-canvas.js.map +1 -1
  21. package/dist/common-properties-88377242.js +2 -0
  22. package/dist/common-properties-88377242.js.map +1 -0
  23. package/dist/common-properties-b295acc8.js +2 -0
  24. package/dist/common-properties-b295acc8.js.map +1 -0
  25. package/dist/context-menu-wrapper-949393c7.js +2 -0
  26. package/dist/context-menu-wrapper-949393c7.js.map +1 -0
  27. package/dist/context-menu-wrapper-f62dfcdb.js +2 -0
  28. package/dist/context-menu-wrapper-f62dfcdb.js.map +1 -0
  29. package/dist/{createClass-440000a3.js → createClass-02596015.js} +2 -2
  30. package/dist/createClass-02596015.js.map +1 -0
  31. package/dist/createClass-155bf7da.js +2 -0
  32. package/dist/createClass-155bf7da.js.map +1 -0
  33. package/dist/datarecord-metadata-v3-schema-07d18e19.js +2 -0
  34. package/dist/{datarecord-metadata-v3-schema-98ec66e9.js.map → datarecord-metadata-v3-schema-07d18e19.js.map} +1 -1
  35. package/dist/datarecord-metadata-v3-schema-df939dd1.js +2 -0
  36. package/dist/{datarecord-metadata-v3-schema-dba0b214.js.map → datarecord-metadata-v3-schema-df939dd1.js.map} +1 -1
  37. package/dist/defineProperty-ad55dbff.js +2 -0
  38. package/dist/{defineProperty-3dc7d8d0.js.map → defineProperty-ad55dbff.js.map} +1 -1
  39. package/dist/{defineProperty-6d406743.js → defineProperty-bcc9968d.js} +2 -2
  40. package/dist/{defineProperty-6d406743.js.map → defineProperty-bcc9968d.js.map} +1 -1
  41. package/dist/flexible-table-c6a8b402.js +2 -0
  42. package/dist/{flexible-table-7c7de0f9.js.map → flexible-table-c6a8b402.js.map} +1 -1
  43. package/dist/flexible-table-f7b294a0.js +2 -0
  44. package/dist/{flexible-table-35e9922a.js.map → flexible-table-f7b294a0.js.map} +1 -1
  45. package/dist/{icon-9edff40c.js → icon-56b27c4f.js} +2 -2
  46. package/dist/{icon-9edff40c.js.map → icon-56b27c4f.js.map} +1 -1
  47. package/dist/{icon-e622f99b.js → icon-8ec2f0ec.js} +2 -2
  48. package/dist/{icon-e622f99b.js.map → icon-8ec2f0ec.js.map} +1 -1
  49. package/dist/index-01cbacf9.js +2 -0
  50. package/dist/{index-e2f8a935.js.map → index-01cbacf9.js.map} +1 -1
  51. package/dist/index-79543d41.js +2 -0
  52. package/dist/{index-94fec521.js.map → index-79543d41.js.map} +1 -1
  53. package/dist/inherits-42ae8426.js +2 -0
  54. package/dist/inherits-42ae8426.js.map +1 -0
  55. package/dist/inherits-75817f22.js +2 -0
  56. package/dist/inherits-75817f22.js.map +1 -0
  57. package/dist/isArrayLikeObject-04f333a5.js +1 -1
  58. package/dist/isArrayLikeObject-04f333a5.js.map +1 -1
  59. package/dist/isArrayLikeObject-7a30aa4b.js +1 -1
  60. package/dist/isArrayLikeObject-7a30aa4b.js.map +1 -1
  61. package/dist/lib/canvas-controller.es.js +1 -1
  62. package/dist/lib/canvas-controller.js +1 -1
  63. package/dist/lib/canvas.es.js +1 -1
  64. package/dist/lib/canvas.js +1 -1
  65. package/dist/lib/command-stack.es.js +1 -1
  66. package/dist/lib/command-stack.es.js.map +1 -1
  67. package/dist/lib/command-stack.js +1 -1
  68. package/dist/lib/command-stack.js.map +1 -1
  69. package/dist/lib/context-menu.es.js +1 -1
  70. package/dist/lib/context-menu.js +1 -1
  71. package/dist/lib/properties/clem.es.js +2 -0
  72. package/dist/lib/properties/clem.es.js.map +1 -0
  73. package/dist/lib/properties/clem.js +2 -0
  74. package/dist/lib/properties/clem.js.map +1 -0
  75. package/dist/lib/properties/field-picker.es.js +1 -1
  76. package/dist/lib/properties/field-picker.js +1 -1
  77. package/dist/lib/properties/flexible-table.es.js +1 -1
  78. package/dist/lib/properties/flexible-table.js +1 -1
  79. package/dist/lib/properties/getPythonHints.es.js +2 -0
  80. package/dist/lib/properties/getPythonHints.es.js.map +1 -0
  81. package/dist/lib/properties/getPythonHints.js +2 -0
  82. package/dist/lib/properties/getPythonHints.js.map +1 -0
  83. package/dist/lib/properties.es.js +1 -1
  84. package/dist/lib/properties.js +1 -1
  85. package/dist/lib/tooltip.es.js +1 -1
  86. package/dist/lib/tooltip.es.js.map +1 -1
  87. package/dist/lib/tooltip.js +1 -1
  88. package/dist/lib/tooltip.js.map +1 -1
  89. package/dist/styles/common-canvas.min.css +1 -1
  90. package/dist/styles/common-canvas.min.css.map +1 -1
  91. package/dist/toolbar-235dfb9d.js +2 -0
  92. package/dist/toolbar-235dfb9d.js.map +1 -0
  93. package/dist/toolbar-6607e35c.js +2 -0
  94. package/dist/toolbar-6607e35c.js.map +1 -0
  95. package/package.json +3 -3
  96. package/rollup.config.js +2 -0
  97. package/src/color-picker/color-picker.jsx +5 -1
  98. package/src/common-canvas/canvas-controller.js +56 -1
  99. package/src/common-canvas/cc-central-items.jsx +0 -4
  100. package/src/common-canvas/cc-toolbar.jsx +35 -13
  101. package/src/common-canvas/common-canvas-utils.js +73 -2
  102. package/src/common-canvas/common-canvas.scss +8 -8
  103. package/src/common-canvas/constants/canvas-constants.js +1 -0
  104. package/src/common-canvas/svg-canvas-d3.scss +3 -2
  105. package/src/common-canvas/svg-canvas-renderer.js +184 -94
  106. package/src/common-canvas/svg-canvas-utils-external.js +1 -1
  107. package/src/common-canvas/svg-canvas-utils-links.js +28 -32
  108. package/src/common-canvas/svg-canvas-utils-nodes.js +5 -13
  109. package/src/common-properties/components/field-picker/field-picker.jsx +4 -0
  110. package/src/common-properties/controls/checkbox/checkbox.scss +0 -1
  111. package/src/common-properties/controls/expression/expression.jsx +3 -5
  112. package/src/common-properties/controls/expression/languages/python-hint.js +18 -30
  113. package/src/common-properties/controls/expression/languages/r-hint.js +16 -8
  114. package/src/common-properties/index.js +4 -2
  115. package/src/icons/icon.scss +1 -1
  116. package/src/index.js +2 -2
  117. package/src/notification-panel/notification-panel.jsx +82 -56
  118. package/src/notification-panel/notification-panel.scss +42 -40
  119. package/src/object-model/config-utils.js +2 -2
  120. package/src/object-model/layout-dimensions.js +82 -87
  121. package/src/object-model/object-model-utils.js +271 -0
  122. package/src/object-model/object-model.js +47 -245
  123. package/src/object-model/redux/reducers/canvasinfo.js +7 -11
  124. package/src/object-model/redux/reducers/canvastoolbar.js +5 -6
  125. package/src/palette/palette-dialog-topbar.jsx +27 -38
  126. package/src/palette/palette-flyout-content-category.jsx +25 -6
  127. package/src/palette/palette.scss +8 -40
  128. package/src/toolbar/index.js +18 -0
  129. package/src/toolbar/toolbar-action-item.jsx +42 -11
  130. package/src/toolbar/toolbar-button-item.jsx +49 -21
  131. package/src/toolbar/toolbar-divider-item.jsx +1 -1
  132. package/src/toolbar/toolbar-overflow-item.jsx +14 -6
  133. package/src/toolbar/toolbar-sub-menu-item.jsx +6 -5
  134. package/src/toolbar/toolbar-sub-menu.jsx +4 -6
  135. package/src/toolbar/toolbar-sub-panel.jsx +31 -18
  136. package/src/toolbar/toolbar-sub-utils.js +21 -12
  137. package/src/toolbar/toolbar.jsx +83 -26
  138. package/src/toolbar/toolbar.scss +47 -47
  139. package/src/tooltip/tooltip.jsx +56 -10
  140. package/stats.html +1 -1
  141. package/assets/images/palette/close_32.svg +0 -1
  142. package/assets/images/palette/palette_close.svg +0 -4
  143. package/assets/images/palette/palette_grid_deselected.svg +0 -2
  144. package/assets/images/palette/palette_grid_hover.svg +0 -2
  145. package/assets/images/palette/palette_grid_selected.svg +0 -2
  146. package/assets/images/palette/palette_list_deselected.svg +0 -1
  147. package/assets/images/palette/palette_list_hover.svg +0 -1
  148. package/assets/images/palette/palette_list_selected.svg +0 -1
  149. package/assets/images/palette/palette_open.svg +0 -4
  150. package/assets/images/zoom_to_fit.svg +0 -8
  151. package/dist/canvas-controller-a53943e4.js +0 -2
  152. package/dist/canvas-controller-a53943e4.js.map +0 -1
  153. package/dist/canvas-controller-cb1d7420.js +0 -2
  154. package/dist/canvas-controller-cb1d7420.js.map +0 -1
  155. package/dist/common-canvas-42027a3f.js +0 -2
  156. package/dist/common-canvas-42027a3f.js.map +0 -1
  157. package/dist/common-canvas-f758ff42.js +0 -2
  158. package/dist/common-canvas-f758ff42.js.map +0 -1
  159. package/dist/common-properties-2e1b7ec7.js +0 -2
  160. package/dist/common-properties-2e1b7ec7.js.map +0 -1
  161. package/dist/common-properties-5e8870e3.js +0 -2
  162. package/dist/common-properties-5e8870e3.js.map +0 -1
  163. package/dist/context-menu-wrapper-49f9a1af.js +0 -2
  164. package/dist/context-menu-wrapper-49f9a1af.js.map +0 -1
  165. package/dist/context-menu-wrapper-5d6a399f.js +0 -2
  166. package/dist/context-menu-wrapper-5d6a399f.js.map +0 -1
  167. package/dist/createClass-440000a3.js.map +0 -1
  168. package/dist/createClass-5ca26865.js +0 -2
  169. package/dist/createClass-5ca26865.js.map +0 -1
  170. package/dist/datarecord-metadata-v3-schema-98ec66e9.js +0 -2
  171. package/dist/datarecord-metadata-v3-schema-dba0b214.js +0 -2
  172. package/dist/defineProperty-3dc7d8d0.js +0 -2
  173. package/dist/flexible-table-35e9922a.js +0 -2
  174. package/dist/flexible-table-7c7de0f9.js +0 -2
  175. package/dist/index-94fec521.js +0 -2
  176. package/dist/index-e2f8a935.js +0 -2
  177. package/dist/inherits-226dfdb2.js +0 -2
  178. package/dist/inherits-226dfdb2.js.map +0 -1
  179. package/dist/inherits-41673c87.js +0 -2
  180. package/dist/inherits-41673c87.js.map +0 -1
  181. package/dist/toolbar-6acda0a2.js +0 -2
  182. package/dist/toolbar-6acda0a2.js.map +0 -1
  183. package/dist/toolbar-d5647da2.js +0 -2
  184. package/dist/toolbar-d5647da2.js.map +0 -1
  185. package/src/palette/palette-dialog-topbar-three-way-icon.jsx +0 -82
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright 2017-2023 Elyra Authors
2
+ * Copyright 2017-2024 Elyra Authors
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -14,6 +14,8 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
+ import { cloneDeep } from "lodash";
18
+
17
19
  const portsHorizontalDefaultLayout = {
18
20
  nodeLayout: {
19
21
  // Default node sizes. The height might be overridden for nodes with more ports
@@ -154,26 +156,19 @@ const portsHorizontalDefaultLayout = {
154
156
  inputPortWidth: 12,
155
157
  inputPortHeight: 12,
156
158
 
157
- // Position of left single input port. Multiple input ports will be
158
- // automatically positioned with the Y coordinate being overriden. These
159
- // values are an offset from the top left corner of the node outline.
160
- // Used when linkDirection is "LeftRight".
161
- inputPortLeftPosX: 0,
162
- inputPortLeftPosY: 20,
163
-
164
- // Position of top single input port. Multiple input ports will be
165
- // automatically positioned with the X coordinate being overriden. These
166
- // values are an offset from the top left corner of the node outline.
167
- // Used when linkDirection is "TopBottom".
168
- inputPortTopPosX: 80,
169
- inputPortTopPosY: 0,
170
-
171
- // Position of bottom single input port. Multiple input ports will be
172
- // automatically positioned with the X coordinate being overriden. These
173
- // values are an offset from the bottom left corner of the node outline.
174
- // Used when linkDirection is "BottomTop".
175
- inputPortBottomPosX: 80,
176
- inputPortBottomPosY: 0,
159
+ // Indicates whether multiple input ports should be automatically
160
+ // positioned (true) or positioned based on the contents of
161
+ // inputPortPositions array (false).
162
+ inputPortAutoPosition: true,
163
+
164
+ // An array of input port positions. Each element is structured like
165
+ // this: { x_pos: 5, y_pos: 10, pos: "topLeft" }. x_pos and y_pos are
166
+ // offsets from the pos point on the node.
167
+ // The order of the elements corresponds to the order of ports in the
168
+ // inputs array for the node.
169
+ inputPortPositions: [
170
+ { x_pos: 0, y_pos: 20, pos: "topLeft" }
171
+ ],
177
172
 
178
173
  // The 'guide' is the object drawn at the mouse position as a new line
179
174
  // is being dragged outwards.
@@ -196,27 +191,19 @@ const portsHorizontalDefaultLayout = {
196
191
  outputPortWidth: 12,
197
192
  outputPortHeight: 12,
198
193
 
199
- // Position of right single output port. Multiple input ports will be
200
- // automatically positioned with the Y coordinate being overriden. These
201
- // values are an offset from the top right corner of the node outline.
202
- // Used when linkDirection is "LeftRight".
203
- outputPortRightPosition: "topRight",
204
- outputPortRightPosX: 0,
205
- outputPortRightPosY: 20,
206
-
207
- // Position of top single output port. Multiple input ports will be
208
- // automatically positioned with the X coordinate being overriden. These
209
- // values are an offset from the top left corner of the node outline.
210
- // Used when linkDirection is "BottomTop".
211
- outputPortTopPosX: 80,
212
- outputPortTopPosY: 0,
213
-
214
- // Position of bottom single output port. Multiple input ports will be
215
- // automatically positioned with the X coordinate being overriden. These
216
- // values are an offset from the bottom left corner of the node outline.
217
- // Used when linkDirection is "TopBottom".
218
- outputPortBottomPosX: 80,
219
- outputPortBottomPosY: 0,
194
+ // Indicates whether multiple output ports should be automatically
195
+ // positioned (true) or positioned based on the contents of
196
+ // outputPortPositions array (false).
197
+ outputPortAutoPosition: true,
198
+
199
+ // An array of output port positions. Each element is structured like
200
+ // this: { x_pos: 5, y_pos: 10, pos: "topRight" }. x_pos and y_pos are
201
+ // offsets from the pos point on the node.
202
+ // The order of the elements corresponds to the order of ports in the
203
+ // outputs array for the node.
204
+ outputPortPositions: [
205
+ { x_pos: 0, y_pos: 20, pos: "topRight" }
206
+ ],
220
207
 
221
208
  // The 'guide' is the object drawn at the mouse position as a new line
222
209
  // is being dragged outwards.
@@ -412,7 +399,7 @@ const portsHorizontalDefaultLayout = {
412
399
  // to switch the data-new-link-over attribute to "yes".
413
400
  nodeProximity: 20,
414
401
 
415
- // Adds additional area around the ghost areaa dragged from the palette
402
+ // Adds additional area around the ghost area dragged from the palette
416
403
  // which can increase the possibility of detecting detached links.
417
404
  ghostAreaPadding: 10,
418
405
 
@@ -569,26 +556,19 @@ const portsVerticalDefaultLayout = {
569
556
  inputPortWidth: 12,
570
557
  inputPortHeight: 12,
571
558
 
572
- // Position of left single input port. Multiple input ports will be
573
- // automatically positioned with the Y coordinate being overriden. These
574
- // values are an offset from the top left corner of the node outline.
575
- // Used when linkDirection is "LeftRight".
576
- inputPortLeftPosX: 0,
577
- inputPortLeftPosY: 29,
578
-
579
- // Position of top single input port. Multiple input ports will be
580
- // automatically positioned with the X coordinate being overriden. These
581
- // values are an offset from the top left corner of the node outline.
582
- // Used when linkDirection is "TopBottom".
583
- inputPortTopPosX: 35,
584
- inputPortTopPosY: 0,
585
-
586
- // Position of bottom single input port. Multiple input ports will be
587
- // automatically positioned with the X coordinate being overriden. These
588
- // values are an offset from the bottom left corner of the node outline.
589
- // Used when linkDirection is "BottomTop".
590
- inputPortBottomPosX: 35,
591
- inputPortBottomPosY: 0,
559
+ // Indicates whether multiple input ports should be automatically
560
+ // positioned (true) or positioned based on the contents of
561
+ // inputPortPositions array (false).
562
+ inputPortAutoPosition: true,
563
+
564
+ // An array of input port positions. Each element is structured like
565
+ // this: { x_pos: 5, y_pos: 10, pos: "topLeft" }. x_pos and y_pos are
566
+ // offsets from the pos point on the node.
567
+ // The order of the elements corresponds to the order of ports in the
568
+ // inputs array for the node.
569
+ inputPortPositions: [
570
+ { x_pos: 0, y_pos: 29, pos: "topLeft" }
571
+ ],
592
572
 
593
573
  // The 'guide' is the object drawn at the mouse position as a new line
594
574
  // is being dragged outwards.
@@ -611,27 +591,19 @@ const portsVerticalDefaultLayout = {
611
591
  outputPortWidth: 12,
612
592
  outputPortHeight: 12,
613
593
 
614
- // Position of right single input port. Multiple input ports will be
615
- // automatically positioned with the Y coordinate being overriden. These
616
- // values are an offset from the top right corner of the node outline.
617
- // Used when linkDirection is "LeftRight".
618
- outputPortRightPosition: "topRight",
619
- outputPortRightPosX: 0,
620
- outputPortRightPosY: 29,
621
-
622
- // Position of top single input port. Multiple input ports will be
623
- // automatically positioned with the X coordinate being overriden. These
624
- // values are an offset from the top left corner of the node outline.
625
- // Used when linkDirection is "BottomTop".
626
- outputPortTopPosX: 35,
627
- outputPortTopPosY: 0,
628
-
629
- // Position of bottom single input port. Multiple input ports will be
630
- // automatically positioned with the X coordinate being overriden. These
631
- // values are an offset from the bottom left corner of the node outline.
632
- // Used when linkDirection is "TopBottom".
633
- outputPortBottomPosX: 35,
634
- outputPortBottomPosY: 0,
594
+ // Indicates whether multiple output ports should be automatically
595
+ // positioned (true) or positioned based on the contents of
596
+ // outputPortPositions array (false).
597
+ outputPortAutoPosition: true,
598
+
599
+ // An array of output port positions. Each element is structured like
600
+ // this: { x_pos: 5, y_pos: 10, pos: "topRight" }. x_pos and y_pos are
601
+ // offsets from the pos point on the node.
602
+ // The order of the elements corresponds to the order of ports in the
603
+ // outputs array for the node.
604
+ outputPortPositions: [
605
+ { x_pos: 0, y_pos: 29, pos: "topRight" }
606
+ ],
635
607
 
636
608
  // The 'guide' is the object drawn at the mouse position as a new line
637
609
  // is being dragged outwards.
@@ -827,7 +799,7 @@ const portsVerticalDefaultLayout = {
827
799
  // to switch the data-new-link-over attribute to "yes".
828
800
  nodeProximity: 20,
829
801
 
830
- // Adds additional area around the ghost areaa dragged from the palette
802
+ // Adds additional area around the ghost area dragged from the palette
831
803
  // which can increase the possibility of detecting detached links.
832
804
  ghostAreaPadding: 10,
833
805
 
@@ -850,7 +822,8 @@ export default class LayoutDimensions {
850
822
  let newLayout = this.getDefaultLayout(config);
851
823
 
852
824
  if (config) {
853
- newLayout = this.overrideNodeLayout(newLayout, overlayLayout); // Do this first because snap-to-grid depends on this.
825
+ newLayout = this.overridePortPositions(newLayout, config); // Must do this before overrideNodeLayout
826
+ newLayout = this.overrideNodeLayout(newLayout, overlayLayout); // Must do this before overrideSnapToGrid
854
827
  newLayout = this.overrideCanvasLayout(newLayout, config, overlayLayout);
855
828
  newLayout = this.overrideLinkType(newLayout, config);
856
829
  newLayout = this.overrideSnapToGrid(newLayout, config);
@@ -867,7 +840,7 @@ export default class LayoutDimensions {
867
840
  } else {
868
841
  defaultLayout = portsHorizontalDefaultLayout;
869
842
  }
870
- return Object.assign({}, defaultLayout);
843
+ return cloneDeep(defaultLayout);
871
844
  }
872
845
 
873
846
  static overrideNodeLayout(layout, overlayLayout) {
@@ -939,4 +912,26 @@ export default class LayoutDimensions {
939
912
  }
940
913
  return Number.parseInt(snapToGridSizeStr, 10);
941
914
  }
915
+
916
+ // Overrides the port positioning fields in the layout based on the type of node
917
+ // and the link direction.
918
+ static overridePortPositions(layout, config) {
919
+ if (config.enableLinkDirection === "BottomTop") {
920
+ layout.nodeLayout.inputPortPositions = [
921
+ { x_pos: 0, y_pos: 0, pos: "bottomCenter" }
922
+ ];
923
+ layout.nodeLayout.outputPortPositions = [
924
+ { x_pos: 0, y_pos: 0, pos: "topCenter" }
925
+ ];
926
+
927
+ } else if (config.enableLinkDirection === "TopBottom") {
928
+ layout.nodeLayout.inputPortPositions = [
929
+ { x_pos: 0, y_pos: 0, pos: "topCenter" }
930
+ ];
931
+ layout.nodeLayout.outputPortPositions = [
932
+ { x_pos: 0, y_pos: 0, pos: "bottomCenter" }
933
+ ];
934
+ }
935
+ return layout;
936
+ }
942
937
  }
@@ -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
+ }