@reltio/components 1.4.2189 → 1.4.2191

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 (133) hide show
  1. package/ProfileBand/ProfileBand.d.ts +5 -4
  2. package/ProfileBand/ProfileBand.js +4 -5
  3. package/ProfileBand/ProfileBand.module.css.js +9 -0
  4. package/cjs/ProfileBand/ProfileBand.d.ts +5 -4
  5. package/cjs/ProfileBand/ProfileBand.js +14 -15
  6. package/cjs/ProfileBand/ProfileBand.module.css.js +9 -0
  7. package/cjs/contexts/MdmModuleContext/context.d.ts +2 -0
  8. package/cjs/contexts/MdmModuleContext/hooks.d.ts +1 -0
  9. package/cjs/contexts/MdmModuleContext/hooks.js +3 -1
  10. package/cjs/contexts/MdmModuleContext/index.d.ts +1 -1
  11. package/cjs/contexts/MdmModuleContext/index.js +2 -1
  12. package/cjs/features/history/HistoryRow/styles.d.ts +1 -1
  13. package/cjs/features/workflow/AddWorkflowDialog/AddWorkflowDialog.spec.js +67 -0
  14. package/cjs/features/workflow/ChangeRequestEditor/ChangeRequestEditor.d.ts +8 -0
  15. package/cjs/features/workflow/ChangeRequestEditor/ChangeRequestEditor.js +18 -0
  16. package/cjs/features/workflow/ChangeRequestEditor/ChangeRequestEditor.module.css.js +9 -0
  17. package/cjs/features/workflow/ChangeRequestEditor/index.d.ts +1 -0
  18. package/cjs/features/workflow/ChangeRequestEditor/index.js +5 -0
  19. package/cjs/features/workflow/ReviewDCRButton/ReviewDCRButton.d.ts +6 -0
  20. package/cjs/features/workflow/ReviewDCRButton/ReviewDCRButton.js +19 -0
  21. package/cjs/features/workflow/ReviewDCRButton/ReviewDCRButton.module.css.js +9 -0
  22. package/cjs/features/workflow/ReviewDCRButton/index.d.ts +1 -0
  23. package/cjs/features/workflow/ReviewDCRButton/index.js +5 -0
  24. package/cjs/features/workflow/ReviewDCRDialog/ReviewDCRDialog.d.ts +11 -0
  25. package/cjs/features/workflow/ReviewDCRDialog/ReviewDCRDialog.js +63 -0
  26. package/cjs/features/workflow/ReviewDCRDialog/ReviewDCRDialog.module.css.js +9 -0
  27. package/cjs/features/workflow/ReviewDCRDialog/components/DCRChangesSummary/DCRChangesSummary.d.ts +8 -0
  28. package/cjs/features/workflow/ReviewDCRDialog/components/DCRChangesSummary/DCRChangesSummary.js +73 -0
  29. package/cjs/features/workflow/ReviewDCRDialog/components/DCRChangesSummary/DCRChangesSummary.module.css.js +9 -0
  30. package/cjs/features/workflow/ReviewDCRDialog/components/DCRChangesSummary/index.d.ts +1 -0
  31. package/cjs/features/workflow/ReviewDCRDialog/components/DCRChangesSummary/index.js +5 -0
  32. package/cjs/features/workflow/ReviewDCRDialog/components/DCRSummaryInfo/DCRSummaryInfo.d.ts +9 -0
  33. package/cjs/features/workflow/ReviewDCRDialog/components/DCRSummaryInfo/DCRSummaryInfo.js +40 -0
  34. package/cjs/features/workflow/ReviewDCRDialog/components/DCRSummaryInfo/DCRSummaryInfo.module.css.js +9 -0
  35. package/cjs/features/workflow/ReviewDCRDialog/helpers/calculateDCRChanges.d.ts +3 -0
  36. package/cjs/features/workflow/ReviewDCRDialog/helpers/calculateDCRChanges.js +19 -0
  37. package/cjs/features/workflow/ReviewDCRDialog/helpers/calculateDCRChanges.test.d.ts +1 -0
  38. package/cjs/features/workflow/ReviewDCRDialog/helpers/calculateDCRChanges.test.js +124 -0
  39. package/cjs/features/workflow/ReviewDCRDialog/helpers/index.d.ts +1 -0
  40. package/cjs/features/workflow/ReviewDCRDialog/helpers/index.js +5 -0
  41. package/cjs/features/workflow/ReviewDCRDialog/index.d.ts +1 -0
  42. package/cjs/features/workflow/ReviewDCRDialog/index.js +5 -0
  43. package/cjs/features/workflow/TaskActionButtons/TaskActionButtons.spec.js +1 -1
  44. package/cjs/features/workflow/WorkflowActionButtons/WorkflowActionButtons.d.ts +12 -0
  45. package/cjs/features/workflow/WorkflowActionButtons/WorkflowActionButtons.js +57 -0
  46. package/cjs/features/workflow/WorkflowActionButtons/index.d.ts +1 -0
  47. package/cjs/features/workflow/WorkflowActionButtons/index.js +5 -0
  48. package/cjs/features/workflow/WorkflowComments/WorkflowComments.d.ts +7 -1
  49. package/cjs/features/workflow/WorkflowComments/WorkflowComments.js +15 -31
  50. package/cjs/features/workflow/WorkflowComments/WorkflowComments.module.css.js +9 -0
  51. package/cjs/features/workflow/WorkflowTaskCard/components/DataChangeRequestTaskCard/DataChangeRequestTaskCard.js +46 -6
  52. package/cjs/features/workflow/WorkflowTaskCard/components/DataChangeRequestTaskCard/DataChangeRequestTaskCard.spec.js +80 -5
  53. package/cjs/features/workflow/WorkflowTaskCard/components/GenericWorkflowTaskCard/GenericWorkflowTaskCard.d.ts +2 -1
  54. package/cjs/features/workflow/WorkflowTaskCard/components/GenericWorkflowTaskCard/GenericWorkflowTaskCard.js +30 -29
  55. package/cjs/features/workflow/WorkflowTaskCard/components/GenericWorkflowTaskCard/GenericWorkflowTaskCard.module.css.js +9 -0
  56. package/cjs/features/workflow/WorkflowTaskCard/components/GenericWorkflowTaskCard/GenericWorkflowTaskCard.spec.js +124 -2
  57. package/cjs/features/workflow/WorkflowTaskCard/components/PotentialMatchTaskCard/PotentialMatchTaskCard.spec.js +69 -3
  58. package/cjs/features/workflow/index.d.ts +2 -0
  59. package/cjs/features/workflow/index.js +5 -1
  60. package/cjs/icons/RequestSummary.d.ts +3 -0
  61. package/cjs/icons/RequestSummary.js +24 -0
  62. package/cjs/icons/ReviewDCR.d.ts +3 -0
  63. package/cjs/icons/ReviewDCR.js +22 -0
  64. package/contexts/MdmModuleContext/context.d.ts +2 -0
  65. package/contexts/MdmModuleContext/hooks.d.ts +1 -0
  66. package/contexts/MdmModuleContext/hooks.js +1 -0
  67. package/contexts/MdmModuleContext/index.d.ts +1 -1
  68. package/contexts/MdmModuleContext/index.js +1 -1
  69. package/features/history/HistoryRow/styles.d.ts +1 -1
  70. package/features/workflow/AddWorkflowDialog/AddWorkflowDialog.spec.js +67 -0
  71. package/features/workflow/ChangeRequestEditor/ChangeRequestEditor.d.ts +8 -0
  72. package/features/workflow/ChangeRequestEditor/ChangeRequestEditor.js +11 -0
  73. package/features/workflow/ChangeRequestEditor/ChangeRequestEditor.module.css.js +9 -0
  74. package/features/workflow/ChangeRequestEditor/index.d.ts +1 -0
  75. package/features/workflow/ChangeRequestEditor/index.js +1 -0
  76. package/features/workflow/ReviewDCRButton/ReviewDCRButton.d.ts +6 -0
  77. package/features/workflow/ReviewDCRButton/ReviewDCRButton.js +12 -0
  78. package/features/workflow/ReviewDCRButton/ReviewDCRButton.module.css.js +9 -0
  79. package/features/workflow/ReviewDCRButton/index.d.ts +1 -0
  80. package/features/workflow/ReviewDCRButton/index.js +1 -0
  81. package/features/workflow/ReviewDCRDialog/ReviewDCRDialog.d.ts +11 -0
  82. package/features/workflow/ReviewDCRDialog/ReviewDCRDialog.js +56 -0
  83. package/features/workflow/ReviewDCRDialog/ReviewDCRDialog.module.css.js +9 -0
  84. package/features/workflow/ReviewDCRDialog/components/DCRChangesSummary/DCRChangesSummary.d.ts +8 -0
  85. package/features/workflow/ReviewDCRDialog/components/DCRChangesSummary/DCRChangesSummary.js +43 -0
  86. package/features/workflow/ReviewDCRDialog/components/DCRChangesSummary/DCRChangesSummary.module.css.js +9 -0
  87. package/features/workflow/ReviewDCRDialog/components/DCRChangesSummary/index.d.ts +1 -0
  88. package/features/workflow/ReviewDCRDialog/components/DCRChangesSummary/index.js +1 -0
  89. package/features/workflow/ReviewDCRDialog/components/DCRSummaryInfo/DCRSummaryInfo.d.ts +9 -0
  90. package/features/workflow/ReviewDCRDialog/components/DCRSummaryInfo/DCRSummaryInfo.js +33 -0
  91. package/features/workflow/ReviewDCRDialog/components/DCRSummaryInfo/DCRSummaryInfo.module.css.js +9 -0
  92. package/features/workflow/ReviewDCRDialog/helpers/calculateDCRChanges.d.ts +3 -0
  93. package/features/workflow/ReviewDCRDialog/helpers/calculateDCRChanges.js +15 -0
  94. package/features/workflow/ReviewDCRDialog/helpers/calculateDCRChanges.test.d.ts +1 -0
  95. package/features/workflow/ReviewDCRDialog/helpers/calculateDCRChanges.test.js +122 -0
  96. package/features/workflow/ReviewDCRDialog/helpers/index.d.ts +1 -0
  97. package/features/workflow/ReviewDCRDialog/helpers/index.js +1 -0
  98. package/features/workflow/ReviewDCRDialog/index.d.ts +1 -0
  99. package/features/workflow/ReviewDCRDialog/index.js +1 -0
  100. package/features/workflow/TaskActionButtons/TaskActionButtons.spec.js +1 -1
  101. package/features/workflow/WorkflowActionButtons/WorkflowActionButtons.d.ts +12 -0
  102. package/features/workflow/WorkflowActionButtons/WorkflowActionButtons.js +27 -0
  103. package/features/workflow/WorkflowActionButtons/index.d.ts +1 -0
  104. package/features/workflow/WorkflowActionButtons/index.js +1 -0
  105. package/features/workflow/WorkflowComments/WorkflowComments.d.ts +7 -1
  106. package/features/workflow/WorkflowComments/WorkflowComments.js +13 -29
  107. package/features/workflow/WorkflowComments/WorkflowComments.module.css.js +9 -0
  108. package/features/workflow/WorkflowTaskCard/components/DataChangeRequestTaskCard/DataChangeRequestTaskCard.js +23 -6
  109. package/features/workflow/WorkflowTaskCard/components/DataChangeRequestTaskCard/DataChangeRequestTaskCard.spec.js +82 -7
  110. package/features/workflow/WorkflowTaskCard/components/GenericWorkflowTaskCard/GenericWorkflowTaskCard.d.ts +2 -1
  111. package/features/workflow/WorkflowTaskCard/components/GenericWorkflowTaskCard/GenericWorkflowTaskCard.js +8 -7
  112. package/features/workflow/WorkflowTaskCard/components/GenericWorkflowTaskCard/GenericWorkflowTaskCard.module.css.js +9 -0
  113. package/features/workflow/WorkflowTaskCard/components/GenericWorkflowTaskCard/GenericWorkflowTaskCard.spec.js +125 -3
  114. package/features/workflow/WorkflowTaskCard/components/PotentialMatchTaskCard/PotentialMatchTaskCard.spec.js +71 -5
  115. package/features/workflow/index.d.ts +2 -0
  116. package/features/workflow/index.js +2 -0
  117. package/icons/RequestSummary.d.ts +3 -0
  118. package/icons/RequestSummary.js +19 -0
  119. package/icons/ReviewDCR.d.ts +3 -0
  120. package/icons/ReviewDCR.js +17 -0
  121. package/package.json +2 -2
  122. package/ProfileBand/styles.d.ts +0 -1
  123. package/ProfileBand/styles.js +0 -87
  124. package/cjs/ProfileBand/styles.d.ts +0 -1
  125. package/cjs/ProfileBand/styles.js +0 -90
  126. package/cjs/features/workflow/WorkflowComments/styles.d.ts +0 -1
  127. package/cjs/features/workflow/WorkflowComments/styles.js +0 -42
  128. package/cjs/features/workflow/WorkflowTaskCard/components/GenericWorkflowTaskCard/styles.d.ts +0 -3
  129. package/cjs/features/workflow/WorkflowTaskCard/components/GenericWorkflowTaskCard/styles.js +0 -113
  130. package/features/workflow/WorkflowComments/styles.d.ts +0 -1
  131. package/features/workflow/WorkflowComments/styles.js +0 -39
  132. package/features/workflow/WorkflowTaskCard/components/GenericWorkflowTaskCard/styles.d.ts +0 -3
  133. package/features/workflow/WorkflowTaskCard/components/GenericWorkflowTaskCard/styles.js +0 -110
