@reltio/components 1.4.2206 → 1.4.2208

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 (49) hide show
  1. package/cjs/contexts/WorkflowTasksContext/index.d.ts +1 -0
  2. package/cjs/features/workflow/ChangeRequestEditor/ChangeRequestEditor.js +1 -2
  3. package/cjs/features/workflow/ChangeRequestEditor/components/ChangeItemEditor/ChangeItemEditor.js +3 -4
  4. package/cjs/features/workflow/ChangeRequestEditor/components/ChangeItemRow/ChangeItemRow.js +4 -4
  5. package/cjs/features/workflow/ChangeRequestEditor/components/DCRValueEditor/DCRValueEditor.d.ts +1 -1
  6. package/cjs/features/workflow/ChangeRequestEditor/components/DCRValueEditorFactory/DCRValueEditorFactory.d.ts +1 -1
  7. package/cjs/features/workflow/ChangeRequestEditor/hooks/useChangeRequestEditor.d.ts +2 -1
  8. package/cjs/features/workflow/ChangeRequestEditor/hooks/useChangeRequestEditor.js +14 -8
  9. package/cjs/features/workflow/ReviewDCRDialog/ReviewDCRDialog.js +10 -7
  10. package/cjs/features/workflow/TaskActionButtons/TaskActionButtons.js +6 -4
  11. package/cjs/features/workflow/WorkflowTaskCard/components/DataChangeRequestTaskCard/DataChangeRequestTaskCard.js +12 -3
  12. package/cjs/features/workflow/WorkflowTaskCard/components/GenericWorkflowTaskCard/GenericWorkflowTaskCard.js +6 -4
  13. package/cjs/features/workflow/{ChangeRequestEditor/context → contexts/ChangeRequestEditorContext}/index.d.ts +1 -0
  14. package/cjs/features/workflow/{ChangeRequestEditor/context → contexts/ChangeRequestEditorContext}/index.js +12 -0
  15. package/cjs/features/workflow/helpers/attributes.js +2 -2
  16. package/cjs/features/workflow/helpers/attributes.test.js +9 -6
  17. package/cjs/features/workflow/helpers/dcr.d.ts +8 -1
  18. package/cjs/features/workflow/helpers/dcr.js +186 -1
  19. package/cjs/features/workflow/helpers/merge.js +2 -1
  20. package/cjs/features/workflow/hooks/useApplyDcrChanges.d.ts +3 -0
  21. package/cjs/features/workflow/hooks/useApplyDcrChanges.js +145 -0
  22. package/cjs/features/workflow/hooks/useWorkflowActions.d.ts +7 -2
  23. package/cjs/features/workflow/hooks/useWorkflowActions.js +31 -8
  24. package/cjs/features/workflow/types.d.ts +4 -0
  25. package/contexts/WorkflowTasksContext/index.d.ts +1 -0
  26. package/features/workflow/ChangeRequestEditor/ChangeRequestEditor.js +1 -2
  27. package/features/workflow/ChangeRequestEditor/components/ChangeItemEditor/ChangeItemEditor.js +3 -4
  28. package/features/workflow/ChangeRequestEditor/components/ChangeItemRow/ChangeItemRow.js +1 -1
  29. package/features/workflow/ChangeRequestEditor/components/DCRValueEditor/DCRValueEditor.d.ts +1 -1
  30. package/features/workflow/ChangeRequestEditor/components/DCRValueEditorFactory/DCRValueEditorFactory.d.ts +1 -1
  31. package/features/workflow/ChangeRequestEditor/hooks/useChangeRequestEditor.d.ts +2 -1
  32. package/features/workflow/ChangeRequestEditor/hooks/useChangeRequestEditor.js +8 -2
  33. package/features/workflow/ReviewDCRDialog/ReviewDCRDialog.js +10 -7
  34. package/features/workflow/TaskActionButtons/TaskActionButtons.js +6 -4
  35. package/features/workflow/WorkflowTaskCard/components/DataChangeRequestTaskCard/DataChangeRequestTaskCard.js +14 -5
  36. package/features/workflow/WorkflowTaskCard/components/GenericWorkflowTaskCard/GenericWorkflowTaskCard.js +6 -4
  37. package/features/workflow/{ChangeRequestEditor/context → contexts/ChangeRequestEditorContext}/index.d.ts +1 -0
  38. package/features/workflow/{ChangeRequestEditor/context → contexts/ChangeRequestEditorContext}/index.js +13 -1
  39. package/features/workflow/helpers/attributes.js +2 -2
  40. package/features/workflow/helpers/attributes.test.js +9 -6
  41. package/features/workflow/helpers/dcr.d.ts +8 -1
  42. package/features/workflow/helpers/dcr.js +186 -2
  43. package/features/workflow/helpers/merge.js +2 -1
  44. package/features/workflow/hooks/useApplyDcrChanges.d.ts +3 -0
  45. package/features/workflow/hooks/useApplyDcrChanges.js +141 -0
  46. package/features/workflow/hooks/useWorkflowActions.d.ts +7 -2
  47. package/features/workflow/hooks/useWorkflowActions.js +31 -8
  48. package/features/workflow/types.d.ts +4 -0
  49. package/package.json +2 -2
@@ -41,23 +41,25 @@ import { isOpenTask } from '../helpers/common';
41
41
  import { WorkflowTasksContext } from '../../../contexts/WorkflowTasksContext';
