@elyra/canvas 12.30.0 → 12.31.1

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 (163) hide show
  1. package/dist/{extends-7d4f15b6.js → _baseForOwn-ad2a8649.js} +3 -3
  2. package/dist/_baseForOwn-ad2a8649.js.map +1 -0
  3. package/dist/_baseForOwn-bfa77b3e.js +8 -0
  4. package/dist/_baseForOwn-bfa77b3e.js.map +1 -0
  5. package/dist/canvas-constants-187a30d5.js +2 -0
  6. package/dist/canvas-constants-187a30d5.js.map +1 -0
  7. package/dist/canvas-constants-5fb4e9b8.js +2 -0
  8. package/dist/canvas-constants-5fb4e9b8.js.map +1 -0
  9. package/dist/canvas-controller-53bd69c8.js +2 -0
  10. package/dist/canvas-controller-53bd69c8.js.map +1 -0
  11. package/dist/canvas-controller-9551a089.js +2 -0
  12. package/dist/canvas-controller-9551a089.js.map +1 -0
  13. package/dist/common-canvas-1c40c3df.js +2 -0
  14. package/dist/common-canvas-1c40c3df.js.map +1 -0
  15. package/dist/common-canvas-93c3f6a4.js +2 -0
  16. package/dist/common-canvas-93c3f6a4.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-02c52656.js +2 -0
  22. package/dist/common-properties-02c52656.js.map +1 -0
  23. package/dist/common-properties-df2350d5.js +2 -0
  24. package/dist/common-properties-df2350d5.js.map +1 -0
  25. package/dist/context-menu-wrapper-6c8f7928.js +2 -0
  26. package/dist/context-menu-wrapper-6c8f7928.js.map +1 -0
  27. package/dist/context-menu-wrapper-fc78153c.js +2 -0
  28. package/dist/context-menu-wrapper-fc78153c.js.map +1 -0
  29. package/dist/datarecord-metadata-v3-schema-15146f5e.js +2 -0
  30. package/dist/{datarecord-metadata-v3-schema-6a3754ce.js.map → datarecord-metadata-v3-schema-15146f5e.js.map} +1 -1
  31. package/dist/datarecord-metadata-v3-schema-9994b9ee.js +2 -0
  32. package/dist/{datarecord-metadata-v3-schema-ba1f2849.js.map → datarecord-metadata-v3-schema-9994b9ee.js.map} +1 -1
  33. package/dist/extends-093996c9.js +2 -0
  34. package/dist/extends-093996c9.js.map +1 -0
  35. package/dist/extends-1b35a664.js +2 -0
  36. package/dist/extends-1b35a664.js.map +1 -0
  37. package/dist/flexible-table-1f259bf6.js +2 -0
  38. package/dist/flexible-table-1f259bf6.js.map +1 -0
  39. package/dist/flexible-table-aa7a3125.js +2 -0
  40. package/dist/flexible-table-aa7a3125.js.map +1 -0
  41. package/dist/icon-c65ffd4c.js +2 -0
  42. package/dist/{icon-221bb2e5.js.map → icon-c65ffd4c.js.map} +1 -1
  43. package/dist/icon-e1c49d95.js +2 -0
  44. package/dist/{icon-ea917a08.js.map → icon-e1c49d95.js.map} +1 -1
  45. package/dist/index-27d84a2b.js +2 -0
  46. package/dist/{index-aee893ad.js.map → index-27d84a2b.js.map} +1 -1
  47. package/dist/index-6776fe83.js +2 -0
  48. package/dist/{index-92422c18.js.map → index-6776fe83.js.map} +1 -1
  49. package/dist/{isArrayLikeObject-f3b27f64.js → isArrayLikeObject-0cd02b77.js} +2 -2
  50. package/dist/{isArrayLikeObject-f3b27f64.js.map → isArrayLikeObject-0cd02b77.js.map} +1 -1
  51. package/dist/{isArrayLikeObject-a9c7973b.js → isArrayLikeObject-6a001191.js} +2 -2
  52. package/dist/{isArrayLikeObject-a9c7973b.js.map → isArrayLikeObject-6a001191.js.map} +1 -1
  53. package/dist/lib/canvas-controller.es.js +1 -1
  54. package/dist/lib/canvas-controller.js +1 -1
  55. package/dist/lib/canvas.es.js +1 -1
  56. package/dist/lib/canvas.js +1 -1
  57. package/dist/lib/context-menu.es.js +1 -1
  58. package/dist/lib/context-menu.es.js.map +1 -1
  59. package/dist/lib/context-menu.js +1 -1
  60. package/dist/lib/context-menu.js.map +1 -1
  61. package/dist/lib/properties/field-picker.es.js +1 -1
  62. package/dist/lib/properties/field-picker.js +1 -1
  63. package/dist/lib/properties/flexible-table.es.js +1 -1
  64. package/dist/lib/properties/flexible-table.js +1 -1
  65. package/dist/lib/properties.es.js +1 -1
  66. package/dist/lib/properties.js +1 -1
  67. package/dist/styles/common-canvas.min.css +1 -1
  68. package/dist/styles/common-canvas.min.css.map +1 -1
  69. package/dist/toolbar-83b4d3d3.js +2 -0
  70. package/dist/toolbar-83b4d3d3.js.map +1 -0
  71. package/dist/toolbar-d7febd83.js +2 -0
  72. package/dist/toolbar-d7febd83.js.map +1 -0
  73. package/locales/common-canvas/locales/en.json +1 -0
  74. package/locales/common-canvas/locales/eo.json +1 -0
  75. package/package.json +3 -3
  76. package/src/color-picker/color-picker.scss +2 -2
  77. package/src/common-canvas/canvas-controller-menu-utils.js +328 -0
  78. package/src/common-canvas/canvas-controller.js +114 -283
  79. package/src/common-canvas/cc-contents.jsx +9 -1
  80. package/src/common-canvas/cc-context-menu.jsx +9 -6
  81. package/src/common-canvas/cc-context-toolbar.jsx +205 -0
  82. package/src/common-canvas/cc-text-toolbar.jsx +4 -3
  83. package/src/common-canvas/cc-toolbar.jsx +4 -4
  84. package/src/common-canvas/common-canvas-utils.js +0 -5
  85. package/src/common-canvas/common-canvas.scss +34 -4
  86. package/src/common-canvas/constants/canvas-constants.js +9 -1
  87. package/src/common-canvas/svg-canvas-d3.js +4 -0
  88. package/src/common-canvas/svg-canvas-renderer.js +174 -86
  89. package/src/common-canvas/svg-canvas-utils-textarea.js +1 -1
  90. package/src/common-properties/common-properties.jsx +3 -1
  91. package/src/common-properties/components/editor-form/editor-form.jsx +11 -7
  92. package/src/common-properties/components/editor-form/editor-form.scss +27 -4
  93. package/src/common-properties/components/flexible-table/flexible-table.jsx +6 -4
  94. package/src/common-properties/components/title-editor/title-editor.jsx +3 -1
  95. package/src/common-properties/components/title-editor/title-editor.scss +4 -0
  96. package/src/common-properties/components/virtualized-table/virtualized-table.jsx +8 -2
  97. package/src/common-properties/constants/constants.js +5 -0
  98. package/src/common-properties/panels/subtabs/subtabs.jsx +1 -0
  99. package/src/common-properties/panels/tearsheet/tearsheet.scss +1 -0
  100. package/src/common-properties/properties-controller.js +2 -1
  101. package/src/common-properties/properties-main/properties-main.jsx +4 -1
  102. package/src/common-properties/ui-conditions/condition-ops/greaterThan.js +1 -1
  103. package/src/common-properties/ui-conditions/condition-ops/isDateTime.js +1 -1
  104. package/src/common-properties/ui-conditions/condition-ops/isEmpty.js +1 -1
  105. package/src/common-properties/ui-conditions/condition-ops/isNotEmpty.js +1 -1
  106. package/src/common-properties/ui-conditions/condition-ops/lessThan.js +1 -1
  107. package/src/context-menu/common-context-menu.jsx +20 -23
  108. package/src/context-menu/context-menu-wrapper.jsx +13 -11
  109. package/src/object-model/config-utils.js +5 -1
  110. package/src/object-model/layout-dimensions.js +10 -2
  111. package/src/object-model/object-model.js +23 -3
  112. package/src/object-model/redux/canvas-store.js +8 -4
  113. package/src/object-model/redux/reducers/categories.js +12 -0
  114. package/src/object-model/redux/reducers/contextmenu.js +10 -3
  115. package/src/object-model/redux/reducers/palette.js +3 -0
  116. package/src/palette/palette-flyout-content-category.jsx +18 -15
  117. package/src/palette/palette-flyout-content.jsx +0 -15
  118. package/src/toolbar/toolbar-action-item.jsx +80 -10
  119. package/src/toolbar/toolbar-overflow-item.jsx +9 -9
  120. package/src/toolbar/toolbar.jsx +12 -1
  121. package/src/toolbar/toolbar.scss +41 -13
  122. package/stats.html +1 -1
  123. package/dist/_baseForOwn-7d4e8506.js +0 -2
  124. package/dist/_baseForOwn-7d4e8506.js.map +0 -1
  125. package/dist/_baseForOwn-d38b560e.js +0 -2
  126. package/dist/_baseForOwn-d38b560e.js.map +0 -1
  127. package/dist/canvas-constants-046e4126.js +0 -2
  128. package/dist/canvas-constants-046e4126.js.map +0 -1
  129. package/dist/canvas-constants-f4e65d4d.js +0 -2
  130. package/dist/canvas-constants-f4e65d4d.js.map +0 -1
  131. package/dist/canvas-controller-6fe261d9.js +0 -2
  132. package/dist/canvas-controller-6fe261d9.js.map +0 -1
  133. package/dist/canvas-controller-ea7d4a8f.js +0 -2
  134. package/dist/canvas-controller-ea7d4a8f.js.map +0 -1
  135. package/dist/common-canvas-2953ff65.js +0 -2
  136. package/dist/common-canvas-2953ff65.js.map +0 -1
  137. package/dist/common-canvas-fbd62592.js +0 -2
  138. package/dist/common-canvas-fbd62592.js.map +0 -1
  139. package/dist/common-properties-0df4ed36.js +0 -2
  140. package/dist/common-properties-0df4ed36.js.map +0 -1
  141. package/dist/common-properties-8409565f.js +0 -2
  142. package/dist/common-properties-8409565f.js.map +0 -1
  143. package/dist/datarecord-metadata-v3-schema-6a3754ce.js +0 -2
  144. package/dist/datarecord-metadata-v3-schema-ba1f2849.js +0 -2
  145. package/dist/en-7201b548.js +0 -2
  146. package/dist/en-7201b548.js.map +0 -1
  147. package/dist/en-a08356c8.js +0 -2
  148. package/dist/en-a08356c8.js.map +0 -1
  149. package/dist/extends-7d4f15b6.js.map +0 -1
  150. package/dist/extends-d144eab9.js +0 -7
  151. package/dist/extends-d144eab9.js.map +0 -1
  152. package/dist/flexible-table-3a78cdf3.js +0 -2
  153. package/dist/flexible-table-3a78cdf3.js.map +0 -1
  154. package/dist/flexible-table-6e801de4.js +0 -2
  155. package/dist/flexible-table-6e801de4.js.map +0 -1
  156. package/dist/icon-221bb2e5.js +0 -2
  157. package/dist/icon-ea917a08.js +0 -2
  158. package/dist/index-92422c18.js +0 -2
  159. package/dist/index-aee893ad.js +0 -2
  160. package/dist/toolbar-3fdd090b.js +0 -2
  161. package/dist/toolbar-3fdd090b.js.map +0 -1
  162. package/dist/toolbar-5437484a.js +0 -2
  163. package/dist/toolbar-5437484a.js.map +0 -1