@@ -0,0 +1 @@
1
+ export { WorkflowActionButtons } from './WorkflowActionButtons';
@@ -0,0 +1 @@
1
+ export { WorkflowActionButtons } from './WorkflowActionButtons';
@@ -8,6 +8,12 @@ type Props = {
8
8
  taskId: string;
9
9
  isTaskOpen: boolean;
10
10
  preferredAction?: WorkflowAction;
11
+ showActionButtons?: boolean;
12
+ alwaysExpanded?: boolean;
13
+ classes?: {
14
+ container?: string;
15
+ commentsContainer?: string;
16
+ };
11
17
  };
12
- export declare const WorkflowComments: ({ workflowActions: actions, actionRequestIsInProgress, processInstanceComments, taskId, isTaskOpen, preferredAction }: Props) => React.JSX.Element;
18
+ export declare const WorkflowComments: ({ workflowActions: actions, actionRequestIsInProgress, processInstanceComments, taskId, isTaskOpen, preferredAction, showActionButtons, alwaysExpanded, classes }: Props) => React.JSX.Element;
13
19
  export {};
@@ -1,26 +1,24 @@
1
- import React, { useCallback, useState, useMemo } from 'react';
1
+ import React, { useCallback, useState } from 'react';
2
+ import classnames from 'classnames';
2
3
  import i18n from 'ui-i18n';
