@elyra/canvas 12.27.1 → 12.28.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 (181) hide show
  1. package/dist/{canvas-constants-07dbe4b7.js → canvas-constants-046e4126.js} +2 -2
  2. package/dist/{canvas-constants-07dbe4b7.js.map → canvas-constants-046e4126.js.map} +1 -1
  3. package/dist/canvas-constants-f4e65d4d.js +2 -0
  4. package/dist/canvas-constants-f4e65d4d.js.map +1 -0
  5. package/dist/{canvas-controller-01c28c3a.js → canvas-controller-1bbd9c0e.js} +2 -2
  6. package/dist/canvas-controller-1bbd9c0e.js.map +1 -0
  7. package/dist/canvas-controller-d6aa7d4d.js +2 -0
  8. package/dist/canvas-controller-d6aa7d4d.js.map +1 -0
  9. package/dist/common-canvas-9c735f47.js +2 -0
  10. package/dist/common-canvas-9c735f47.js.map +1 -0
  11. package/dist/common-canvas-a02e75c1.js +2 -0
  12. package/dist/common-canvas-a02e75c1.js.map +1 -0
  13. package/dist/common-canvas.es.js +1 -1
  14. package/dist/common-canvas.js +1 -1
  15. package/dist/common-properties-3b9f3106.js +2 -0
  16. package/dist/common-properties-3b9f3106.js.map +1 -0
  17. package/dist/common-properties-86b9b936.js +2 -0
  18. package/dist/common-properties-86b9b936.js.map +1 -0
  19. package/dist/datarecord-metadata-v3-schema-6a3754ce.js +1 -1
  20. package/dist/datarecord-metadata-v3-schema-6a3754ce.js.map +1 -1
  21. package/dist/datarecord-metadata-v3-schema-ba1f2849.js +1 -1
  22. package/dist/datarecord-metadata-v3-schema-ba1f2849.js.map +1 -1
  23. package/dist/en-7201b548.js +1 -1
  24. package/dist/en-7201b548.js.map +1 -1
  25. package/dist/en-a08356c8.js +1 -1
  26. package/dist/en-a08356c8.js.map +1 -1
  27. package/dist/{extends-de3127ea.js → extends-7d4f15b6.js} +2 -2
  28. package/dist/extends-7d4f15b6.js.map +1 -0
  29. package/dist/extends-d144eab9.js +7 -0
  30. package/dist/extends-d144eab9.js.map +1 -0
  31. package/dist/flexible-table-8219d7a0.js +2 -0
  32. package/dist/flexible-table-8219d7a0.js.map +1 -0
  33. package/dist/flexible-table-f5d55fe4.js +2 -0
  34. package/dist/flexible-table-f5d55fe4.js.map +1 -0
  35. package/dist/{icon-63afae46.js → icon-221bb2e5.js} +2 -2
  36. package/dist/{icon-63afae46.js.map → icon-221bb2e5.js.map} +1 -1
  37. package/dist/icon-ea917a08.js +2 -0
  38. package/dist/{icon-94bf4b86.js.map → icon-ea917a08.js.map} +1 -1
  39. package/dist/index-17b33a9b.js +2 -0
  40. package/dist/index-17b33a9b.js.map +1 -0
  41. package/dist/index-ac265f1e.js +2 -0
  42. package/dist/index-ac265f1e.js.map +1 -0
  43. package/dist/isArrayLikeObject-a9c7973b.js +1 -1
  44. package/dist/isArrayLikeObject-a9c7973b.js.map +1 -1
  45. package/dist/isArrayLikeObject-f3b27f64.js +1 -1
  46. package/dist/isArrayLikeObject-f3b27f64.js.map +1 -1
  47. package/dist/lib/canvas-controller.es.js +1 -1
  48. package/dist/lib/canvas-controller.js +1 -1
  49. package/dist/lib/canvas.es.js +1 -1
  50. package/dist/lib/canvas.js +1 -1
  51. package/dist/lib/context-menu.es.js +1 -1
  52. package/dist/lib/context-menu.js +1 -1
  53. package/dist/lib/properties/field-picker.es.js +1 -1
  54. package/dist/lib/properties/field-picker.js +1 -1
  55. package/dist/lib/properties/flexible-table.es.js +1 -1
  56. package/dist/lib/properties/flexible-table.js +1 -1
  57. package/dist/lib/properties.es.js +1 -1
  58. package/dist/lib/properties.js +1 -1
  59. package/dist/lib/tooltip.es.js +1 -1
  60. package/dist/lib/tooltip.es.js.map +1 -1
  61. package/dist/lib/tooltip.js +1 -1
  62. package/dist/lib/tooltip.js.map +1 -1
  63. package/dist/styles/common-canvas.min.css +1 -1
  64. package/dist/styles/common-canvas.min.css.map +1 -1
  65. package/dist/toolbar-2bbc9542.js +2 -0
  66. package/dist/toolbar-2bbc9542.js.map +1 -0
  67. package/dist/toolbar-c173e22a.js +2 -0
  68. package/dist/toolbar-c173e22a.js.map +1 -0
  69. package/locales/common-properties/locales/de.json +2 -1
  70. package/locales/common-properties/locales/en.json +2 -0
  71. package/locales/common-properties/locales/eo.json +2 -0
  72. package/locales/common-properties/locales/es.json +3 -2
  73. package/locales/common-properties/locales/fr.json +2 -1
  74. package/locales/common-properties/locales/it.json +2 -1
  75. package/locales/common-properties/locales/ja.json +2 -1
  76. package/locales/common-properties/locales/ko.json +2 -1
  77. package/locales/common-properties/locales/pt-br.json +2 -1
  78. package/locales/common-properties/locales/sv.json +2 -1
  79. package/locales/common-properties/locales/zh-CN.json +5 -4
  80. package/locales/common-properties/locales/zh-TW.json +2 -1
  81. package/locales/notification-panel/locales/de.json +3 -0
  82. package/locales/notification-panel/locales/es.json +3 -0
  83. package/locales/notification-panel/locales/fr.json +3 -0
  84. package/locales/notification-panel/locales/it.json +3 -0
  85. package/locales/notification-panel/locales/ja.json +3 -0
  86. package/locales/notification-panel/locales/ko.json +3 -0
  87. package/locales/notification-panel/locales/pt-BR.json +3 -0
  88. package/locales/notification-panel/locales/sv.json +3 -0
  89. package/locales/notification-panel/locales/zh-CN.json +3 -0
  90. package/locales/notification-panel/locales/zh-TW.json +3 -0
  91. package/package.json +1 -1
  92. package/src/common-canvas/canvas-controller.js +31 -0
  93. package/src/common-canvas/cc-toolbar.jsx +5 -5
  94. package/src/common-canvas/constants/canvas-constants.js +2 -0
  95. package/src/common-canvas/svg-canvas-renderer.js +29 -14
  96. package/src/common-properties/actions/button/button.jsx +1 -3
  97. package/src/common-properties/actions/image/image.jsx +1 -3
  98. package/src/common-properties/common-properties.jsx +8 -5
  99. package/src/common-properties/components/control-item/control-item.jsx +1 -3
  100. package/src/common-properties/components/control-item/control-item.scss +2 -0
  101. package/src/common-properties/components/field-picker/field-picker.jsx +1 -3
  102. package/src/common-properties/components/truncated-content-tooltip/truncated-content-tooltip.jsx +11 -3
  103. package/src/common-properties/components/truncated-content-tooltip/truncated-content-tooltip.scss +1 -1
  104. package/src/common-properties/components/validation-message/validation-message.jsx +1 -2
  105. package/src/common-properties/components/virtualized-table/virtualized-table.jsx +18 -31
  106. package/src/common-properties/constants/constants.js +12 -1
  107. package/src/common-properties/constants/form-constants.js +2 -0
  108. package/src/common-properties/controls/abstract-table.jsx +7 -4
  109. package/src/common-properties/controls/checkbox/checkbox.jsx +1 -2
  110. package/src/common-properties/controls/checkboxset/checkboxset.jsx +1 -1
  111. package/src/common-properties/controls/control-factory.js +10 -0
  112. package/src/common-properties/controls/controls.scss +3 -1
  113. package/src/common-properties/controls/datepicker/datepicker.jsx +118 -0
  114. package/src/common-properties/controls/datepicker/datepicker.scss +23 -0
  115. package/src/common-properties/controls/datepicker/index.js +18 -0
  116. package/src/common-properties/controls/datepicker-range/datepicker-range.jsx +194 -0
  117. package/src/common-properties/controls/datepicker-range/datepicker-range.scss +21 -0
  118. package/src/common-properties/controls/datepicker-range/index.js +18 -0
  119. package/src/common-properties/controls/dropdown/dropdown.jsx +2 -1
  120. package/src/common-properties/controls/expression/expression-builder/expression-select-field-function.jsx +3 -2
  121. package/src/common-properties/controls/expression/expression-builder/expression-select-operator.jsx +1 -3
  122. package/src/common-properties/controls/radioset/radioset.jsx +1 -1
  123. package/src/common-properties/controls/readonly/readonly.jsx +7 -0
  124. package/src/common-properties/controls/textarea/textarea.jsx +3 -2
  125. package/src/common-properties/controls/textfield/textfield.jsx +15 -17
  126. package/src/common-properties/controls/textfield/textfield.scss +1 -0
  127. package/src/common-properties/form/EditorForm.js +5 -1
  128. package/src/common-properties/form/Form.js +2 -8
  129. package/src/common-properties/panels/sub-panel/cell.jsx +1 -2
  130. package/src/common-properties/panels/summary/summary.jsx +12 -12
  131. package/src/common-properties/panels/summary/summary.scss +4 -10
  132. package/src/common-properties/properties-controller.js +15 -6
  133. package/src/common-properties/properties-main/properties-main.jsx +11 -3
  134. package/src/common-properties/ui-conditions/condition-ops/contains.js +1 -1
  135. package/src/common-properties/ui-conditions/condition-ops/greaterThan.js +22 -1
  136. package/src/common-properties/ui-conditions/condition-ops/isDateTime.js +9 -6
  137. package/src/common-properties/ui-conditions/condition-ops/isEmpty.js +7 -1
  138. package/src/common-properties/ui-conditions/condition-ops/isNotEmpty.js +5 -1
  139. package/src/common-properties/ui-conditions/condition-ops/lessThan.js +22 -1
  140. package/src/common-properties/ui-conditions/condition-ops/notContains.js +1 -1
  141. package/src/common-properties/ui-conditions/conditions-utils.js +5 -5
  142. package/src/common-properties/util/control-utils.js +18 -3
  143. package/src/common-properties/util/date-utils.js +152 -0
  144. package/src/common-properties/util/property-utils.js +29 -12
  145. package/src/object-model/api-pipeline.js +1 -0
  146. package/src/object-model/object-model.js +12 -0
  147. package/src/object-model/redux/reducers/canvasinfo.js +8 -0
  148. package/src/themes/light.scss +16 -0
  149. package/src/toolbar/toolbar-action-item.jsx +9 -7
  150. package/src/tooltip/tooltip.jsx +28 -15
  151. package/src/tooltip/tooltip.scss +7 -7
  152. package/stats.html +1 -1
  153. package/dist/canvas-constants-ba465147.js +0 -2
  154. package/dist/canvas-constants-ba465147.js.map +0 -1
  155. package/dist/canvas-controller-01c28c3a.js.map +0 -1
  156. package/dist/canvas-controller-fc5bee30.js +0 -2
  157. package/dist/canvas-controller-fc5bee30.js.map +0 -1
  158. package/dist/common-canvas-4f99983f.js +0 -2
  159. package/dist/common-canvas-4f99983f.js.map +0 -1
  160. package/dist/common-canvas-e1879d85.js +0 -2
  161. package/dist/common-canvas-e1879d85.js.map +0 -1
  162. package/dist/common-properties-9a5037f4.js +0 -2
  163. package/dist/common-properties-9a5037f4.js.map +0 -1
  164. package/dist/common-properties-cae41b08.js +0 -2
  165. package/dist/common-properties-cae41b08.js.map +0 -1
  166. package/dist/extends-86f8d713.js +0 -7
  167. package/dist/extends-86f8d713.js.map +0 -1
  168. package/dist/extends-de3127ea.js.map +0 -1
  169. package/dist/flexible-table-d68c24c6.js +0 -2
  170. package/dist/flexible-table-d68c24c6.js.map +0 -1
  171. package/dist/flexible-table-f14863ac.js +0 -2
  172. package/dist/flexible-table-f14863ac.js.map +0 -1
  173. package/dist/icon-94bf4b86.js +0 -2
  174. package/dist/index-5c0ad9bb.js +0 -2
  175. package/dist/index-5c0ad9bb.js.map +0 -1
  176. package/dist/index-fc1b32b4.js +0 -2
  177. package/dist/index-fc1b32b4.js.map +0 -1
  178. package/dist/toolbar-393d299e.js +0 -2
  179. package/dist/toolbar-393d299e.js.map +0 -1
  180. package/dist/toolbar-91001066.js +0 -2
  181. package/dist/toolbar-91001066.js.map +0 -1