42
42
  import { useMdmTenant, useMdmUsername, useMdmWorkflowEnvironmentUrl, useMdmWorkflowPath } from '../../../contexts/MdmModuleContext';
43
43
  import { useCommentDialog } from '../../../contexts/CommentDialogContext';
44
- export var useWorkflowActions = function (task, onActionSuccess) {
45
- var _a = task !== null && task !== void 0 ? task : {}, possibleActions = _a.possibleActions, assignee = _a.assignee, taskId = _a.taskId, isOpen = _a.isOpen;
44
+ import { showDefaultErrorMessage } from '../../../helpers/errors';
45
+ export var useWorkflowActions = function (_a) {
46
+ var task = _a.task, onActionSuccess = _a.onActionSuccess, beforeAction = _a.beforeAction;
47
+ var _b = task !== null && task !== void 0 ? task : {}, possibleActions = _b.possibleActions, assignee = _b.assignee, taskId = _b.taskId, isOpen = _b.isOpen;
46
48
  var workflowTasks = useContext(WorkflowTasksContext);
47
49
  var workflowPath = useMdmWorkflowPath();
48
50
  var environment = useMdmWorkflowEnvironmentUrl();
49
51
  var tenant = useMdmTenant();
50
52
  var username = useMdmUsername();
51
53
  var showCommentDialog = useCommentDialog();
52
- var _b = useState(false), actionRequestIsInProgress = _b[0], setActionRequestIsInProgress = _b[1];
54
+ var _c = useState(false), actionRequestIsInProgress = _c[0], setActionRequestIsInProgress = _c[1];
53
55
  var handleActionSuccess = onActionSuccess !== null && onActionSuccess !== void 0 ? onActionSuccess : workflowTasks === null || workflowTasks === void 0 ? void 0 : workflowTasks.onActionSuccess;
54
56
  var performTaskAction = useCallback(function (action, commentRequired) {
55
57
  return function (comment) { return __awaiter(void 0, void 0, void 0, function () {
56
- var processInstanceComment;
58
+ var processInstanceComment, outcome, error_1;
57
59
  return __generator(this, function (_a) {
58
60
  switch (_a.label) {
59
61
  case 0:
60
- if (!(workflowPath && taskId)) return [3 /*break*/, 3];
62
+ if (!(workflowPath && taskId)) return [3 /*break*/, 7];
61
63
  setActionRequestIsInProgress(true);
62
64
  processInstanceComment = typeof comment === 'string' && comment.length ? comment : null;
63
65
  if (!(commentRequired && !processInstanceComment)) return [3 /*break*/, 2];
@@ -70,6 +72,27 @@ export var useWorkflowActions = function (task, onActionSuccess) {
70
72
  }
71
73
  _a.label = 2;
72
74
  case 2:
75
+ if (!beforeAction) return [3 /*break*/, 6];
76
+ _a.label = 3;
77
+ case 3:
78
+ _a.trys.push([3, 5, , 6]);
79
+ return [4 /*yield*/, beforeAction()];
80
+ case 4:
81
+ outcome = _a.sent();
82
+ if (!outcome.proceed) {
83
+ if (outcome.error) {
84
+ showDefaultErrorMessage(outcome.error);
85
+ }
86
+ setActionRequestIsInProgress(false);
87
+ return [2 /*return*/];
88
+ }
89
+ return [3 /*break*/, 6];
90
+ case 5:
91
+ error_1 = _a.sent();
92
+ showDefaultErrorMessage(error_1);
93
+ setActionRequestIsInProgress(false);
94
+ return [2 /*return*/];
95
+ case 6:
73
96
  runTaskAction({
74
97
  taskId: taskId,
75
98
  workflowPath: workflowPath,
@@ -85,12 +108,12 @@ export var useWorkflowActions = function (task, onActionSuccess) {
85
108
  .finally(function () {
86
109
  setActionRequestIsInProgress(false);
87
110
  });
88
- _a.label = 3;
89
- case 3: return [2 /*return*/];
111
+ _a.label = 7;
112
+ case 7: return [2 /*return*/];
90
113
  }
91
114
  });
92
115
  }); };
93
- }, [workflowPath, taskId, environment, tenant, handleActionSuccess, showCommentDialog]);
116
+ }, [workflowPath, taskId, environment, tenant, handleActionSuccess, showCommentDialog, beforeAction]);
94
117
  var actions = useMemo(function () {
95
118
  return username === assignee && isOpenTask(isOpen)
96
119
  ? (possibleActions || []).map(function (_a) {
@@ -19,3 +19,7 @@ export type Diff = {
19
19
  export type Title = {
20
20
  label: string;
21
21
  };
22
+ export type BeforeActionOutcome = {
23
+ proceed: boolean;
24
+ error?: unknown;
25
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reltio/components",
3
- "version": "1.4.2206",
3
+ "version": "1.4.2208",
4
4
  "license": "SEE LICENSE IN LICENSE FILE",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./index.js",
@@ -11,7 +11,7 @@
11
11
  "@fluentui/react-context-selector": "^9.1.26",
12
12
  "@googlemaps/markerclusterer": "^2.5.3",
13
13
  "@react-sigma/core": "3.4.0",
14
- "@reltio/mdm-sdk": "^1.4.2008",
14
+ "@reltio/mdm-sdk": "^1.4.2010",
15
15
  "@vis.gl/react-google-maps": "^1.3.0",
16
16
  "d3-cloud": "^1.2.5",
17
17
  "d3-geo": "^2.0.1",