3
4
  import Input from '@mui/material/Input';
4
5
  import InputAdornment from '@mui/material/InputAdornment';
5
6
  import SendIcon from '@mui/icons-material/Send';
6
- import Button from '@mui/material/Button';
7
7
  import { CollapsedComments } from './components/CollapsedComments';
8
8
  import { ExpandedComments } from './components/ExpandedComments';
9
9
  import { useWorkflowComments } from '../hooks/useWorkflowComments';
10
10
  import { SmallIconButton } from '../../../SmallIconButton';
11
- import { ModeSwitcherSelect } from '../../../ModeSwitcherSelect';
12
- import { useStyles } from './styles';
11
+ import { WorkflowActionButtons } from '../WorkflowActionButtons';
12
+ import styles from './WorkflowComments.module.css';
13
13
  export var WorkflowComments = function (_a) {
14
- var actions = _a.workflowActions, actionRequestIsInProgress = _a.actionRequestIsInProgress, processInstanceComments = _a.processInstanceComments, taskId = _a.taskId, isTaskOpen = _a.isTaskOpen, preferredAction = _a.preferredAction;
15
- var styles = useStyles();
16
- var _b = useState(false), expanded = _b[0], setExpanded = _b[1];
17
- var _c = useState(''), comment = _c[0], setComment = _c[1];
18
- var _d = useState(function () { var _a; return (preferredAction === null || preferredAction === void 0 ? void 0 : preferredAction.label) || ((_a = actions[0]) === null || _a === void 0 ? void 0 : _a.text); }), currentAction = _d[0], setCurrentAction = _d[1];
19
- var _e = useWorkflowComments({
14
+ var actions = _a.workflowActions, actionRequestIsInProgress = _a.actionRequestIsInProgress, processInstanceComments = _a.processInstanceComments, taskId = _a.taskId, isTaskOpen = _a.isTaskOpen, preferredAction = _a.preferredAction, _b = _a.showActionButtons, showActionButtons = _b === void 0 ? true : _b, _c = _a.alwaysExpanded, alwaysExpanded = _c === void 0 ? false : _c, classes = _a.classes;
15
+ var _d = useState(false), expanded = _d[0], setExpanded = _d[1];
16
+ var _e = useState(''), comment = _e[0], setComment = _e[1];
17
+ var _f = useWorkflowComments({
20
18
  processInstanceComments: processInstanceComments,
21
19
  taskId: taskId,
22
20
  isOpen: isTaskOpen
23
- }), comments = _e.comments, writeComment = _e.writeComment, readOnly = _e.readOnly;
21
+ }), comments = _f.comments, writeComment = _f.writeComment, readOnly = _f.readOnly;
24
22
  var sendComment = useCallback(function () {
25
23
  writeComment(comment);
26
24
  setComment('');
@@ -40,28 +38,14 @@ export var WorkflowComments = function (_a) {
40
38
  e.preventDefault();
41
39
  }
42
40
  }, [comment, sendComment]);
43
- var buttonsGroup = useMemo(function () {
44
- return actions.map(function (_a) {
45
- var text = _a.text, onClick = _a.onClick;
46
- return ({
47
- label: text,
48
- onClick: function () {
49
- setCurrentAction(text);
50
- onClick(comment);
51
- },
52
- value: text
53
- });
54
- });
55
- }, [actions, comment]);
56
- return (React.createElement("div", { className: styles.container },
41
+ return (React.createElement("div", { className: classnames(styles.container, classes === null || classes === void 0 ? void 0 : classes.container) },
57
42
  React.createElement("div", { className: styles.title },
58
43
  " ",
59
44
  i18n.text('Comments'),
60
45
  " "),
61
- React.createElement("div", { className: styles.commentsContainer }, expanded || comments.length < 3 ? (React.createElement(ExpandedComments, { comments: comments })) : (React.createElement(CollapsedComments, { onClick: function () { return setExpanded(true); }, comments: comments }))),
46
+ React.createElement("div", { className: classnames(styles.commentsContainer, classes === null || classes === void 0 ? void 0 : classes.commentsContainer) }, expanded || alwaysExpanded || comments.length < 3 ? (React.createElement(ExpandedComments, { comments: comments })) : (React.createElement(CollapsedComments, { onClick: function () { return setExpanded(true); }, comments: comments }))),
62
47
  !readOnly && (React.createElement(Input, { endAdornment: React.createElement(InputAdornment, { position: "end", className: styles.sendButton },
63
48
  React.createElement(SmallIconButton, { icon: SendIcon, disabled: comment.length === 0, onClick: sendComment, "data-reltio-id": "send-button" })), classes: { root: styles.filledInputRoot }, placeholder: i18n.text('Write a comment'), value: comment, onKeyPress: handleKeyPress, onChange: handleChange, disableUnderline: true, multiline: true })),
64
- React.createElement("div", { className: styles.modeSwitcherWrapper },
65
- buttonsGroup.length === 1 && (React.createElement(Button, { variant: "outlined", onClick: buttonsGroup[0].onClick, disabled: actionRequestIsInProgress }, buttonsGroup[0].label)),
66
- buttonsGroup.length > 1 && (React.createElement(ModeSwitcherSelect, { buttonsGroup: buttonsGroup, value: currentAction, loading: actionRequestIsInProgress, disabled: actionRequestIsInProgress })))));
49
+ showActionButtons && (React.createElement("div", { className: styles.modeSwitcherWrapper },
50
+ React.createElement(WorkflowActionButtons, { workflowActions: actions, actionRequestIsInProgress: actionRequestIsInProgress, preferredAction: preferredAction, comment: comment })))));
67
51
  };
@@ -0,0 +1,9 @@
1
+ const styles = {"container":"WorkflowComments-container--zu4Un","commentsContainer":"WorkflowComments-commentsContainer--CHV0q","title":"WorkflowComments-title--a0FTZ","filledInputRoot":"WorkflowComments-filledInputRoot--q5WAu","focused":"WorkflowComments-focused--s-NQa","modeSwitcherWrapper":"WorkflowComments-modeSwitcherWrapper--b585U","sendButton":"WorkflowComments-sendButton--NjNcl"};
2
+ if (typeof document !== 'undefined') {
3
+ const head = document.head || document.getElementsByTagName('head')[0]
4
+ const style = document.createElement('style');
5
+ style.type = 'text/css'
6
+ style.innerHTML = `.WorkflowComments-container--zu4Un{display:flex;flex-direction:column;padding:5px 0}.WorkflowComments-commentsContainer--CHV0q{max-height:300px;overflow-y:auto}.WorkflowComments-title--a0FTZ{color:rgba(0,0,0,.87);font-size:14px;margin:0 0 8px 5px}.WorkflowComments-filledInputRoot--q5WAu{background-color:rgba(0,0,0,.03);font-size:14px;margin:10px 17px 0 6px;min-height:40px;padding:10px 6px}.WorkflowComments-filledInputRoot--q5WAu.WorkflowComments-focused--s-NQa,.WorkflowComments-filledInputRoot--q5WAu:hover{background-color:rgba(0,0,0,.03)}.WorkflowComments-modeSwitcherWrapper--b585U{margin-left:auto;margin-right:16px;margin-top:8px}.WorkflowComments-sendButton--NjNcl{align-self:end;margin-bottom:10px}`;
7
+ head.appendChild(style);
8
+ }
9
+ export default styles;
@@ -1,16 +1,33 @@
1
- import React from 'react';
1
+ import React, { useCallback, useMemo, useState } from 'react';
2
2
  import DcrTaskIcon from '../../../../../icons/DcrTaskIcon';