@@ -0,0 +1,152 @@
1
+ /*
2
+ * Copyright 2023 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
+ // Don't use 'd' in regex to avoid problems with replacing date token 'd'
18
+ const FLATPICKR_DATE_TOKENS_REGEX = {
19
+ Y: "([1-9][0-9][0-9][0-9])", // 4 digit year
20
+ y: "([0-9][0-9])", // 2 digit year
21
+ m: "([0][1-9]|[1][0-2])", // 2 digit month
22
+ n: "([1-9]|[1-2][0-2])", // month without leading 0
23
+ d: "([0][1-9]|[1-2][0-9]|3[01])", // 2 digit day
24
+ j: "([1-9]|[1-2][0-9]|3[01])" // day without leading 0
25
+ };
26
+
27
+ function getDateFormatRegex(dateFormat) {
28
+ let dateRegex = dateFormat;
29
+ dateRegex = dateRegex.replace("Y", FLATPICKR_DATE_TOKENS_REGEX.Y);
30
+ dateRegex = dateRegex.replace("y", FLATPICKR_DATE_TOKENS_REGEX.y);
31
+ dateRegex = dateRegex.replace("m", FLATPICKR_DATE_TOKENS_REGEX.m);
32
+ dateRegex = dateRegex.replace("n", FLATPICKR_DATE_TOKENS_REGEX.n);
33
+ dateRegex = dateRegex.replace("d", FLATPICKR_DATE_TOKENS_REGEX.d);
34
+ dateRegex = dateRegex.replace("j", FLATPICKR_DATE_TOKENS_REGEX.j);
35
+ dateRegex = dateRegex.replaceAll(".", "[.]"); // escape decimals
36
+ dateRegex = "^" + dateRegex + "$";
37
+ return dateRegex;
38
+ }
39
+
40
+ // 'datepicker' and 'datepickerRange' uses flatpickr internally through Carbon
41
+ // dateFormat tokens: https://flatpickr.js.org/formatting/#date-formatting-tokens
42
+ // Gets the formatted date to display in the control
43
+ function getFormattedDate(inDate, dateFormat) {
44
+ const date = new Date(inDate);
45
+ if (!isNaN(date)) {
46
+ const year = date.getFullYear().toString();
47
+ let month = (date.getMonth() + 1).toString(); // month is 0 indexed
48
+ if (month.length === 1) {
49
+ month = "0" + month;
50
+ }
51
+ let day = date.getDate().toString();
52
+ if (day.length === 1) {
53
+ day = "0" + day;
54
+ }
55
+
56
+ let formattedDate = dateFormat;
57
+ formattedDate = formattedDate.replace("Y", year); // 4 digit year
58
+ formattedDate = formattedDate.replace("y", year.substring(2)); // 2 digit year
59
+ formattedDate = formattedDate.replace("m", month); // 2 digit month
60
+ formattedDate = formattedDate.replace("n", parseInt(month, 10)); // month without leading 0
61
+ formattedDate = formattedDate.replace("d", day); // 2 digit day
62
+ formattedDate = formattedDate.replace("j", parseInt(day, 10)); // day without leading 0
63
+ return formattedDate;
64
+ }
65
+ return inDate;
66
+ }
67
+
68
+ // Get the ISO date format that is stored internally
69
+ function getISODate(inDate, dateFormat) {
70
+ const date = new Date(inDate);
71
+ if (!isNaN(date)) {
72
+ if (inDate instanceof Date) {
73
+ return date.toISOString();
74
+ } else if (typeof inDate === "string" && inDate.trim().length > 0 && dateFormat) {
75
+ const dateRegex = getDateFormatRegex(dateFormat);
76
+ const { year, month, day } = getYearMonthDay(inDate, dateRegex, dateFormat);
77
+ return new Date(`${year}-${month}-${day}T00:00:00.00`).toISOString();
78
+ }
79
+ }
80
+ return inDate;
81
+ }
82
+
83
+ // Date libraries are able to parse dates such as 2023-02-31 into an actual Date object: Jan 31 2023
84
+ // Given a date string (internal ISO format) and dateFormat,
85
+ // test to see if the date is valid byt first parsing the given date for the year, month, and day
86
+ // then compare the values of the created Date object to see if it matches
87
+ function isValidDate(dateString, dateFormat) {
88
+ const date = new Date(dateString);
89
+ if (isNaN(date)) {
90
+ return false;
91
+ }
92
+
93
+ const dateRegex = getDateFormatRegex(dateFormat);
94
+ const validRegex = new RegExp(dateRegex).test(dateString);
95
+ if (validRegex) {
96
+ const { year, month, day } = getYearMonthDay(dateString, dateRegex, dateFormat);
97
+ const newDate = new Date(`${year}-${month}-${day}T00:00:00`); // ISO format
98
+ const newYear = newDate.getFullYear();
99
+ const newMonth = newDate.getMonth() + 1;
100
+ const newDay = newDate.getDate();
101
+ return newYear === parseInt(year, 10) && newMonth === parseInt(month, 10) && newDay === parseInt(day, 10);
102
+ }
103
+ return false;
104
+ }
105
+
106
+ // Given the date in string format "03-22-2023" and corresponding dateFormat m-d-Y,
107
+ // return the year, month, and day as separate fields
108
+ function getYearMonthDay(dateString, dateRegex, dateFormat) {
109
+ let year = "";
110
+ let month = "";
111
+ let day = "";
112
+
113
+ const groups = dateString.match(dateRegex);
114
+ if (groups) {
115
+ let groupIdx = 1; // Index 0 is the entire match
116
+ for (let formatIdx = 0; formatIdx < dateFormat.length; formatIdx++) {
117
+ const formatToken = dateFormat.charAt(formatIdx);
118
+ switch (formatToken) {
119
+ case "Y":
120
+ case "y": {
121
+ year = groups[groupIdx];
122
+ groupIdx++;
123
+ break;
124
+ }
125
+ case "m":
126
+ case "n": {
127
+ month = groups[groupIdx];
128
+ groupIdx++;
129
+ break;
130
+ }
131
+ case "d":
132
+ case "j": {
133
+ day = groups[groupIdx];
134
+ groupIdx++;
135
+ break;
136
+ }
137
+ default:
138
+ break;
139
+ }
140
+ }
141
+ return { year, month, day };
142
+ }
143
+ return null;
144
+ }
145
+
146
+ export {
147
+ getDateFormatRegex,
148
+ getFormattedDate,
149
+ getISODate,
150
+ isValidDate,
151
+ getYearMonthDay
152
+ };
@@ -533,41 +533,58 @@ function _findCorrespondingValue(input, values) {
533
533
  }
534
534
 
535
535
  // Convert the data types of currentParameters to the type defined in parameterDefs
536
- function convertValueDataTypes(currentParameters, paramDefs) {
536
+ function convertValueDataTypes(currentParameters, controls) {
537
537
  const convertedCurrentParameters = {};
538
- paramDefs.forEach((paramDef) => {
539
- if (!isUndefined(currentParameters[paramDef.name])) {
540
- const originalValue = currentParameters[paramDef.name];
538
+ const currentParams = Object.keys(currentParameters);
539
+ currentParams.forEach((paramName) => {
540
+ const originalValue = currentParameters[paramName];
541
+ if (!isUndefined(originalValue) && controls[paramName]) {
542
+ const valueType = controls[paramName].valueDef.propType;
543
+ const isList = controls[paramName].valueDef.isList;
541
544
  if (originalValue) {
542
- switch (paramDef.type) {
545
+ switch (valueType) {
543
546
  case "string": {
544
- convertedCurrentParameters[paramDef.name] = originalValue.toString();
547
+ if (isList) {
548
+ convertedCurrentParameters[paramName] = originalValue.map((val) => val.toString());
549
+ } else {
550
+ convertedCurrentParameters[paramName] = originalValue.toString();
551
+ }
545
552
  break;
546
553
  }
547
554
  case "integer": {
548
- convertedCurrentParameters[paramDef.name] = parseInt(originalValue, 10);
555
+ if (isList) {
556
+ convertedCurrentParameters[paramName] = originalValue.map((val) => parseInt(val, 10));
557
+ } else {
558
+ convertedCurrentParameters[paramName] = parseInt(originalValue, 10);
559
+ }
549
560
  break;
550
561
  }
551
562
  case "double": {
552
- convertedCurrentParameters[paramDef.name] = parseFloat(originalValue);
563
+ if (isList) {
564
+ convertedCurrentParameters[paramName] = originalValue.map((val) => parseFloat(val));
565
+ } else {
566
+ convertedCurrentParameters[paramName] = parseFloat(originalValue);
567
+ }
553
568
  break;
554
569
  }
555
570
  case "boolean": {
556
571
  if (isString(originalValue)) {
557
- convertedCurrentParameters[paramDef.name] = originalValue === "true";
572
+ convertedCurrentParameters[paramName] = originalValue === "true";
558
573
  } else { // Assume boolean
559
- convertedCurrentParameters[paramDef.name] = Boolean(originalValue);
574
+ convertedCurrentParameters[paramName] = Boolean(originalValue);
560
575
  }
561
576
  break;
562
577
  }
563
578
  default: { // arrays, objects, enum, password
564
- convertedCurrentParameters[paramDef.name] = originalValue;
579
+ convertedCurrentParameters[paramName] = originalValue;
565
580
  break;
566
581
  }
567
582
  }
568
583
  } else { // null
569
- convertedCurrentParameters[paramDef.name] = originalValue;
584
+ convertedCurrentParameters[paramName] = originalValue;
570
585
  }
586
+ } else { // control is missing or current parameter is not set
587
+ convertedCurrentParameters[paramName] = originalValue;
571
588
  }
572
589
  });
573
590
  return convertedCurrentParameters;
@@ -1005,6 +1005,7 @@ export default class APIPipeline {
1005
1005
 
1006
1006
  addComment(data) {
1007
1007
  this.store.dispatch({ type: "ADD_COMMENT", data: data, pipelineId: this.pipelineId });
1008
+ this.store.dispatch({ type: "SHOW_COMMENTS" });
1008
1009
  }
1009
1010
 
1010
1011
  // Returns a position for a new comment added by clicking the 'add comment'
@@ -1239,6 +1239,18 @@ export default class ObjectModel {
1239
1239
  this.store.dispatch({ type: "REMOVE_ALL_STYLES", data: { temporary: temporary } });
1240
1240
  }
1241
1241
 
1242
+ hideComments() {
1243
+ this.store.dispatch({ type: "HIDE_COMMENTS" });
1244
+ }
1245
+
1246
+ showComments() {
1247
+ this.store.dispatch({ type: "SHOW_COMMENTS" });
1248
+ }
1249
+
1250
+ isHidingComments() {
1251
+ return this.store.getCanvasInfo().hideComments;
1252
+ }
1253
+
1242
1254
  findNode(nodeId, pipelineId, pipelines) {
1243
1255
  const targetPipeline = pipelines.find((p) => p.id === pipelineId);
1244
1256
 
@@ -151,6 +151,14 @@ export default (state = {}, action) => {
151
151
  case "SET_SUBDUE_STYLE":
152
152
  return Object.assign({}, state, { subdueStyle: action.data.subdueStyle });
153
153
 
154
+ case "HIDE_COMMENTS": {
155
+ return { ...state, hideComments: true };
156
+ }
157
+
158
+ case "SHOW_COMMENTS": {
159
+ return { ...state, hideComments: false };
160
+ }
161
+
154
162
  case "ADD_NODE":
155
163
  case "REPLACE_NODES":
156
164
  case "REPLACE_NODE":
@@ -1,3 +1,19 @@
1
+ /*
2
+ * Copyright 2017-2022 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
+
1
17
  @import "@carbon/themes/scss/themes";
2
18
 
3
19
  // Switch the themes below to get light or dark.
@@ -28,13 +28,14 @@ import ZoomToFit from "./../../assets/images/zoom_to_fit.svg";
28
28
  import { Button } from "carbon-components-react";
29
29
  import SVG from "react-inlinesvg";
30
30
  import classNames from "classnames";
31
- import { StopFilledAlt16, Play16, Undo16, Redo16, Cut16, Copy16, Paste16,
31
+ import { StopFilledAlt16, Play16, Undo16, Redo16, Chat16, ChatOff16, Cut16, Copy16, Paste16,
32
32
  AddComment16, TrashCan16, ZoomIn16, ZoomOut16 } from "@carbon/icons-react";
33
33
  import { TOOLBAR_STOP, TOOLBAR_RUN, TOOLBAR_UNDO, TOOLBAR_REDO, TOOLBAR_CUT,
34
34
  TOOLBAR_COPY, TOOLBAR_PASTE, TOOLBAR_CREATE_AUTO_COMMENT,
35
35
  TOOLBAR_DELETE_SELECTED_OBJECTS, TOOLBAR_ZOOM_IN, TOOLBAR_ZOOM_OUT, TOOLBAR_ZOOM_FIT,
36
36
  TOOLBAR_ARRANGE_HORIZONALLY, TOOLBAR_ARRANGE_VERTICALLY, TOOLBAR_OPEN_PALETTE,
37
- TOOLBAR_CLOSE_PALETTE, TOOLBAR_TOGGLE_NOTIFICATION_PANEL }
37
+ TOOLBAR_CLOSE_PALETTE, TOOLBAR_TOGGLE_NOTIFICATION_PANEL,
38
+ TOOLBAR_SHOW_COMMENTS, TOOLBAR_HIDE_COMMENTS }
38
39
  from "../common-canvas/constants/canvas-constants.js";
39
40
 
40
41
  class ToolbarActionItem extends React.Component {
@@ -44,14 +45,12 @@ class ToolbarActionItem extends React.Component {
44
45
  this.actionClickHandler = this.actionClickHandler.bind(this);
45
46
  }
46
47
 
47
- // Returns a default icon, if there is one, for the action passed in. The
48
- // icon may be overridden by the iconTypeOverride field if it is provided.
48
+ // Returns a default icon, if there is one, for the action passed in.
49
49
  // It also may be set to disabled state.
50
50
  getDefaultIcon(actionObj) {
51
- const iconType = actionObj.iconTypeOverride ? actionObj.iconTypeOverride : actionObj.action;
52
51
  const disabled = !actionObj.enable;
53
52
 
54
- switch (iconType) {
53
+ switch (actionObj.action) {
55
54
  case (TOOLBAR_STOP):
56
55
  return <StopFilledAlt16 disabled={disabled} />;
57
56
  case (TOOLBAR_RUN):
@@ -68,6 +67,10 @@ class ToolbarActionItem extends React.Component {
68
67
  return <Paste16 disabled={disabled} />;
69
68
  case (TOOLBAR_CREATE_AUTO_COMMENT):
70
69
  return <AddComment16 disabled={disabled} />;
70
+ case (TOOLBAR_SHOW_COMMENTS):
71
+ return <Chat16 disabled={disabled} />;
72
+ case (TOOLBAR_HIDE_COMMENTS):
73
+ return <ChatOff16 disabled={disabled} />;
71
74
  case (TOOLBAR_DELETE_SELECTED_OBJECTS):
72
75
  return <TrashCan16 disabled={disabled} />;
73
76
  case (TOOLBAR_ZOOM_IN):
@@ -282,7 +285,6 @@ ToolbarActionItem.propTypes = {
282
285
  ]),
283
286
  className: PropTypes.string,
284
287
  textContent: PropTypes.string,
285
- iconTypeOverride: PropTypes.string,
286
288
  isSelected: PropTypes.bool,
287
289
  kind: PropTypes.string,
288
290
  jsx: PropTypes.object,
@@ -21,6 +21,7 @@ import React from "react";
21
21
  import PropTypes from "prop-types";
22
22
  import { Portal } from "react-portal";
23
23
  import { Link } from "carbon-components-react";
24
+ import { v4 as uuid4 } from "uuid";
24
25
 
25
26
  class ToolTip extends React.Component {
26
27
  constructor(props) {
@@ -28,7 +29,7 @@ class ToolTip extends React.Component {
28
29
  this.state = {
29
30
  isTooltipVisible: false
30
31
  };
31
-
32
+ this.uuid = uuid4();
32
33
  this.pendingTooltip = null;
33
34
  this.hideTooltipOnScrollAndResize = this.hideTooltipOnScrollAndResize.bind(this);
34
35
  }
@@ -61,7 +62,7 @@ class ToolTip extends React.Component {
61
62
 
62
63
 
63
64
  if (this.showTooltip()) {
64
- const tooltip = document.querySelector("[data-id='" + this.props.id + "']");
65
+ const tooltip = document.querySelector(`[data-id='${this.uuid}-${this.props.id}']`);
65
66
  this.pendingTooltip = null;
66
67
  this.setState({
67
68
  isTooltipVisible: visible
@@ -72,7 +73,7 @@ class ToolTip extends React.Component {
72
73
  if (this.props.targetObj) {
73
74
  tooltipTrigger = this.props.targetObj;
74
75
  } else {
75
- tooltipTrigger = document.querySelector("[data-id='" + this.props.id + "-trigger']");
76
+ tooltipTrigger = document.querySelector(`[data-id='${this.uuid}-${this.props.id}-trigger']`);
76
77
  }
77
78
  if (tooltipTrigger && tooltip) {
78
79
  this.updateTooltipLayout(tooltip, tooltipTrigger, tooltip.getAttribute("direction"));
@@ -119,13 +120,13 @@ class ToolTip extends React.Component {
119
120
  // (scrollWidth) value is equal to the minimum width the element would require
120
121
  // in order to fit all the content in the viewport without using a horizontal scrollbar
121
122
  canDisplayFullText(elem) {
122
- if (elem) {
123
- const firstChildWidth = elem.firstChild && elem.firstChild.scrollWidth ? elem.firstChild.scrollWidth : 0;
124
- const displayWidth = elem.offsetWidth;
125
- let fullWidth = firstChildWidth;
126
- if (firstChildWidth === 0) {
127
- fullWidth = elem.scrollWidth;
128
- }
123
+ const triggerElem = this.props.truncatedRef ? this.props.truncatedRef : elem;
124
+ if (triggerElem) {
125
+ const fullWidth = triggerElem.firstChild && triggerElem.firstChild.scrollWidth && triggerElem.firstChild.scrollWidth !== 0 ? triggerElem.firstChild.scrollWidth
126
+ : triggerElem.scrollWidth;
127
+ const childWidth = triggerElem.firstChild && triggerElem.firstChild.offsetWidth && triggerElem.firstChild.offsetWidth || 0;
128
+ // need different handling when content is within a span vs div
129
+ const displayWidth = childWidth !== 0 && childWidth < triggerElem.offsetWidth ? childWidth : triggerElem.offsetWidth;
129
130
  const canDisplayFullText = fullWidth <= displayWidth;
130
131
  return canDisplayFullText;
131
132
  }
@@ -351,7 +352,7 @@ class ToolTip extends React.Component {
351
352
  const click = (evt) => this.toggleTooltipOnClick(evt);
352
353
 
353
354
  triggerContent = (<div
354
- data-id={this.props.id + "-trigger"}
355
+ data-id={`${this.uuid}-${this.props.id}-trigger`}
355
356
  className="tooltip-trigger"
356
357
  onMouseOver={!this.props.showToolTipOnClick ? mouseover : null}
357
358
  onMouseLeave={!this.props.showToolTipOnClick ? mouseleave : null}
@@ -360,6 +361,10 @@ class ToolTip extends React.Component {
360
361
  onFocus={this.props.showToolTipOnClick ? onFocus : null} // When focused using keyboard
361
362
  onBlur={this.props.showToolTipOnClick ? onBlur : null}
362
363
  tabIndex={this.props.showToolTipOnClick ? 0 : null}
364
+ role={this.props.showToolTipOnClick ? "button" : null}
365
+ aria-labelledby={`${this.uuid}-${this.props.id}`}
366
+ aria-expanded={this.props.showToolTipOnClick ? this.state.isTooltipVisible : null}
367
+ aria-controls={this.props.showToolTipOnClick ? `${this.uuid}-${this.props.id}` : null}
363
368
  ref={(ref) => (this.triggerRef = ref)}
364
369
  >
365
370
  {this.props.children}
@@ -368,13 +373,13 @@ class ToolTip extends React.Component {
368
373
 
369
374
  if ((typeof this.props.tip) === "string") {
370
375
  tooltipContent = (
371
- <span id="tooltipContainer">
376
+ <span className="tooltipContainer">
372
377
  {this.props.tip}
373
378
  </span>
374
379
  );
375
380
  } else if ((typeof this.props.tip) === "object") {
376
381
  tooltipContent = (
377
- <div id="tooltipContainer">
382
+ <div className="tooltipContainer">
378
383
  {this.props.tip}
379
384
  </div>
380
385
  );
@@ -406,8 +411,15 @@ class ToolTip extends React.Component {
406
411
  if (tooltipContent || link) {
407
412
  tooltip = (
408
413
  <Portal>
409
- <div data-id={this.props.id} className={tipClass} aria-hidden={!this.state.isTooltipVisible} direction={this.props.direction}>
410
- <svg id="tipArrow" x="0px" y="0px" viewBox="0 0 9.1 16.1">
414
+ <div
415
+ role="tooltip"
416
+ id={`${this.uuid}-${this.props.id}`}
417
+ data-id={`${this.uuid}-${this.props.id}`}
418
+ className={tipClass}
419
+ aria-hidden={!this.state.isTooltipVisible}
420
+ direction={this.props.direction}
421
+ >
422
+ <svg className="tipArrow" x="0px" y="0px" viewBox="0 0 9.1 16.1">
411
423
  <polyline points="9.1,15.7 1.4,8.1 9.1,0.5" />
412
424
  <polygon points="8.1,16.1 0,8.1 8.1,0 8.1,1.4 1.4,8.1 8.1,14.7" />
413
425
  </svg>
@@ -439,6 +451,7 @@ ToolTip.propTypes = {
439
451
  mousePos: PropTypes.object,
440
452
  disable: PropTypes.bool, // Tooltip will not show if disabled
441
453
  showToolTipIfTruncated: PropTypes.bool, // Set to true to only display tooltip if full text does not fit in displayable width
454
+ truncatedRef: PropTypes.object,
442
455
  delay: PropTypes.number,
443
456
  showToolTipOnClick: PropTypes.bool
444
457
  };
@@ -72,31 +72,31 @@
72
72
  padding: $spacing-03 $spacing-05;
73
73
  }
74
74
 
75
- .common-canvas-tooltip #tipArrow {
75
+ .common-canvas-tooltip .tipArrow {
76
76
  position: absolute;
77
77
  width: 10px;
78
78
  height: 14px;
79
79
  }
80
80
 
81
- .common-canvas-tooltip[direction="top"] #tipArrow {
81
+ .common-canvas-tooltip[direction="top"] .tipArrow {
82
82
  transform: rotate(-90deg);
83
83
  }
84
84
 
85
- .common-canvas-tooltip[direction="left"] #tipArrow {
85
+ .common-canvas-tooltip[direction="left"] .tipArrow {
86
86
  transform: rotate(180deg);
87
87
  }
88
88
 
89
- .common-canvas-tooltip[direction="bottom"] #tipArrow {
89
+ .common-canvas-tooltip[direction="bottom"] .tipArrow {
90
90
  transform: rotate(90deg);
91
91
  }
92
92
 
93
93
 
94
- .common-canvas-tooltip #tipArrow polyline {
94
+ .common-canvas-tooltip .tipArrow polyline {
95
95
  fill: $inverse-02;
96
96
  stroke-width: 0;
97
97
  }
98
98
 
99
- .common-canvas-tooltip #tipArrow polygon {
99
+ .common-canvas-tooltip .tipArrow polygon {
100
100
  fill: $inverse-02;
101
101
  }
102
102
 
@@ -156,6 +156,6 @@
156
156
  max-width: 250px;
157
157
  }
158
158
 
159
- .properties-tooltips #tipArrow polyline {
159
+ .properties-tooltips .tipArrow polyline {
160
160
  fill: $inverse-02;
161
161
  }