@@ -52,7 +52,8 @@ import LabelUtil from "./label-util.js";
52
52
  import Logger from "../logging/canvas-logger.js";
53
53
  import ObjectModel from "../object-model/object-model.js";
54
54
  import SizeAndPositionObjectsAction from "../command-actions/sizeAndPositionObjectsAction.js";
55
- import { get, has, isEmpty } from "lodash";
55
+ import getContextMenuDefiniton from "./canvas-controller-menu-utils.js";
56
+ import { get, isEmpty } from "lodash";
56
57
  import { LINK_SELECTION_NONE, LINK_SELECTION_DETACHABLE, SNAP_TO_GRID_NONE, SUPER_NODE } from "./constants/canvas-constants";
57
58
 
58
59
  // Global instance ID counter
@@ -98,8 +99,6 @@ export default class CanvasController {
98
99
  actionLabelHandler: null
99
100
  };
100
101
 
101
- this.contextMenuSource = null;
102
-
103
102
  this.objectModel = new ObjectModel();
104
103
  this.commandStack = new CommandStack();
105
104
 
@@ -113,6 +112,8 @@ export default class CanvasController {
113
112
  this.contextMenuActionHandler = this.contextMenuActionHandler.bind(this);
114
113
  this.closeContextMenu = this.closeContextMenu.bind(this);
115
114
 
115
+ this.isContextMenuForNonSelectedObj = this.isContextMenuForNonSelectedObj.bind(this);
116
+
116
117
  // Increment the global instance ID by 1 each time a new
117
118
  // canvas controller is created.
118
119
  this.instanceId = commonCanvasControllerInstanceId++;
@@ -478,6 +479,31 @@ export default class CanvasController {
478
479
  return this.objectModel.convertNodeTemplate(nodeTemplate);
479
480
  }
480
481
 
482
+ // Opens the palette category identified by the category ID passed in.
483
+ openPaletteCategory(categoryId) {
484
+ this.objectModel.setIsOpenCategory(categoryId, true);
485
+ }
486
+
487
+ // Closes the palette category idetified by the category ID passed in.
488
+ closePaletteCategory(categoryId) {
489
+ this.objectModel.setIsOpenCategory(categoryId, false);
490
+ }
491
+
492
+ // Opens all the palette categories.
493
+ openAllPaletteCategories() {
494
+ this.objectModel.setIsOpenAllCategories(true);
495
+ }
496
+
497
+ // Closes all the palette categories.
498
+ closeAllPaletteCategories() {
499
+ this.objectModel.setIsOpenAllCategories(false);
500
+ }
501
+
502
+ // Returns true or false to indicate whether a palette category is open or not.
503
+ isPaletteCategoryOpen(categoryId) {
504
+ return this.objectModel.isPaletteCategoryOpen(categoryId);
505
+ }
506
+
481
507
  // ---------------------------------------------------------------------------
482
508
  // Selections methods
483
509
  // ---------------------------------------------------------------------------
@@ -970,6 +996,23 @@ export default class CanvasController {
970
996
  return this.objectModel.getAPIPipeline(pipelineId).isSuperNodeExpandedInPlace(nodeId);
971
997
  }
972
998
 
999
+ // Sets the label, for the node identified, to edit mode, provided the node
1000
+ // label is editable. This allows the user to edite the label text.
1001
+ setNodeLabelEditingMode(nodeId, pipelineId) {
1002
+ if (this.canvasContents) {
1003
+ this.getSVGCanvasD3().setNodeLabelEditingMode(nodeId, pipelineId);
1004
+ }
1005
+ }
1006
+
1007
+ // Sets the decoration label, for the decoration in the node identified, to edit
1008
+ // mode, provided the node label is editable. This allows the user to edit the
1009
+ // label text.
1010
+ setNodeDecorationLabelEditingMode(decId, nodeId, pipelineId) {
1011
+ if (this.canvasContents) {
1012
+ this.getSVGCanvasD3().setNodeDecorationLabelEditingMode(decId, nodeId, pipelineId);
1013
+ }
1014
+ }
1015
+
973
1016
  // ---------------------------------------------------------------------------
974
1017
  // Comments methods
975
1018
  // ---------------------------------------------------------------------------
@@ -1084,6 +1127,14 @@ export default class CanvasController {
1084
1127
  return this.objectModel.isHidingComments();
1085
1128
  }
1086
1129
 
1130
+ // Sets the comment identified, to edit mode so the user can
1131
+ // edit the comment.
1132
+ setCommentEditingMode(commentId, pipelineId) {
1133
+ if (this.canvasContents) {
1134
+ this.getSVGCanvasD3().setCommentEditingMode(commentId, pipelineId);
1135
+ }
1136
+ }
1137
+
1087
1138
  // ---------------------------------------------------------------------------
1088
1139
  // Links methods
1089
1140
  // ---------------------------------------------------------------------------
@@ -1268,6 +1319,15 @@ export default class CanvasController {
1268
1319
  return this.objectModel.getAPIPipeline(pipelineId).getLinkDecorations(linkId);
1269
1320
  }
1270
1321
 
1322
+ // Sets the decoration label, for the decoration in the link identified, to edit
1323
+ // mode provided the link label is editable. This allows the user to edit the
1324
+ // label text.
1325
+ setLinkDecorationLabelEditingMode(decId, linkId, pipelineId) {
1326
+ if (this.canvasContents) {
1327
+ this.getSVGCanvasD3().setLinkDecorationLabelEditingMode(decId, linkId, pipelineId);
1328
+ }
1329
+ }
1330
+
1271
1331
  // ---------------------------------------------------------------------------
1272
1332
  // Command stack methods
1273
1333
  // ---------------------------------------------------------------------------
@@ -1391,6 +1451,10 @@ export default class CanvasController {
1391
1451
  return highlightObjectIds;
1392
1452
  }
1393
1453
 
1454
+ isHighlighted() {
1455
+ return this.highlight;
1456
+ }
1457
+
1394
1458
  // ---------------------------------------------------------------------------
1395
1459
  // Operational methods
1396
1460
  // ---------------------------------------------------------------------------
@@ -1438,8 +1502,8 @@ export default class CanvasController {
1438
1502
  return this.getObjectModel().isPaletteOpen();
1439
1503
  }
1440
1504
 
1441
- openContextMenu(menuDef) {
1442
- this.objectModel.openContextMenu(menuDef);
1505
+ openContextMenu(menuDef, source) {
1506
+ this.objectModel.openContextMenu(menuDef, source);
1443
1507
  }
1444
1508
 
1445
1509
  isBottomPanelOpen() {
@@ -1462,6 +1526,24 @@ export default class CanvasController {
1462
1526
  return this.objectModel.isContextMenuDisplayed();
1463
1527
  }
1464
1528
 
1529
+ getContextMenuSource() {
1530
+ return this.objectModel.getContextMenuSource();
1531
+ }
1532
+
1533
+ closeContextToolbar() {
1534
+ if (!this.mouseInContextToolbar && !this.mouseInObject) {
1535
+ this.objectModel.closeContextMenu();
1536
+ }
1537
+ }
1538
+
1539
+ setMouseInContextToolbar(state) {
1540
+ this.mouseInContextToolbar = state;
1541
+ }
1542
+
1543
+ setMouseInObject(state) {
1544
+ this.mouseInObject = state;
1545
+ }
1546
+
1465
1547
  openNotificationPanel() {
1466
1548
  this.objectModel.openNotificationPanel();
1467
1549
  }
@@ -1561,32 +1643,6 @@ export default class CanvasController {
1561
1643
  }
1562
1644
  }
1563
1645
 
1564
- // Sets the label for the node identified to edit mode so the user can start
1565
- // editing the label, provided the node label is editable.
1566
- setNodeLabelEditingMode(nodeId, pipelineId) {
1567
- if (this.canvasContents) {
1568
- this.getSVGCanvasD3().setNodeLabelEditingMode(nodeId, pipelineId);
1569
- }
1570
- }
1571
-
1572
- // Sets the decoration label for the decoration in the node identified to edit
1573
- // mode so the user can start editing the label, provided the node label is
1574
- // editable.
1575
- setNodeDecorationLabelEditingMode(decId, nodeId, pipelineId) {
1576
- if (this.canvasContents) {
1577
- this.getSVGCanvasD3().setNodeDecorationLabelEditingMode(decId, nodeId, pipelineId);
1578
- }
1579
- }
1580
-
1581
- // Sets the decoration label for the decoration in the link identified to edit
1582
- // mode so the user can start editing the label, provided the link label is
1583
- // editable.
1584
- setLinkDecorationLabelEditingMode(decId, linkId, pipelineId) {
1585
- if (this.canvasContents) {
1586
- this.getSVGCanvasD3().setLinkDecorationLabelEditingMode(decId, linkId, pipelineId);
1587
- }
1588
- }
1589
-
1590
1646
  // Changes the zoom amounts for the canvas. This method does not alter the
1591
1647
  // pipelineFlow document. zoomObject is an object with three fields:
1592
1648
  // x: Is the horizontal translate amount which is a number indicating the
@@ -1845,9 +1901,10 @@ export default class CanvasController {
1845
1901
  isTipEnabled(tipType) {
1846
1902
  const canvasConfig = this.getCanvasConfig();
1847
1903
  switch (tipType) {
1848
- case constants.TIP_TYPE_PALETTE_ITEM:
1849
1904
  case constants.TIP_TYPE_PALETTE_CATEGORY:
1850
- return canvasConfig.tipConfig.palette;
1905
+ return canvasConfig.tipConfig.palette === true || get(canvasConfig, "tipConfig.palette.categories", false);
1906
+ case constants.TIP_TYPE_PALETTE_ITEM:
1907
+ return canvasConfig.tipConfig.palette === true || get(canvasConfig, "tipConfig.palette.nodeTemplates", false);
1851
1908
  case constants.TIP_TYPE_NODE:
1852
1909
  return canvasConfig.tipConfig.nodes;
1853
1910
  case constants.TIP_TYPE_PORT:
@@ -2006,269 +2063,39 @@ export default class CanvasController {
2006
2063
  return false;
2007
2064
  }
2008
2065
 
2009
- createEditMenu(source, includePaste) {
2010
- const editSubMenu = [
2011
- { action: "cut", label: this.labelUtil.getLabel("edit.cutSelection"), enable: source.selectedObjectIds.length > 0 },
2012
- { action: "copy", label: this.labelUtil.getLabel("edit.copySelection"), enable: source.selectedObjectIds.length > 0 }
2013
- ];
2014
- if (includePaste) {
2015
- editSubMenu.push({ action: "paste", label: this.labelUtil.getLabel("edit.pasteSelection"), enable: !this.isClipboardEmpty() });
2016
- }
2017
- return editSubMenu;
2018
- }
2019
-
2020
- createHighlightMenu(source) {
2021
- const highlightSubMenu = [
2022
- { action: "highlightBranch", label: this.labelUtil.getLabel("menu.highlightBranch") },
2023
- { action: "highlightUpstream", label: this.labelUtil.getLabel("menu.highlightUpstream") },
2024
- { action: "highlightDownstream", label: this.labelUtil.getLabel("menu.highlightDownstream") }
2025
- ];
2026
- return highlightSubMenu;
2027
- }
2028
-
2029
- // This should only appear in menu if highlight is true.
2030
- createUnhighlightMenu(source) {
2031
- const unhighlightSubMenu = [
2032
- { action: "unhighlight", label: this.labelUtil.getLabel("menu.unhighlight"), enable: this.highlight }
2033
- ];
2034
- return unhighlightSubMenu;
2035
- }
2036
-
2037
- createDefaultMenu(source) {
2038
- let menuDefinition = [];
2039
- // Select all & add comment: canvas only
2040
- if (source.type === "canvas") {
2041
- menuDefinition = menuDefinition.concat([{ action: "createComment", label: this.labelUtil.getLabel("canvas.addComment") },
2042
- { action: "selectAll", label: this.labelUtil.getLabel("canvas.selectAll") },
2043
- { divider: true }]);
2044
- }
2045
- // Rename node
2046
- if (source.type === "node" && get(source, "targetObject.layout.labelEditable", false)) {
2047
- menuDefinition = menuDefinition.concat({ action: "setNodeLabelEditingMode", label: this.labelUtil.getLabel("node.renameNode") });
2048
- }
2049
- // Disconnect node
2050
- if (source.type === "node" || source.type === "comment") {
2051
- const linksFound = this.objectModel.getAPIPipeline(source.pipelineId).getLinksContainingIds(source.selectedObjectIds);
2052
- if (linksFound.length > 0) {
2053
- menuDefinition = menuDefinition.concat({ action: "disconnectNode", label: this.labelUtil.getLabel("node.disconnectNode") });
2054
- menuDefinition = menuDefinition.concat({ divider: true });
2066
+ // Returns true if the context toolbar is switched on and the node over which
2067
+ // the mouse cursor is hovering is NOT in the list of selected objects.
2068
+ isContextMenuForNonSelectedObj(source) {
2069
+ if (this.getCanvasConfig().enableContextToolbar) {
2070
+ if (source.targetObject) {
2071
+ return !source.selectedObjectIds.includes(source.targetObject.id);
2055
2072
  }
2056
2073
  }
2057
- // Color objects
2058
- if (source.type === "comment" &&
2059
- get(this, "contextMenuConfig.defaultMenuEntries.colorBackground", true)) {
2060
- menuDefinition = menuDefinition.concat({ submenu: true, menu: "colorPicker", label: this.labelUtil.getLabel("comment.colorBackground") });
2061
- menuDefinition = menuDefinition.concat({ divider: true });
2062
- }
2063
- // Edit submenu (cut, copy, paste)
2064
- if (source.type === "node" ||
2065
- source.type === "comment" ||
2066
- (source.type === "link" && this.areDetachableLinksInUse()) ||
2067
- source.type === "canvas") {
2068
- const editSubMenu = this.createEditMenu(source, source.type === "canvas");
2069
- menuDefinition = menuDefinition.concat({ submenu: true, menu: editSubMenu, label: this.labelUtil.getLabel("node.editMenu") });
2070
- menuDefinition = menuDefinition.concat({ divider: true });
2071
- }
2072
- // Undo and redo
2073
- if (source.type === "canvas") {
2074
- menuDefinition = menuDefinition.concat([{ action: "undo", label: this.labelUtil.getLabel("canvas.undo"), enable: this.canUndo() },
2075
- { action: "redo", label: this.labelUtil.getLabel("canvas.redo"), enable: this.canRedo() },
2076
- { divider: true }]);
2077
- }
2078
- // Delete objects
2079
- if (source.type === "node" || source.type === "comment" ||
2080
- (this.getCanvasConfig().enableLinkSelection !== LINK_SELECTION_NONE && source.type === "link")) {
2081
- menuDefinition = menuDefinition.concat([{ action: "deleteSelectedObjects", label: this.labelUtil.getLabel("canvas.deleteObject") },
2082
- { divider: true }]);
2083
- }
2084
- // Create supernode
2085
- if (source.type === "node" || source.type === "comment") {
2086
- if (this.isCreateSupernodeCMOptionRequired() &&
2087
- ((has(this, "contextMenuConfig.enableCreateSupernodeNonContiguous") &&
2088
- this.contextMenuConfig.enableCreateSupernodeNonContiguous) ||
2089
- this.areSelectedNodesContiguous())) {
2090
- menuDefinition = menuDefinition.concat([{ action: "createSuperNode", label: this.labelUtil.getLabel("node.createSupernode") }]);
2091
- if (this.getCanvasConfig().enableExternalPipelineFlows) {
2092
- menuDefinition = menuDefinition.concat([{ action: "createSuperNodeExternal", label: this.labelUtil.getLabel("node.createSupernodeExternal") }]);
2093
- }
2094
- menuDefinition = menuDefinition.concat([{ divider: true }]);
2095
- }
2096
- }
2097
- // Supernode options - only applicable with a single supernode selected
2098
- // which is opened by the "canvas" (default) editor.
2099
- if (source.type === "node" && source.selectedObjectIds.length === 1 && source.targetObject.type === SUPER_NODE &&
2100
- (source.targetObject.open_with_tool === "canvas" || typeof source.targetObject.open_with_tool === "undefined")) {
2101
- // Deconstruct supernode
2102
- menuDefinition = menuDefinition.concat({ action: "deconstructSuperNode",
2103
- label: this.labelUtil.getLabel("node.deconstructSupernode") });
2104
-
2105
- menuDefinition = menuDefinition.concat({ divider: true });
2106
-
2107
- // Collapse supernode
2108
- if (this.isSuperNodeExpandedInPlace(source.targetObject.id, source.pipelineId)) {
2109
- menuDefinition = menuDefinition.concat({ action: "collapseSuperNodeInPlace",
2110
- label: this.labelUtil.getLabel("node.collapseSupernodeInPlace") });
2111
- // Expand supernode
2112
- } else {
2113
- menuDefinition = menuDefinition.concat({ action: "expandSuperNodeInPlace",
2114
- label: this.labelUtil.getLabel("node.expandSupernode") });
2115
- }
2116
-
2117
- // Expand supernode to full page display
2118
- if (get(this, "contextMenuConfig.defaultMenuEntries.displaySupernodeFullPage")) {
2119
- menuDefinition = menuDefinition.concat({ action: "displaySubPipeline",
2120
- label: this.labelUtil.getLabel("node.displaySupernodeFullPage") });
2121
- }
2122
-
2123
- menuDefinition = menuDefinition.concat({ divider: true });
2124
-
2125
- // Convert supernode
2126
- if (this.getCanvasConfig().enableExternalPipelineFlows) {
2127
- // Convert External to Local
2128
- if (source.targetObject.subflow_ref.url) {
2129
- // Supernodes inside an external sub-flow cannot be made local.
2130
- if (!this.isPipelineExternal(source.pipelineId)) {
2131
- menuDefinition = menuDefinition.concat({ action: "convertSuperNodeExternalToLocal",
2132
- label: this.labelUtil.getLabel("node.convertSupernodeExternalToLocal") }, { divider: true });
2133
- }
2134
- // Convert Local to External
2135
- } else {
2136
- menuDefinition = menuDefinition.concat({ action: "convertSuperNodeLocalToExternal",
2137
- label: this.labelUtil.getLabel("node.convertSupernodeLocalToExternal") }, { divider: true });
2138
- }
2139
- }
2140
- }
2141
-
2142
- // Delete link
2143
- if (this.getCanvasConfig().enableLinkSelection === LINK_SELECTION_NONE &&
2144
- source.type === "link") {
2145
- menuDefinition = menuDefinition.concat([{ action: "deleteLink", label: this.labelUtil.getLabel("canvas.deleteObject") }]);
2146
- }
2147
- // Highlight submenu (Highlight Branch | Upstream | Downstream, Unhighlight)
2148
- if (source.type === "node") {
2149
- let highlightSubMenuDef = this.createHighlightMenu(source);
2150
- highlightSubMenuDef.push({ divider: true });
2151
- highlightSubMenuDef = highlightSubMenuDef.concat(this.createUnhighlightMenu(source));
2152
- menuDefinition = menuDefinition.concat({ submenu: true, menu: highlightSubMenuDef, label: this.labelUtil.getLabel("menu.highlight") });
2153
- }
2154
- if (source.type === "canvas") {
2155
- menuDefinition = menuDefinition.concat({ action: "unhighlight", label: this.labelUtil.getLabel("menu.unhighlight"), enable: this.highlight });
2156
- }
2157
- if (source.type === "node" &&
2158
- has(this, "contextMenuConfig.defaultMenuEntries.saveToPalette") &&
2159
- this.contextMenuConfig.defaultMenuEntries.saveToPalette) {
2160
- menuDefinition = menuDefinition.concat({ divider: true },
2161
- { action: "saveToPalette", label: this.labelUtil.getLabel("node.saveToPalette") });
2162
- }
2163
-
2164
- return menuDefinition;
2165
- }
2166
-
2167
- // Returns a new menu based, on the menu passed in, where all actions that
2168
- // might alter the canvas have been removed.
2169
- filterOutEditingActions(menuDefinition) {
2170
- const newMenuDefinition = [];
2171
- menuDefinition.forEach((menuEntry) => {
2172
- if (menuEntry.submenu) {
2173
- const newSubMenu = this.filterOutEditingActions(menuEntry.menu);
2174
- if (newSubMenu && newSubMenu.length > 0) {
2175
- menuEntry.menu = newSubMenu;
2176
- newMenuDefinition.push(menuEntry);
2177
- }
2178
-
2179
- } else if (!this.isEditingAction(menuEntry.action)) {
2180
- newMenuDefinition.push(menuEntry);
2181
- }
2182
- });
2183
- return newMenuDefinition;
2184
- }
2185
-
2186
- // Returns true if the action string passed in is one of the actions
2187
- // that would alter the canvas objects. This is useful for filtering
2188
- // out editing actions that should be unavailable with a read-only canvas.
2189
- isEditingAction(action) {
2190
- return (
2191
- action === "createComment" ||
2192
- action === "disconnectNode" ||
2193
- action === "setNodeLabelEditingMode" ||
2194
- action === "cut" ||
2195
- action === "copy" ||
2196
- action === "paste" ||
2197
- action === "undo" ||
2198
- action === "redo" ||
2199
- action === "deleteSelectedObjects" ||
2200
- action === "createSuperNode" ||
2201
- action === "createSuperNodeExternal" ||
2202
- action === "deconstructSuperNode" ||
2203
- action === "collapseSuperNodeInPlace" ||
2204
- action === "expandSuperNodeInPlace" ||
2205
- action === "convertSuperNodeExternalToLocal" ||
2206
- action === "convertSuperNodeLocalToExternal" ||
2207
- action === "deleteLink" ||
2208
- action === "saveToPalette"
2209
- );
2210
- }
2211
-
2212
- // Returns whether the 'Create Supernode' context menu option is required or
2213
- // not. The default is true.
2214
- isCreateSupernodeCMOptionRequired() {
2215
- let required = true;
2216
- if (has(this, "contextMenuConfig.defaultMenuEntries.createSupernode") &&
2217
- this.contextMenuConfig.defaultMenuEntries.createSupernode === false) {
2218
- required = false;
2219
- }
2220
-
2221
- return required;
2074
+ return false;
2222
2075
  }
2223
2076
 
2224
2077
  contextMenuHandler(source) {
2225
- this.contextMenuSource = source;
2226
- const defMenu = this.createDefaultMenu(source);
2227
- let menuDefinition;
2228
-
2229
- if (typeof this.handlers.contextMenuHandler === "function") {
2230
- const menuCustom = this.handlers.contextMenuHandler(source, defMenu);
2231
- if (menuCustom && menuCustom.length > 0) {
2232
- menuDefinition = menuCustom;
2233
- }
2234
- } else {
2235
- menuDefinition = defMenu;
2236
- }
2078
+ const menuDefinition = getContextMenuDefiniton(source, this);
2237
2079
 
2238
- // If we are NOT allowing editing actions (perhaps because we are showing a
2239
- // read-only canvas), remove any actions from the context menu that might
2240
- // alter the canvas objects.
2241
- if (menuDefinition && menuDefinition.length > 0 &&
2242
- this.getCanvasConfig().enableEditingActions === false) {
2243
- menuDefinition = this.filterOutEditingActions(menuDefinition);
2080
+ // Open the context menu if we still have one!
2081
+ if (menuDefinition && menuDefinition.length > 0) {
2082
+ this.openContextMenu(menuDefinition, source);
2244
2083
  }
2245
-
2246
- if (menuDefinition && menuDefinition.length > 0 &&
2247
- !this.allDividers(menuDefinition)) {
2248
- this.openContextMenu(menuDefinition);
2249
- }
2250
- }
2251
-
2252
- // Returns true if the menu only contains dividers. This might happen if
2253
- // action items have been removed from a menu and left only dividers behind.
2254
- allDividers(menu) {
2255
- const dividers = menu.filter((m) => m.divider);
2256
- return menu.length === dividers.length;
2257
- }
2258
-
2259
- getContextMenuPos() {
2260
- if (this.contextMenuSource) {
2261
- return this.contextMenuSource.cmPos;
2262
- }
2263
- return { x: 0, y: 0 };
2264
2084
  }
2265
2085
 
2266
2086
  contextMenuActionHandler(action, editParam) {
2087
+ const source = this.getContextMenuSource();
2088
+
2267
2089
  this.logger.log("contextMenuActionHandler - action: " + action);
2268
- this.logger.log(this.contextMenuSource);
2090
+ this.logger.log(source);
2091
+
2269
2092
  this.closeContextMenu();
2093
+ if (this.getCanvasConfig().enableContextToolbar &&
2094
+ this.isContextMenuForNonSelectedObj(source)) {
2095
+ this.setSelections([source.targetObject.id]);
2096
+ }
2270
2097
  this.canvasContents.focusOnCanvas(); // Set focus on canvas so keybord events go there.
2271
- const data = Object.assign({}, this.contextMenuSource, { "editType": action, "editParam": editParam, "editSource": "contextmenu" });
2098
+ const data = Object.assign({}, source, { "editType": action, "editParam": editParam, "editSource": "contextmenu" });
2272
2099
  this.editActionHandler(data);
2273
2100
  }
2274
2101
 
@@ -2397,6 +2224,10 @@ export default class CanvasController {
2397
2224
  this.showComments();
2398
2225
  break;
2399
2226
  }
2227
+ case "setCommentEditingMode": {
2228
+ this.setCommentEditingMode(data.id, data.pipelineId);
2229
+ break;
2230
+ }
2400
2231
  case "setNodeLabelEditingMode": {
2401
2232
  this.setNodeLabelEditingMode(data.id, data.pipelineId);
2402
2233
  break;
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright 2017-2022 Elyra Authors
2
+ * Copyright 2017-2023 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.
@@ -23,6 +23,7 @@ import { connect } from "react-redux";
23
23
  import { injectIntl } from "react-intl";
24
24
  import defaultMessages from "../../locales/common-canvas/locales/en.json";
25
25
  import CommonCanvasContextMenu from "./cc-context-menu.jsx";
26
+ import CommonCanvasContextToolbar from "./cc-context-toolbar.jsx";
26
27
  import CommonCanvasTextToolbar from "./cc-text-toolbar.jsx";
27
28
  import CommonCanvasStateTag from "./cc-state-tag.jsx";
28
29
  import CanvasUtils from "./common-canvas-utils.js";
@@ -333,6 +334,13 @@ class CanvasContents extends React.Component {
333
334
  }
334
335
 
335
336
  getContextMenu() {
337
+ if (this.props.canvasConfig.enableContextToolbar) {
338
+ return (
339
+ <CommonCanvasContextToolbar
340
+ canvasController={this.props.canvasController}
341
+ containingDivId={this.mainCanvasDivId}
342
+ />);
343
+ }
336
344
  return (
337
345
  <CommonCanvasContextMenu
338
346
  canvasController={this.props.canvasController}
@@ -17,27 +17,26 @@
17
17
  import React from "react";
18
18
  import PropTypes from "prop-types";
19
19
  import { connect } from "react-redux";
20
- import { isEmpty } from "lodash";
21
20
  import ContextMenuWrapper from "../context-menu/context-menu-wrapper.jsx";
22
21
  import Logger from "../logging/canvas-logger.js";
23
22
 
24
23
  class CommonCanvasContextMenu extends React.Component {
25
24
  constructor(props) {
26
25
  super(props);
27
- this.logger = new Logger("CC-ContextMenu");
26
+ this.logger = new Logger("CC-Context-Menu");
28
27
  }
29
28
 
30
29
  render() {
31
30
  this.logger.log("render");
32
31
 
33
32
  let contextMenu = null;
34
- if (!isEmpty(this.props.contextMenuDef)) {
33
+ if (this.props.showContextMenu) {
35
34
  contextMenu = (
36
35
  <ContextMenuWrapper
37
36
  containingDivId={this.props.containingDivId}
38
37
  contextMenuDef={this.props.contextMenuDef}
39
38
  contextMenuActionHandler={this.props.canvasController.contextMenuActionHandler}
40
- contextMenuPos={this.props.canvasController.getContextMenuPos()}
39
+ contextMenuPos={this.props.contextMenuPos}
41
40
  closeContextMenu={this.props.canvasController.closeContextMenu}
42
41
  stopPropagation
43
42
  />
@@ -53,11 +52,15 @@ CommonCanvasContextMenu.propTypes = {
53
52
  containingDivId: PropTypes.string.isRequired,
54
53
 
55
54
  // Provided by redux
56
- contextMenuDef: PropTypes.array.isRequired
55
+ contextMenuDef: PropTypes.array.isRequired,
56
+ contextMenuPos: PropTypes.object.isRequired,
57
+ showContextMenu: PropTypes.bool.isRequired
57
58
  };
58
59
 
59
60
  const mapStateToProps = (state, ownProps) => ({
60
- contextMenuDef: state.contextmenu.menuDef
61
+ contextMenuDef: state.contextmenu.menuDef,
62
+ contextMenuPos: state.contextmenu.source.cmPos || { x: 0, y: 0 },
63
+ showContextMenu: state.contextmenu.isOpen
61
64
  });
62
65
 
63
66
  export default connect(mapStateToProps)(CommonCanvasContextMenu);