3
+ import { useMdmReviewDCREnabled, useMdmUsername } from '../../../../../contexts/MdmModuleContext';
3
4
  import { GenericWorkflowTaskCard } from '../GenericWorkflowTaskCard';
4
5
  import { AttributesChanges } from '../../../AttributesChanges';
5
6
  import { LineDecorator } from '../../../LineDecorator';
6
7
  import { useChangeRequest } from '../../../hooks/useChangeRequest';
7
8
  import { getDCRUri } from '../../../helpers/common';
9
+ import { ReviewDCRDialog } from '../../../ReviewDCRDialog';
10
+ import { ReviewDCRButton } from '../../../ReviewDCRButton';
8
11
  export var DataChangeRequestTaskCard = function (_a) {
9
12
  var task = _a.task;
10
- var objectURIs = task.objectURIs;
13
+ var reviewDCREnabled = useMdmReviewDCREnabled();
14
+ var username = useMdmUsername();
15
+ var _b = useState(false), isReviewDCRDialogOpen = _b[0], setIsReviewDCRDialogOpen = _b[1];
16
+ var objectURIs = task.objectURIs, assignee = task.assignee;
11
17
  var dcrUri = getDCRUri(objectURIs);
12
- var _b = useChangeRequest(dcrUri), dcr = _b.dcr, groupedObjects = _b.groupedObjects;
13
- return (React.createElement(GenericWorkflowTaskCard, { task: task, Icon: DcrTaskIcon }, dcr &&
14
- groupedObjects.map(function (object, index) { return (React.createElement(LineDecorator, { key: index, last: index === groupedObjects.length - 1, divider: true },
15
- React.createElement(AttributesChanges, { entityInfo: object.entity, relationsInfo: object.relations, changes: dcr.changes, objectsInfo: dcr.objectsInfo, dcrUri: dcrUri }))); })));
18
+ var _c = useChangeRequest(dcrUri), dcr = _c.dcr, groupedObjects = _c.groupedObjects;
19
+ var handleReviewDCR = useCallback(function () {
20
+ setIsReviewDCRDialogOpen(true);
21
+ }, []);
22
+ var handleCloseReviewDCRDialog = useCallback(function () {
23
+ setIsReviewDCRDialogOpen(false);
24
+ }, []);
25
+ var showReviewDCRButton = reviewDCREnabled && assignee == username;
26
+ var showReviewDialog = isReviewDCRDialogOpen && (showReviewDCRButton || reviewDCREnabled);
27
+ var customActionsSlot = useMemo(function () { return showReviewDCRButton && React.createElement(ReviewDCRButton, { onClick: handleReviewDCR }); }, [showReviewDCRButton, handleReviewDCR]);
28
+ return (React.createElement(React.Fragment, null,
29
+ React.createElement(GenericWorkflowTaskCard, { task: task, Icon: DcrTaskIcon, customActionsSlot: customActionsSlot }, dcr &&
30
+ groupedObjects.map(function (object, index) { return (React.createElement(LineDecorator, { key: index, last: index === groupedObjects.length - 1, divider: true },
31
+ React.createElement(AttributesChanges, { entityInfo: object.entity, relationsInfo: object.relations, changes: dcr.changes, objectsInfo: dcr.objectsInfo, dcrUri: dcrUri }))); })),
32
+ showReviewDialog && (React.createElement(ReviewDCRDialog, { open: isReviewDCRDialogOpen, onClose: handleCloseReviewDCRDialog, dcr: dcr, groupedObjects: groupedObjects, task: task }))));
16
33
  };
@@ -60,12 +60,15 @@ import userEvent from '@testing-library/user-event';
60
60
  import moment from 'moment';
61
61
  import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
62
62
  import { AdapterMoment } from '@mui/x-date-pickers/AdapterMoment';
63
- import { DCROperationTypes, DCRTypes, getDataChangeRequest, getEntitiesByUris } from '@reltio/mdm-sdk';
64
- import { useMdmMetadata } from '../../../../../contexts/MdmModuleContext';
63
+ import { DCROperationTypes, DCRTypes, getDataChangeRequest, getEntitiesByUris, runTaskAction } from '@reltio/mdm-sdk';
64
+ import { MdmModuleProvider, useMdmMetadata } from '../../../../../contexts/MdmModuleContext';
65
65
  import { CommentDialogProvider } from '../../../../../contexts/CommentDialogContext';
66
66
  import { DataChangeRequestTaskCard } from './DataChangeRequestTaskCard';
67
- jest.mock('@reltio/mdm-sdk', function () { return (__assign(__assign({}, jest.requireActual('@reltio/mdm-sdk')), { getDataChangeRequest: jest.fn(), getEntitiesByUris: jest.fn() })); });
67
+ import { WorkflowTasksContext } from '../../../../../contexts/WorkflowTasksContext';
68
+ jest.mock('@reltio/mdm-sdk', function () { return (__assign(__assign({}, jest.requireActual('@reltio/mdm-sdk')), { getDataChangeRequest: jest.fn(), getEntitiesByUris: jest.fn(), runTaskAction: jest.fn() })); });
68
69
  jest.mock('../../../../../contexts/MdmModuleContext', function () { return (__assign(__assign({}, jest.requireActual('../../../../../contexts/MdmModuleContext')), { useMdmMetadata: jest.fn() })); });
70
+ var onActionSuccess = jest.fn();
71
+ var workflowTaskContextValue = { onActionSuccess: onActionSuccess };
69
72
  describe('DataChangeRequestTaskCard tests', function () {
70
73
  var _a, _b;
71
74
  var metadata = {
@@ -175,7 +178,7 @@ describe('DataChangeRequestTaskCard tests', function () {
175
178
  var dcrUri = "changeRequests/".concat(dcrId);
176
179
  var dueDate = 1731825314640;
177
180
  var newStartDate = moment('11/15/2024', 'MM/DD/YYYY').valueOf();
178
- var task = {
181
+ var defaultTask = {
179
182
  assignee: userName,
180
183
  processInstanceId: '60260030',
181
184
  processType: 'dataChangeRequestReview',
@@ -255,17 +258,32 @@ describe('DataChangeRequestTaskCard tests', function () {
255
258
  label: relationEntityLabel
256
259
  }
257
260
  ];
258
- var setUp = function () {
261
+ var tenant = { id: 't1', name: 't1' };
262
+ var workflowPath = 'workflowPath';
263
+ var workflowEnvironmentUrl = 'workflowEnvironmentUrl';
264
+ var mdmValues = {
265
+ user: {
266
+ username: userName
267
+ },
268
+ tenant: tenant,
269
+ workflowPath: workflowPath,
270
+ workflowEnvironmentUrl: workflowEnvironmentUrl
271
+ };
272
+ var setUp = function (_a) {
273
+ var _b = _a === void 0 ? {} : _a, _c = _b.task, task = _c === void 0 ? defaultTask : _c;
259
274
  var user = userEvent.setup();
260
275
  var Providers = function (_a) {
261
276
  var children = _a.children;
262
- return (React.createElement(LocalizationProvider, { dateAdapter: AdapterMoment },
263
- React.createElement(CommentDialogProvider, null, children)));
277
+ return (React.createElement(MdmModuleProvider, { values: mdmValues },
278
+ React.createElement(LocalizationProvider, { dateAdapter: AdapterMoment },
279
+ React.createElement(WorkflowTasksContext.Provider, { value: workflowTaskContextValue },
280
+ React.createElement(CommentDialogProvider, null, children)))));
264
281
  };
265
282
  return __assign(__assign({}, render(React.createElement(DataChangeRequestTaskCard, { task: task }), { wrapper: Providers })), { user: user });
266
283
  };
267
284
  beforeAll(function () {
268
285
  getEntitiesByUris.mockResolvedValue(entities);
286
+ runTaskAction.mockResolvedValue(null);
269
287
  });
270
288
  beforeEach(function () {
271
289
  useMdmMetadata.mockReturnValue(metadata);
@@ -512,4 +530,61 @@ describe('DataChangeRequestTaskCard tests', function () {
512
530
  }
513
531
  });
514
532
  }); });
533
+ describe('Required comments', function () {
534
+ it('should show comment dialog when user runs action and comment is required', function () { return __awaiter(void 0, void 0, void 0, function () {
535
+ var task, user, dialog, comment, commentInput;
536
+ return __generator(this, function (_a) {
537
+ switch (_a.label) {
538
+ case 0:
539
+ task = __assign(__assign({}, defaultTask), { possibleActions: [
540
+ {
541
+ action: 'Approve',
542
+ label: 'Approve',
543
+ commentRequired: true
544
+ },
545
+ {
546
+ action: 'Reject',
547
+ label: 'Reject',
548
+ commentRequired: false
549
+ }
550
+ ] });
551
+ getDataChangeRequest.mockResolvedValue(dcr);
552
+ user = setUp({ task: task }).user;
553
+ return [4 /*yield*/, user.click(screen.getByTestId('task-actions'))];
554
+ case 1:
555
+ _a.sent();
556
+ return [4 /*yield*/, user.click(screen.getByText(task.possibleActions[0].label))];
557
+ case 2:
558
+ _a.sent();
559
+ expect(runTaskAction).not.toHaveBeenCalled();
560
+ dialog = screen.getAllByRole('presentation')[1];
561
+ expect(within(dialog).getByText('Please provide a comment for your action')).toBeInTheDocument();
562
+ expect(within(dialog).getByText('Type a comment')).toBeInTheDocument();
563
+ expect(within(dialog).getByText('Cancel')).toBeInTheDocument();
564
+ expect(within(dialog).getByText('Done')).toBeInTheDocument();
565
+ comment = 'Some comment';
566
+ commentInput = screen.getAllByRole('textbox')[0];
567
+ return [4 /*yield*/, user.click(commentInput)];
568
+ case 3:
569
+ _a.sent();
570
+ return [4 /*yield*/, user.paste(comment)];
571
+ case 4:
572
+ _a.sent();
573
+ return [4 /*yield*/, user.click(within(dialog).getByText('Done'))];
574
+ case 5:
575
+ _a.sent();
576
+ expect(screen.queryByText('Please provide a comment for your action')).not.toBeInTheDocument();
577
+ expect(runTaskAction).toHaveBeenCalledWith({
578
+ workflowPath: workflowPath,
579
+ environment: workflowEnvironmentUrl,
580
+ tenant: tenant.id,
581
+ taskId: task.taskId,
582
+ action: task.possibleActions[0].action,
583
+ processInstanceComment: comment
584
+ });
585
+ return [2 /*return*/];
586
+ }
587
+ });
588
+ }); });
589
+ });
515
590
  });
@@ -5,6 +5,7 @@ type Props = {
5
5
  children?: React.ReactNode;
6
6
  actions?: React.ReactNode;
7
7
  Icon?: React.ElementType;
8
+ customActionsSlot?: React.ReactNode;
8
9
  };
9
- export declare const GenericWorkflowTaskCard: ({ task, children, actions, Icon }: Props) => React.JSX.Element;
10
+ export declare const GenericWorkflowTaskCard: ({ task, children, actions, Icon, customActionsSlot }: Props) => React.JSX.Element;
10
11
  export {};
@@ -15,14 +15,13 @@ import { useWorkflowCheckPermission } from '../../../hooks/useWorkflowCheckPermi
15
15
  import CollaborationIcon from '../../../../../icons/CollaborationIcon';
16
16
  import { useWorkflowActions } from '../../../hooks/useWorkflowActions';
17
17
  import { getDCRId } from '../../../helpers/common';
18
- import { useStyles } from './styles';
18
+ import styles from './GenericWorkflowTaskCard.module.css';
19
19
  export var GenericWorkflowTaskCard = function (_a) {
20
20
  var _b;
21
- var task = _a.task, children = _a.children, actions = _a.actions, Icon = _a.Icon;
21
+ var task = _a.task, children = _a.children, actions = _a.actions, Icon = _a.Icon, customActionsSlot = _a.customActionsSlot;
22
22
  var taskId = task.taskId, dueDate = task.dueDate, priority = task.priority, assignee = task.assignee, createdBy = task.createdBy, createTime = task.createTime, step = task.displayName, processDefinitionDisplayName = task.processDefinitionDisplayName, objectURIs = task.objectURIs, processInstanceComments = task.processInstanceComments, possibleActions = task.possibleActions, isTaskOpen = task.isOpen, preferredAction = task.preferredAction;
23
23
  var dcrId = getDCRId(objectURIs);
24
24
  var color = useWorkflowColor({ processDefinitionDisplayName: processDefinitionDisplayName });
25
- var styles = useStyles({ color: color });
26
25
  var _c = useState(false), isExpanded = _c[0], setExpanded = _c[1];
27
26
  var checkWorkflowPermission = useWorkflowCheckPermission();
28
27
  var canViewComments = checkWorkflowPermission('VIEW_PROCESS_INSTANCE_COMMENTS');
@@ -34,7 +33,7 @@ export var GenericWorkflowTaskCard = function (_a) {
34
33
  }), workflowActions = _d.actions, actionRequestIsInProgress = _d.actionRequestIsInProgress;
35
34
  return (React.createElement("div", { className: styles.card },
36
35
  React.createElement("div", { className: classnames((_b = {}, _b[styles.withBackground] = isExpanded, _b)) },
37
- React.createElement("div", { className: styles.lineWrapper },
36
+ React.createElement("div", { className: styles.lineWrapper, style: { '--workflow-color': color } },
38
37
  React.createElement("div", { className: styles.line }),
39
38
  Icon && React.createElement(Icon, { className: styles.icon }),
40
39
  React.createElement(LineDecorator, { plain: true, first: true, transparent: !isExpanded },
@@ -65,9 +64,11 @@ export var GenericWorkflowTaskCard = function (_a) {
65
64
  i18n.text('Step'),
66
65
  ': ',
67
66
  React.createElement("span", { className: styles.infoValue }, step)),
68
- canViewComments && (processInstanceComments === null || processInstanceComments === void 0 ? void 0 : processInstanceComments.length) > 0 && (React.createElement("div", { className: styles.commentsInfo },
69
- React.createElement(CollaborationIcon, { className: styles.commentsIcon }),
70
- React.createElement("div", { className: styles.infoValue }, processInstanceComments.length)))),
67
+ React.createElement("div", { className: styles.bottomInfo },
68
+ canViewComments && (processInstanceComments === null || processInstanceComments === void 0 ? void 0 : processInstanceComments.length) > 0 && (React.createElement("div", { className: styles.commentsInfo },
69
+ React.createElement(CollaborationIcon, { className: styles.commentsIcon }),
70
+ React.createElement("div", { className: styles.infoValue }, processInstanceComments.length))),
71
+ customActionsSlot && (React.createElement("div", { className: styles.customActionsSlot }, customActionsSlot)))),
71
72
  actions || (React.createElement(TaskActions, { actions: workflowActions, isInProgress: actionRequestIsInProgress })))))),
72
73
  isExpanded && (React.createElement(LineDecorator, { plain: true },
73
74
  React.createElement("div", { className: styles.controlsBox },
@@ -0,0 +1,9 @@
1
+ const styles = {"card":"GenericWorkflowTaskCard-card--EMo-i","withBackground":"GenericWorkflowTaskCard-withBackground--Y--db","lineWrapper":"GenericWorkflowTaskCard-lineWrapper--15MN6","icon":"GenericWorkflowTaskCard-icon--eoHOp","line":"GenericWorkflowTaskCard-line--Z1Emv","info":"GenericWorkflowTaskCard-info--2OyKu","bottomInfo":"GenericWorkflowTaskCard-bottomInfo--4bsc4","commentsInfo":"GenericWorkflowTaskCard-commentsInfo--Q6M07","commentsIcon":"GenericWorkflowTaskCard-commentsIcon--crUiN","infoValue":"GenericWorkflowTaskCard-infoValue---gkaX","infoBlock":"GenericWorkflowTaskCard-infoBlock--VyI2O","header":"GenericWorkflowTaskCard-header--bN0nh","flex":"GenericWorkflowTaskCard-flex--5oWde","caption":"GenericWorkflowTaskCard-caption--vxnNJ","title":"GenericWorkflowTaskCard-title--zyCft","flag":"GenericWorkflowTaskCard-flag--dfydb","date":"GenericWorkflowTaskCard-date--MHd-G","mainInfo":"GenericWorkflowTaskCard-mainInfo--l5b9R","controlsBox":"GenericWorkflowTaskCard-controlsBox--ZHDhQ","controlsInRow":"GenericWorkflowTaskCard-controlsInRow--c48Nv","priority":"GenericWorkflowTaskCard-priority--xnnl9","comments":"GenericWorkflowTaskCard-comments--OG-db","customActionsSlot":"GenericWorkflowTaskCard-customActionsSlot--J-mXk"};
2
+ if (typeof document !== 'undefined') {
3
+ const head = document.head || document.getElementsByTagName('head')[0]
4
+ const style = document.createElement('style');
5
+ style.type = 'text/css'
6
+ style.innerHTML = `.GenericWorkflowTaskCard-card--EMo-i{border-bottom:1px solid rgba(0,0,0,.06)}.GenericWorkflowTaskCard-withBackground--Y--db{background-color:rgba(0,0,0,.03)}.GenericWorkflowTaskCard-lineWrapper--15MN6{position:relative}.GenericWorkflowTaskCard-icon--eoHOp{height:32px;left:16px;position:absolute;top:8px;width:32px;z-index:1}.GenericWorkflowTaskCard-line--Z1Emv{border-left:3px solid var(--workflow-color);bottom:0;left:0;position:absolute;top:0}.GenericWorkflowTaskCard-info--2OyKu{color:rgba(0,0,0,.54);font-size:13px;word-wrap:break-word;line-height:15px}.GenericWorkflowTaskCard-bottomInfo--4bsc4{align-items:flex-start;display:flex}.GenericWorkflowTaskCard-commentsInfo--Q6M07{align-items:center;display:flex;margin-bottom:-4px;margin-top:7px}.GenericWorkflowTaskCard-commentsIcon--crUiN{height:11px;margin-left:2px;margin-right:6px;margin-top:-2px;width:11px}.GenericWorkflowTaskCard-infoValue---gkaX{color:rgba(0,0,0,.87)}.GenericWorkflowTaskCard-infoBlock--VyI2O{display:flex;flex-direction:row;margin-bottom:5px}.GenericWorkflowTaskCard-header--bN0nh{display:flex;flex-direction:row;padding-bottom:12px}.GenericWorkflowTaskCard-flex--5oWde{flex:1}.GenericWorkflowTaskCard-caption--vxnNJ{color:rgba(0,0,0,.87);font-size:16px}.GenericWorkflowTaskCard-title--zyCft{align-items:center;display:flex;flex-direction:row;margin-bottom:-4px}.GenericWorkflowTaskCard-flag--dfydb{height:13px;width:13px;stroke:#000;fill:none;margin:2px 5px 0}.GenericWorkflowTaskCard-date--MHd-G{color:rgba(0,0,0,.87);font-size:13px}.GenericWorkflowTaskCard-mainInfo--l5b9R{display:flex;flex:1;flex-direction:column}.GenericWorkflowTaskCard-controlsBox--ZHDhQ{margin-bottom:12px;margin-right:16px;margin-top:13px}.GenericWorkflowTaskCard-controlsInRow--c48Nv{align-items:center;display:flex;flex-direction:row;justify-content:space-between;margin-bottom:20px}.GenericWorkflowTaskCard-priority--xnnl9{width:162px}.GenericWorkflowTaskCard-comments--OG-db{margin-left:11px}.GenericWorkflowTaskCard-customActionsSlot--J-mXk{display:flex;flex-grow:1;justify-content:flex-end;margin-right:-30px}`;
7
+ head.appendChild(style);
8
+ }
9
+ export default styles;
@@ -57,7 +57,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
57
57
  import React from 'react';
58
58
  import i18n from 'ui-i18n';
59
59
  import { identity } from 'ramda';
60
- import { render, screen } from '@testing-library/react';
60
+ import { render, screen, within } from '@testing-library/react';
61
61
  import userEvent from '@testing-library/user-event';
62
62
  import { createTheme } from '@mui/material/styles';
63
63
  import { ThemeProvider } from '@mui/styles';
@@ -71,6 +71,7 @@ import { CommentDialogProvider } from '../../../../../contexts/CommentDialogCont
71
71
  import { ErrorPopup } from '../../../../../ErrorPopup';
72
72
  import { getDefaultTask } from './task.test-data';
73
73
  import { GenericWorkflowTaskCard } from './GenericWorkflowTaskCard';
74
+ import { ReviewDCRButton } from '../../../ReviewDCRButton';
74
75
  jest.mock('@reltio/mdm-sdk', function () { return (__assign(__assign({}, jest.requireActual('@reltio/mdm-sdk')), { runTaskAction: jest.fn().mockReturnValue(Promise.resolve()), getAssigneeForTask: jest.fn().mockResolvedValue({ data: ['assignee1', 'assignee2'] }), addCommentForTask: jest.fn().mockResolvedValue({ status: 'success' }), getTaskById: jest.fn() })); });
75
76
  var onActionSuccess = jest.fn();
76
77
  var workflowTaskContextValue = { onActionSuccess: onActionSuccess };
@@ -102,14 +103,14 @@ var defaultMdmValues = {
102
103
  var errorSet = jest.fn();
103
104
  var defaultTask = getDefaultTask();
104
105
  var setUp = function (_a) {
105
- var _b = _a === void 0 ? {} : _a, _c = _b.mdmValues, mdmValues = _c === void 0 ? defaultMdmValues : _c, _d = _b.task, task = _d === void 0 ? defaultTask : _d;
106
+ var _b = _a === void 0 ? {} : _a, _c = _b.mdmValues, mdmValues = _c === void 0 ? defaultMdmValues : _c, _d = _b.task, task = _d === void 0 ? defaultTask : _d, customActionsSlot = _b.customActionsSlot;
106
107
  var user = userEvent.setup();
107
108
  return __assign(__assign({}, render(React.createElement(MdmModuleProvider, { values: mdmValues, actions: { errorSet: errorSet } },
108
109
  React.createElement(ThemeProvider, { theme: createTheme(theme) },
109
110
  React.createElement(LocalizationProvider, { dateAdapter: AdapterMoment },
110
111
  React.createElement(CommentDialogProvider, null,
111
112
  React.createElement(WorkflowTasksContext.Provider, { value: workflowTaskContextValue },
112
- React.createElement(GenericWorkflowTaskCard, { task: task },
113
+ React.createElement(GenericWorkflowTaskCard, { task: task, customActionsSlot: customActionsSlot },
113
114
  React.createElement("div", { className: "someChildren" }, "some children")),
114
115
  React.createElement(ErrorPopup, { showErrorFromStore: true })))))))), { user: user });
115
116
  };
@@ -451,4 +452,125 @@ describe('GenericWorkflowTaskCard tests', function () {
451
452
  }
452
453
  });
453
454
  }); });
455
+ it('should render custom actions slot if it is provided', function () { return __awaiter(void 0, void 0, void 0, function () {
456
+ var openReviewDialog, user, reviewDCRButton;
457
+ return __generator(this, function (_a) {
458
+ switch (_a.label) {
459
+ case 0:
460
+ openReviewDialog = jest.fn();
461
+ user = setUp({ customActionsSlot: React.createElement(ReviewDCRButton, { onClick: openReviewDialog }) }).user;
462
+ reviewDCRButton = screen.getByRole('button', { name: 'Review DCR' });
463
+ expect(reviewDCRButton).toBeInTheDocument();
464
+ return [4 /*yield*/, user.click(reviewDCRButton)];
465
+ case 1:
466
+ _a.sent();
467
+ expect(openReviewDialog).toHaveBeenCalled();
468
+ return [2 /*return*/];
469
+ }
470
+ });
471
+ }); });
472
+ describe('Required comments', function () {
473
+ it('should show comment dialog when user runs action and comment is required', function () { return __awaiter(void 0, void 0, void 0, function () {
474
+ var task, user, dialog, comment, commentInput;
475
+ return __generator(this, function (_a) {
476
+ switch (_a.label) {
477
+ case 0:
478
+ task = __assign(__assign({}, defaultTask), { possibleActions: [
479
+ {
480
+ action: 'Delete',
481
+ label: 'Delete',
482
+ commentRequired: true
483
+ },
484
+ {
485
+ action: 'Cancel',
486
+ label: 'Cancel',
487
+ commentRequired: false
488
+ }
489
+ ] });
490
+ user = setUp({ task: task }).user;
491
+ return [4 /*yield*/, user.click(screen.getByTestId('task-actions'))];
492
+ case 1:
493
+ _a.sent();
494
+ return [4 /*yield*/, user.click(screen.getByText(task.possibleActions[0].label))];
495
+ case 2:
496
+ _a.sent();
497
+ expect(runTaskAction).not.toHaveBeenCalled();
498
+ dialog = screen.getAllByRole('presentation')[1];
499
+ expect(within(dialog).getByText('Please provide a comment for your action')).toBeInTheDocument();
500
+ expect(within(dialog).getByText('Type a comment')).toBeInTheDocument();
501
+ expect(within(dialog).getByText('Cancel')).toBeInTheDocument();
502
+ expect(within(dialog).getByText('Done')).toBeInTheDocument();
503
+ comment = 'comment';
504
+ commentInput = screen.getAllByRole('textbox')[0];
505
+ return [4 /*yield*/, user.click(commentInput)];
506
+ case 3:
507
+ _a.sent();
508
+ return [4 /*yield*/, user.paste(comment)];
509
+ case 4:
510
+ _a.sent();
511
+ return [4 /*yield*/, user.click(within(screen.getAllByRole('presentation')[1]).getByText('Done'))];
512
+ case 5:
513
+ _a.sent();
514
+ expect(runTaskAction).toHaveBeenCalledWith({
515
+ workflowPath: workflowPath,
516
+ environment: workflowEnvironmentUrl,
517
+ tenant: tenant.id,
518
+ taskId: defaultTask.taskId,
519
+ action: defaultTask.possibleActions[0].action,
520
+ processInstanceComment: comment
521
+ });
522
+ return [2 /*return*/];
523
+ }
524
+ });
525
+ }); });
526
+ it('should not show comment dialog when user types comment and run action', function () { return __awaiter(void 0, void 0, void 0, function () {
527
+ var task, user, comment, commentInput;
528
+ var _a;
529
+ return __generator(this, function (_b) {
530
+ switch (_b.label) {
531
+ case 0:
532
+ task = __assign(__assign({}, defaultTask), { possibleActions: [
533
+ {
534
+ action: 'Delete',
535
+ label: 'Delete',
536
+ commentRequired: true
537
+ },
538
+ {
539
+ action: 'Cancel',
540
+ label: 'Cancel',
541
+ commentRequired: false
542
+ }
543
+ ] });
544
+ user = setUp({ task: task }).user;
545
+ return [4 /*yield*/, user.click(screen.getByTestId('collapse-button'))];
546
+ case 1:
547
+ _b.sent();
548
+ comment = 'comment';
549
+ commentInput = screen.getByPlaceholderText('Write a comment');
550
+ return [4 /*yield*/, user.click(commentInput)];
551
+ case 2:
552
+ _b.sent();
553
+ return [4 /*yield*/, user.paste(comment)];
554
+ case 3:
555
+ _b.sent();
556
+ return [4 /*yield*/, user.click(screen.getByRole('button', { name: (_a = task.preferredAction) === null || _a === void 0 ? void 0 : _a.label }))];
557
+ case 4:
558
+ _b.sent();
559
+ return [4 /*yield*/, user.click(screen.getByTestId("reltio-profile-select-mode-".concat(task.possibleActions[0].label)))];
560
+ case 5:
561
+ _b.sent();
562
+ expect(screen.queryByText('Please provide a comment for your action')).not.toBeInTheDocument();
563
+ expect(runTaskAction).toHaveBeenCalledWith({
564
+ workflowPath: workflowPath,
565
+ environment: workflowEnvironmentUrl,
566
+ tenant: tenant.id,
567
+ taskId: defaultTask.taskId,
568
+ action: defaultTask.possibleActions[0].action,
569
+ processInstanceComment: comment
570
+ });
571
+ return [2 /*return*/];
572
+ }
573
+ });
574
+ }); });
575
+ });
454
576
  });
@@ -46,25 +46,32 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
46
46
  }
47
47
  };
48
48
  import React from 'react';
49
- import { render, screen } from '@testing-library/react';
49
+ import { render, screen, within } from '@testing-library/react';
50
50
  import userEvent from '@testing-library/user-event';
51
- import { ActivityFilter } from '@reltio/mdm-sdk';
51
+ import { ActivityFilter, runTaskAction } from '@reltio/mdm-sdk';
52
52
  import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
53
53
  import { AdapterMoment } from '@mui/x-date-pickers/AdapterMoment';
54
54
  import { MdmModuleProvider } from '../../../../../contexts/MdmModuleContext';
55
55
  import { CommentDialogProvider } from '../../../../../contexts/CommentDialogContext';
56
56
  import { PotentialMatchTaskCard } from './PotentialMatchTaskCard';
57
+ jest.mock('@reltio/mdm-sdk', function () { return (__assign(__assign({}, jest.requireActual('@reltio/mdm-sdk')), { runTaskAction: jest.fn() })); });
57
58
  describe('PotentialMatchTaskCard tests', function () {
59
+ var tenant = { id: 't1', name: 't1' };
60
+ var workflowPath = 'workflowPath';
61
+ var workflowEnvironmentUrl = 'workflowEnvironmentUrl';
58
62
  var mdmValues = {
59
63
  metadata: { entityTypes: [], relationTypes: [] },
60
64
  entity: { uri: 'entities/uri1', type: 'configuration/entityTypes/HCO' },
61
- tenant: { id: 't1', name: 't1' },
65
+ tenant: tenant,
66
+ workflowPath: workflowPath,
67
+ workflowEnvironmentUrl: workflowEnvironmentUrl,
68
+ user: { username: 'egorshkov' },
62
69
  dtssPath: 'path',
63
70
  dataTenants: [],
64
71
  activityFilter: ActivityFilter.ACTIVE_ONLY
65
72
  };
66
73
  var relatedEntityUri = 'entities/6hj8baQ';
67
- var task = {
74
+ var defaultTask = {
68
75
  assignee: 'egorshkov',
69
76
  objectURIs: [relatedEntityUri, 'entities/1RdgehCi'],
70
77
  createdBy: 'egorshkov',
@@ -98,7 +105,7 @@ describe('PotentialMatchTaskCard tests', function () {
98
105
  uri: 'entities/6hj8baQ'
99
106
  }
100
107
  };
101
- var defaultProps = { task: task, match: match, entitiesMap: entitiesMap };
108
+ var defaultProps = { task: defaultTask, match: match, entitiesMap: entitiesMap };
102
109
  var setUp = function (props) {
103
110
  if (props === void 0) { props = {}; }
104
111
  var user = userEvent.setup();
@@ -110,6 +117,9 @@ describe('PotentialMatchTaskCard tests', function () {
110
117
  };
111
118
  return __assign({ user: user }, render(React.createElement(PotentialMatchTaskCard, __assign({}, defaultProps, props)), { wrapper: Providers }));
112
119
  };
120
+ beforeAll(function () {
121
+ runTaskAction.mockResolvedValue(null);
122
+ });
113
123
  afterEach(function () {
114
124
  jest.clearAllMocks();
115
125
  });
@@ -158,4 +168,60 @@ describe('PotentialMatchTaskCard tests', function () {
158
168
  }
159
169
  });
160
170
  }); });
171
+ describe('Required comments', function () {
172
+ it('should show comment dialog when user runs action and comment is required', function () { return __awaiter(void 0, void 0, void 0, function () {
173
+ var task, user, dialog, comment, commentInput;
174
+ return __generator(this, function (_a) {
175
+ switch (_a.label) {
176
+ case 0:
177
+ task = __assign(__assign({}, defaultTask), { isOpen: true, possibleActions: [
178
+ {
179
+ action: 'Approve',
180
+ label: 'Approve',
181
+ commentRequired: true
182
+ },
183
+ {
184
+ action: 'Reject',
185
+ label: 'Reject',
186
+ commentRequired: false
187
+ }
188
+ ] });
189
+ user = setUp({ task: task }).user;
190
+ return [4 /*yield*/, user.click(screen.getByTestId('task-actions'))];
191
+ case 1:
192
+ _a.sent();
193
+ return [4 /*yield*/, user.click(screen.getByText(task.possibleActions[0].label))];
194
+ case 2:
195
+ _a.sent();
196
+ expect(runTaskAction).not.toHaveBeenCalled();
197
+ dialog = screen.getAllByRole('presentation')[1];
198
+ expect(within(dialog).getByText('Please provide a comment for your action')).toBeInTheDocument();
199
+ expect(within(dialog).getByText('Type a comment')).toBeInTheDocument();
200
+ expect(within(dialog).getByText('Cancel')).toBeInTheDocument();
201
+ expect(within(dialog).getByText('Done')).toBeInTheDocument();
202
+ comment = 'Some comment';
203
+ commentInput = screen.getAllByRole('textbox')[0];
204
+ return [4 /*yield*/, user.click(commentInput)];
205
+ case 3:
206
+ _a.sent();
207
+ return [4 /*yield*/, user.paste(comment)];
208
+ case 4:
209
+ _a.sent();
210
+ return [4 /*yield*/, user.click(within(dialog).getByText('Done'))];
211
+ case 5:
212
+ _a.sent();
213
+ expect(screen.queryByText('Please provide a comment for your action')).not.toBeInTheDocument();
214
+ expect(runTaskAction).toHaveBeenCalledWith({
215
+ workflowPath: workflowPath,
216
+ environment: workflowEnvironmentUrl,
217
+ tenant: tenant.id,
218
+ taskId: task.taskId,
219
+ action: task.possibleActions[0].action,
220
+ processInstanceComment: comment
221
+ });
222
+ return [2 /*return*/];
223
+ }
224
+ });
225
+ }); });
226
+ });
161
227
  });
@@ -5,6 +5,8 @@ export { AssigneeSelector } from './AssigneeSelector';
5
5
  export { ReassignButton } from './ReassignButton';
6
6
  export { WorkflowComments } from './WorkflowComments';
7
7
  export { TaskActionButtons } from './TaskActionButtons';
8
+ export { ReviewDCRButton } from './ReviewDCRButton';
9
+ export { ReviewDCRDialog } from './ReviewDCRDialog';
8
10
  export { useWorkflowAssignee } from './hooks/useWorkflowAssignee';
9
11
  export { useWorkflowComments } from './hooks/useWorkflowComments';
10
12
  export { useWorkflowActions } from './hooks/useWorkflowActions';