@reltio/components 1.4.2181 → 1.4.2183
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.
- package/ActionButton/ActionButton.js +1 -1
- package/CommentDialog/CommentDialog.d.ts +14 -0
- package/CommentDialog/CommentDialog.js +43 -0
- package/CommentDialog/CommentDialog.module.css.js +9 -0
- package/cjs/ActionButton/ActionButton.js +1 -1
- package/cjs/CommentDialog/CommentDialog.d.ts +14 -0
- package/cjs/CommentDialog/CommentDialog.js +73 -0
- package/cjs/CommentDialog/CommentDialog.module.css.js +9 -0
- package/cjs/contexts/CommentDialogContext/index.d.ts +16 -0
- package/cjs/contexts/CommentDialogContext/index.js +68 -0
- package/cjs/contexts/WorkflowDefinitionsContext/index.d.ts +11 -0
- package/cjs/contexts/WorkflowDefinitionsContext/index.js +25 -0
- package/cjs/features/workflow/AddWorkflowDialog/AddWorkflowDialog.js +15 -11
- package/cjs/features/workflow/AddWorkflowDialog/AddWorkflowDialog.spec.js +10 -9
- package/cjs/features/workflow/AddWorkflowDialog/styles.d.ts +1 -1
- package/cjs/features/workflow/AddWorkflowDialog/styles.js +11 -4
- package/cjs/features/workflow/ReassignButton/components/ReassignDialog/styles.d.ts +1 -1
- package/cjs/features/workflow/TaskActionButtons/TaskActionButtons.spec.js +54 -1
- package/cjs/features/workflow/WorkflowTaskCard/WorkflowTaskCard.test.js +3 -1
- package/cjs/features/workflow/WorkflowTaskCard/components/DataChangeRequestTaskCard/DataChangeRequestTaskCard.spec.js +3 -1
- package/cjs/features/workflow/WorkflowTaskCard/components/GenericWorkflowTaskCard/GenericWorkflowTaskCard.spec.js +9 -7
- package/cjs/features/workflow/WorkflowTaskCard/components/PotentialMatchTaskCard/PotentialMatchTaskCard.spec.js +3 -1
- package/cjs/features/workflow/helpers/common.d.ts +2 -1
- package/cjs/features/workflow/helpers/common.js +3 -1
- package/cjs/features/workflow/hooks/useWorkflowActions.js +82 -22
- package/cjs/features/workflow/hooks/useWorkflowDefinitions.d.ts +7 -2
- package/cjs/features/workflow/hooks/useWorkflowDefinitions.js +20 -7
- package/cjs/features/workflow/index.d.ts +1 -0
- package/cjs/features/workflow/index.js +4 -1
- package/cjs/hooks/useRequestDCRReview/useRequestDCRReview.js +88 -17
- package/contexts/CommentDialogContext/index.d.ts +16 -0
- package/contexts/CommentDialogContext/index.js +40 -0
- package/contexts/WorkflowDefinitionsContext/index.d.ts +11 -0
- package/contexts/WorkflowDefinitionsContext/index.js +18 -0
- package/features/workflow/AddWorkflowDialog/AddWorkflowDialog.js +15 -11
- package/features/workflow/AddWorkflowDialog/AddWorkflowDialog.spec.js +10 -9
- package/features/workflow/AddWorkflowDialog/styles.d.ts +1 -1
- package/features/workflow/AddWorkflowDialog/styles.js +11 -4
- package/features/workflow/ReassignButton/components/ReassignDialog/styles.d.ts +1 -1
- package/features/workflow/TaskActionButtons/TaskActionButtons.spec.js +55 -2
- package/features/workflow/WorkflowTaskCard/WorkflowTaskCard.test.js +3 -1
- package/features/workflow/WorkflowTaskCard/components/DataChangeRequestTaskCard/DataChangeRequestTaskCard.spec.js +3 -1
- package/features/workflow/WorkflowTaskCard/components/GenericWorkflowTaskCard/GenericWorkflowTaskCard.spec.js +9 -7
- package/features/workflow/WorkflowTaskCard/components/PotentialMatchTaskCard/PotentialMatchTaskCard.spec.js +3 -1
- package/features/workflow/helpers/common.d.ts +2 -1
- package/features/workflow/helpers/common.js +2 -1
- package/features/workflow/hooks/useWorkflowActions.js +82 -22
- package/features/workflow/hooks/useWorkflowDefinitions.d.ts +7 -2
- package/features/workflow/hooks/useWorkflowDefinitions.js +22 -9
- package/features/workflow/index.d.ts +1 -0
- package/features/workflow/index.js +2 -0
- package/hooks/useRequestDCRReview/useRequestDCRReview.js +90 -19
- package/package.json +2 -2
|
@@ -56,7 +56,7 @@ import { theme } from '../../../constants';
|
|
|
56
56
|
import { MdmModuleProvider } from '../../../contexts/MdmModuleContext';
|
|
57
57
|
import { WorkflowTasksContext } from '../../../contexts/WorkflowTasksContext';
|
|
58
58
|
import { AddWorkflowDialog } from './AddWorkflowDialog';
|
|
59
|
-
jest.mock('@reltio/mdm-sdk', function () { return (__assign(__assign({}, jest.requireActual('@reltio/mdm-sdk')), { processDefinitions: jest.fn(), startProcessInstance: jest.fn() })); });
|
|
59
|
+
jest.mock('@reltio/mdm-sdk', function () { return (__assign(__assign({}, jest.requireActual('@reltio/mdm-sdk')), { processDefinitions: jest.fn(), startProcessInstance: jest.fn(), memoizeWith: jest.fn(function (keyFn, fn) { return fn; }) })); });
|
|
60
60
|
var tenant = { id: 'alenat', name: 'alenat' };
|
|
61
61
|
var workflowEnvironmentUrl = 'https://tst-01.reltio.com';
|
|
62
62
|
var workflowPath = 'https://tst-01-workflow.reltio.com/workflow-adapter';
|
|
@@ -131,7 +131,7 @@ describe('AddWorkflowDialog tests', function () {
|
|
|
131
131
|
});
|
|
132
132
|
}); });
|
|
133
133
|
it('should render Popover and selector correctly if anchorEl exists', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
134
|
-
var mockAnchorEl, props, user;
|
|
134
|
+
var mockAnchorEl, props, user, dropdown;
|
|
135
135
|
return __generator(this, function (_a) {
|
|
136
136
|
switch (_a.label) {
|
|
137
137
|
case 0:
|
|
@@ -142,10 +142,10 @@ describe('AddWorkflowDialog tests', function () {
|
|
|
142
142
|
};
|
|
143
143
|
user = setUp(props).user;
|
|
144
144
|
expect(screen.getByText('Add new workflow')).toBeInTheDocument();
|
|
145
|
-
|
|
145
|
+
dropdown = screen.getByRole('combobox');
|
|
146
|
+
return [4 /*yield*/, user.click(dropdown)];
|
|
146
147
|
case 1:
|
|
147
148
|
_a.sent();
|
|
148
|
-
expect(screen.getByText('RDM Data Change Request Review')).toBeInTheDocument();
|
|
149
149
|
expect(screen.getByText('Data Verification With Loop')).toBeInTheDocument();
|
|
150
150
|
expect(screen.getByText('Account onboarding')).toBeInTheDocument();
|
|
151
151
|
return [2 /*return*/];
|
|
@@ -165,13 +165,14 @@ describe('AddWorkflowDialog tests', function () {
|
|
|
165
165
|
};
|
|
166
166
|
user = setUp(props).user;
|
|
167
167
|
expect(screen.getByText('Add new workflow')).toBeInTheDocument();
|
|
168
|
-
return [4 /*yield*/, user.click(screen.
|
|
168
|
+
return [4 /*yield*/, user.click(screen.getByRole('combobox'))];
|
|
169
169
|
case 1:
|
|
170
170
|
_a.sent();
|
|
171
|
+
expect(screen.getByText('RDM Data Change Request Review')).toBeInTheDocument();
|
|
171
172
|
return [4 /*yield*/, user.click(screen.getByText('RDM Data Change Request Review'))];
|
|
172
173
|
case 2:
|
|
173
174
|
_a.sent();
|
|
174
|
-
comment = screen.
|
|
175
|
+
comment = screen.getByLabelText('Type a comment');
|
|
175
176
|
return [4 /*yield*/, user.type(comment, 'comment')];
|
|
176
177
|
case 3:
|
|
177
178
|
_a.sent();
|
|
@@ -210,13 +211,13 @@ describe('AddWorkflowDialog tests', function () {
|
|
|
210
211
|
};
|
|
211
212
|
user = setUp(props).user;
|
|
212
213
|
expect(screen.getByText('Add new workflow')).toBeInTheDocument();
|
|
213
|
-
return [4 /*yield*/, user.click(screen.
|
|
214
|
+
return [4 /*yield*/, user.click(screen.getByRole('combobox'))];
|
|
214
215
|
case 1:
|
|
215
216
|
_a.sent();
|
|
216
217
|
return [4 /*yield*/, user.click(screen.getByText('RDM Data Change Request Review'))];
|
|
217
218
|
case 2:
|
|
218
219
|
_a.sent();
|
|
219
|
-
comment = screen.
|
|
220
|
+
comment = screen.getByLabelText('Type a comment');
|
|
220
221
|
return [4 /*yield*/, user.type(comment, 'comment')];
|
|
221
222
|
case 3:
|
|
222
223
|
_a.sent();
|
|
@@ -251,7 +252,7 @@ describe('AddWorkflowDialog tests', function () {
|
|
|
251
252
|
anchorEl: mockAnchorEl
|
|
252
253
|
};
|
|
253
254
|
user = setUp(props).user;
|
|
254
|
-
return [4 /*yield*/, user.click(screen.
|
|
255
|
+
return [4 /*yield*/, user.click(screen.getByRole('combobox'))];
|
|
255
256
|
case 1:
|
|
256
257
|
_a.sent();
|
|
257
258
|
expect(consoleSpy).toHaveBeenCalledWith('Workflow error', 'Some error');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"content" | "title" | "footer" | "input" | "select" | "inputRoot" | "cancelButton" | "popoverPaper" | "simpleDropDownSelector">;
|
|
1
|
+
export declare const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"content" | "title" | "footer" | "input" | "select" | "inputRoot" | "asterisk" | "cancelButton" | "inputLabelRoot" | "popoverPaper" | "simpleDropDownSelector">;
|
|
@@ -9,20 +9,26 @@ export var useStyles = makeStyles(function (theme) { return ({
|
|
|
9
9
|
letterSpacing: '0.25px',
|
|
10
10
|
lineHeight: '24px',
|
|
11
11
|
color: theme.palette.text.primary,
|
|
12
|
-
marginBottom: '
|
|
12
|
+
marginBottom: '20px'
|
|
13
13
|
},
|
|
14
14
|
content: {
|
|
15
15
|
display: 'flex',
|
|
16
16
|
flexDirection: 'column',
|
|
17
|
-
padding: '
|
|
17
|
+
padding: '18px 16px 20px 16px'
|
|
18
18
|
},
|
|
19
19
|
simpleDropDownSelector: {
|
|
20
20
|
marginBottom: '20px'
|
|
21
21
|
},
|
|
22
22
|
inputRoot: {
|
|
23
|
-
paddingTop: '
|
|
23
|
+
paddingTop: '12px !important',
|
|
24
24
|
paddingBottom: '0 !important'
|
|
25
25
|
},
|
|
26
|
+
inputLabelRoot: {
|
|
27
|
+
fontSize: '14px'
|
|
28
|
+
},
|
|
29
|
+
asterisk: {
|
|
30
|
+
color: 'red'
|
|
31
|
+
},
|
|
26
32
|
select: {
|
|
27
33
|
fontSize: '14px'
|
|
28
34
|
},
|
|
@@ -36,6 +42,7 @@ export var useStyles = makeStyles(function (theme) { return ({
|
|
|
36
42
|
marginRight: '8px'
|
|
37
43
|
},
|
|
38
44
|
input: {
|
|
39
|
-
fontSize: '14px'
|
|
45
|
+
fontSize: '14px',
|
|
46
|
+
paddingBottom: '5px'
|
|
40
47
|
}
|
|
41
48
|
}); });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"caption" | "disabled" | "title" | "currentAssignee" | "
|
|
1
|
+
export declare const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"caption" | "disabled" | "title" | "currentAssignee" | "dialogContent" | "dialogText">;
|
|
@@ -47,11 +47,12 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
47
47
|
};
|
|
48
48
|
import React from 'react';
|
|
49
49
|
import { runTaskAction } from '@reltio/mdm-sdk';
|
|
50
|
-
import { render, screen } from '@testing-library/react';
|
|
50
|
+
import { render, screen, within } from '@testing-library/react';
|
|
51
51
|
import userEvent from '@testing-library/user-event';
|
|
52
52
|
import { TaskActionButtons } from '../TaskActionButtons';
|
|
53
53
|
import { WorkflowTasksContext } from '../../../contexts/WorkflowTasksContext';
|
|
54
54
|
import { MdmModuleProvider } from '../../../contexts/MdmModuleContext';
|
|
55
|
+
import { CommentDialogProvider } from '../../../contexts/CommentDialogContext';
|
|
55
56
|
jest.mock('@reltio/mdm-sdk', function () { return (__assign(__assign({}, jest.requireActual('@reltio/mdm-sdk')), { runTaskAction: jest.fn() })); });
|
|
56
57
|
var task = {
|
|
57
58
|
assignee: 'somebody',
|
|
@@ -92,7 +93,8 @@ var setUp = function (props) {
|
|
|
92
93
|
var Providers = function (_a) {
|
|
93
94
|
var children = _a.children;
|
|
94
95
|
return (React.createElement(WorkflowTasksContext.Provider, { value: workflowTaskContextValue },
|
|
95
|
-
React.createElement(
|
|
96
|
+
React.createElement(CommentDialogProvider, null,
|
|
97
|
+
React.createElement(MdmModuleProvider, { values: mdmValues }, children))));
|
|
96
98
|
};
|
|
97
99
|
return __assign(__assign({}, render(React.createElement(TaskActionButtons, __assign({}, props)), { wrapper: Providers })), { user: user });
|
|
98
100
|
};
|
|
@@ -132,4 +134,55 @@ describe('TaskActionButtons tests', function () {
|
|
|
132
134
|
}
|
|
133
135
|
});
|
|
134
136
|
}); });
|
|
137
|
+
describe('required comments', function () {
|
|
138
|
+
it('should show comment dialog if commentRequired is true', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
139
|
+
var task, user, dialog, textfield;
|
|
140
|
+
return __generator(this, function (_a) {
|
|
141
|
+
switch (_a.label) {
|
|
142
|
+
case 0:
|
|
143
|
+
task = __assign(__assign({}, defaultProps.task), { possibleActions: [
|
|
144
|
+
{ action: 'Approve', label: 'Approve', commentRequired: false },
|
|
145
|
+
{ action: 'Reject', label: 'Reject', commentRequired: true }
|
|
146
|
+
] });
|
|
147
|
+
user = setUp({ task: task }).user;
|
|
148
|
+
return [4 /*yield*/, user.click(screen.getByText('Reject'))];
|
|
149
|
+
case 1:
|
|
150
|
+
_a.sent();
|
|
151
|
+
expect(onActionSuccess).not.toHaveBeenCalledWith('Reject');
|
|
152
|
+
dialog = screen.getAllByRole('presentation')[1];
|
|
153
|
+
expect(within(dialog).getByText('Please provide a comment for your action')).toBeInTheDocument();
|
|
154
|
+
expect(within(dialog).getByText('Type a comment')).toBeInTheDocument();
|
|
155
|
+
expect(within(dialog).getByText('Cancel')).toBeInTheDocument();
|
|
156
|
+
expect(within(dialog).getByText('Done')).toBeInTheDocument();
|
|
157
|
+
return [4 /*yield*/, user.click(within(dialog).getByText('Cancel'))];
|
|
158
|
+
case 2:
|
|
159
|
+
_a.sent();
|
|
160
|
+
expect(onActionSuccess).not.toHaveBeenCalled();
|
|
161
|
+
return [4 /*yield*/, user.click(screen.getByText('Reject'))];
|
|
162
|
+
case 3:
|
|
163
|
+
_a.sent();
|
|
164
|
+
textfield = screen.getAllByRole('textbox')[0];
|
|
165
|
+
return [4 /*yield*/, user.click(textfield)];
|
|
166
|
+
case 4:
|
|
167
|
+
_a.sent();
|
|
168
|
+
return [4 /*yield*/, user.paste('test comment')];
|
|
169
|
+
case 5:
|
|
170
|
+
_a.sent();
|
|
171
|
+
return [4 /*yield*/, user.click(within(screen.getAllByRole('presentation')[1]).getByText('Done'))];
|
|
172
|
+
case 6:
|
|
173
|
+
_a.sent();
|
|
174
|
+
expect(onActionSuccess).toHaveBeenCalledWith('Reject');
|
|
175
|
+
expect(runTaskAction).toHaveBeenCalledWith({
|
|
176
|
+
taskId: '38453993',
|
|
177
|
+
workflowPath: 'workflowPath',
|
|
178
|
+
environment: 'workflowEnvironmentURL',
|
|
179
|
+
tenant: 't1',
|
|
180
|
+
action: 'Reject',
|
|
181
|
+
processInstanceComment: 'test comment'
|
|
182
|
+
});
|
|
183
|
+
return [2 /*return*/];
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
}); });
|
|
187
|
+
});
|
|
135
188
|
});
|
|
@@ -62,6 +62,7 @@ import { WorkflowTaskCard } from './WorkflowTaskCard';
|
|
|
62
62
|
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
|
|
63
63
|
import { AdapterMoment } from '@mui/x-date-pickers/AdapterMoment';
|
|
64
64
|
import { MdmModuleProvider } from '../../../contexts/MdmModuleContext';
|
|
65
|
+
import { CommentDialogProvider } from '../../../contexts/CommentDialogContext';
|
|
65
66
|
jest.mock('@reltio/mdm-sdk', function () { return (__assign(__assign({}, jest.requireActual('@reltio/mdm-sdk')), { getDataChangeRequest: jest.fn(), getEntitiesByUris: jest.fn() })); });
|
|
66
67
|
jest.mock('../../../icons/DefaultTaskIcon', function () {
|
|
67
68
|
var MockDefaultTaskIcon = function () { return React.createElement("div", { "data-reltio-id": "default-task-icon" }); };
|
|
@@ -97,7 +98,8 @@ describe('WorkflowTaskCard tests', function () {
|
|
|
97
98
|
var Providers = function (_a) {
|
|
98
99
|
var children = _a.children;
|
|
99
100
|
return (React.createElement(LocalizationProvider, { dateAdapter: AdapterMoment },
|
|
100
|
-
React.createElement(
|
|
101
|
+
React.createElement(CommentDialogProvider, null,
|
|
102
|
+
React.createElement(MdmModuleProvider, { values: mdmValues }, children))));
|
|
101
103
|
};
|
|
102
104
|
return __assign({ user: user }, render(React.createElement(WorkflowTaskCard, { task: __assign(__assign({}, defaultTask), task) }), { wrapper: Providers }));
|
|
103
105
|
};
|
|
@@ -62,6 +62,7 @@ import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
|
|
|
62
62
|
import { AdapterMoment } from '@mui/x-date-pickers/AdapterMoment';
|
|
63
63
|
import { DCROperationTypes, DCRTypes, getDataChangeRequest, getEntitiesByUris } from '@reltio/mdm-sdk';
|
|
64
64
|
import { useMdmMetadata } from '../../../../../contexts/MdmModuleContext';
|
|
65
|
+
import { CommentDialogProvider } from '../../../../../contexts/CommentDialogContext';
|
|
65
66
|
import { DataChangeRequestTaskCard } from './DataChangeRequestTaskCard';
|
|
66
67
|
jest.mock('@reltio/mdm-sdk', function () { return (__assign(__assign({}, jest.requireActual('@reltio/mdm-sdk')), { getDataChangeRequest: jest.fn(), getEntitiesByUris: jest.fn() })); });
|
|
67
68
|
jest.mock('../../../../../contexts/MdmModuleContext', function () { return (__assign(__assign({}, jest.requireActual('../../../../../contexts/MdmModuleContext')), { useMdmMetadata: jest.fn() })); });
|
|
@@ -258,7 +259,8 @@ describe('DataChangeRequestTaskCard tests', function () {
|
|
|
258
259
|
var user = userEvent.setup();
|
|
259
260
|
var Providers = function (_a) {
|
|
260
261
|
var children = _a.children;
|
|
261
|
-
return (React.createElement(LocalizationProvider, { dateAdapter: AdapterMoment },
|
|
262
|
+
return (React.createElement(LocalizationProvider, { dateAdapter: AdapterMoment },
|
|
263
|
+
React.createElement(CommentDialogProvider, null, children)));
|
|
262
264
|
};
|
|
263
265
|
return __assign(__assign({}, render(React.createElement(DataChangeRequestTaskCard, { task: task }), { wrapper: Providers })), { user: user });
|
|
264
266
|
};
|
|
@@ -67,6 +67,7 @@ import { runTaskAction, getTaskById, addCommentForTask } from '@reltio/mdm-sdk';
|
|
|
67
67
|
import { theme } from '../../../../../constants';
|
|
68
68
|
import { MdmModuleProvider } from '../../../../../contexts/MdmModuleContext';
|
|
69
69
|
import { WorkflowTasksContext } from '../../../../../contexts/WorkflowTasksContext';
|
|
70
|
+
import { CommentDialogProvider } from '../../../../../contexts/CommentDialogContext';
|
|
70
71
|
import { ErrorPopup } from '../../../../../ErrorPopup';
|
|
71
72
|
import { getDefaultTask } from './task.test-data';
|
|
72
73
|
import { GenericWorkflowTaskCard } from './GenericWorkflowTaskCard';
|
|
@@ -106,10 +107,11 @@ var setUp = function (_a) {
|
|
|
106
107
|
return __assign(__assign({}, render(React.createElement(MdmModuleProvider, { values: mdmValues, actions: { errorSet: errorSet } },
|
|
107
108
|
React.createElement(ThemeProvider, { theme: createTheme(theme) },
|
|
108
109
|
React.createElement(LocalizationProvider, { dateAdapter: AdapterMoment },
|
|
109
|
-
React.createElement(
|
|
110
|
-
React.createElement(
|
|
111
|
-
React.createElement(
|
|
112
|
-
|
|
110
|
+
React.createElement(CommentDialogProvider, null,
|
|
111
|
+
React.createElement(WorkflowTasksContext.Provider, { value: workflowTaskContextValue },
|
|
112
|
+
React.createElement(GenericWorkflowTaskCard, { task: task },
|
|
113
|
+
React.createElement("div", { className: "someChildren" }, "some children")),
|
|
114
|
+
React.createElement(ErrorPopup, { showErrorFromStore: true })))))))), { user: user });
|
|
113
115
|
};
|
|
114
116
|
var checkAlwaysVisibleElements = function (task) {
|
|
115
117
|
var processDefinitionDisplayName = task.processDefinitionDisplayName, createdBy = task.createdBy, createTime = task.createTime, dueDate = task.dueDate, displayName = task.displayName;
|
|
@@ -300,7 +302,7 @@ describe('GenericWorkflowTaskCard tests', function () {
|
|
|
300
302
|
tenant: tenant.id,
|
|
301
303
|
taskId: defaultTask.taskId,
|
|
302
304
|
action: defaultTask.possibleActions[1].action,
|
|
303
|
-
processInstanceComment:
|
|
305
|
+
processInstanceComment: null
|
|
304
306
|
});
|
|
305
307
|
expect(onActionSuccess).toHaveBeenCalledWith(defaultTask.possibleActions[1].action);
|
|
306
308
|
return [2 /*return*/];
|
|
@@ -325,7 +327,7 @@ describe('GenericWorkflowTaskCard tests', function () {
|
|
|
325
327
|
tenant: tenant.id,
|
|
326
328
|
taskId: defaultTask.taskId,
|
|
327
329
|
action: defaultTask.possibleActions[1].action,
|
|
328
|
-
processInstanceComment:
|
|
330
|
+
processInstanceComment: null
|
|
329
331
|
});
|
|
330
332
|
expect(onActionSuccess).toHaveBeenCalledWith(defaultTask.possibleActions[1].action);
|
|
331
333
|
return [2 /*return*/];
|
|
@@ -370,7 +372,7 @@ describe('GenericWorkflowTaskCard tests', function () {
|
|
|
370
372
|
tenant: tenant.id,
|
|
371
373
|
taskId: defaultTask.taskId,
|
|
372
374
|
action: defaultTask.possibleActions[1].action,
|
|
373
|
-
processInstanceComment:
|
|
375
|
+
processInstanceComment: null
|
|
374
376
|
});
|
|
375
377
|
expect(onActionSuccess).not.toHaveBeenCalled();
|
|
376
378
|
expect(screen.getByText('Error')).toBeInTheDocument();
|
|
@@ -52,6 +52,7 @@ import { ActivityFilter } 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
|
+
import { CommentDialogProvider } from '../../../../../contexts/CommentDialogContext';
|
|
55
56
|
import { PotentialMatchTaskCard } from './PotentialMatchTaskCard';
|
|
56
57
|
describe('PotentialMatchTaskCard tests', function () {
|
|
57
58
|
var mdmValues = {
|
|
@@ -104,7 +105,8 @@ describe('PotentialMatchTaskCard tests', function () {
|
|
|
104
105
|
var Providers = function (_a) {
|
|
105
106
|
var children = _a.children;
|
|
106
107
|
return (React.createElement(LocalizationProvider, { dateAdapter: AdapterMoment },
|
|
107
|
-
React.createElement(
|
|
108
|
+
React.createElement(CommentDialogProvider, null,
|
|
109
|
+
React.createElement(MdmModuleProvider, { values: mdmValues }, children))));
|
|
108
110
|
};
|
|
109
111
|
return __assign({ user: user }, render(React.createElement(PotentialMatchTaskCard, __assign({}, defaultProps, props)), { wrapper: Providers }));
|
|
110
112
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AttributeType, DCRAttributeValue, DCRObjectsInfo, DCROperationTypes, DCRValue, WorkflowTaskData } from '@reltio/mdm-sdk';
|
|
1
|
+
import { AttributeType, DCRAttributeValue, DCRObjectsInfo, DCROperationTypes, DCRValue, WorkflowTaskData, WorkflowDefinition } from '@reltio/mdm-sdk';
|
|
2
2
|
export declare const getOperationType: (type: string, oldValue?: DCRAttributeValue) => DCROperationTypes;
|
|
3
3
|
export declare const getOperationLabel: (operation: DCROperationTypes) => string;
|
|
4
4
|
export declare const getAttributeDescription: (attrType: AttributeType, value: DCRAttributeValue, currentEntityUri: string, objectsInfo?: DCRObjectsInfo) => {
|
|
@@ -11,3 +11,4 @@ export declare const getDCRUri: (objectUris?: string[]) => string;
|
|
|
11
11
|
export declare const getDCRId: (objectUris?: string[]) => string;
|
|
12
12
|
export declare const isOpenTask: (isOpen: WorkflowTaskData["isOpen"]) => boolean;
|
|
13
13
|
export declare const isRequestedTask: (processTypes: string[], assignee: string) => (task: WorkflowTaskData) => boolean;
|
|
14
|
+
export declare const findWorkflowDefinitionByType: (definitions: WorkflowDefinition[], type: string) => WorkflowDefinition | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { pipe, startsWith, isNil, unless, split, nth, allPass, always, equals, evolve, prop, when, filter, has, length } from 'ramda';
|
|
1
|
+
import { pipe, startsWith, isNil, unless, split, nth, allPass, always, equals, evolve, prop, when, filter, has, length, propEq } from 'ramda';
|
|
2
2
|
import i18n from 'ui-i18n';
|
|
3
3
|
import { DataTypes, DCRTypes, getAttrDataTypeDefinition, isUrl, DCROperationTypes } from '@reltio/mdm-sdk';
|
|
4
4
|
export var getOperationType = function (type, oldValue) {
|
|
@@ -66,3 +66,4 @@ export var isOpenTask = function (isOpen) { return isOpen === undefined || isOpe
|
|
|
66
66
|
export var isRequestedTask = function (processTypes, assignee) { return function (task) {
|
|
67
67
|
return (!processTypes || processTypes.includes(task.processType)) && (!assignee || assignee === task.assignee);
|
|
68
68
|
}; };
|
|
69
|
+
export var findWorkflowDefinitionByType = function (definitions, type) { return definitions.find(propEq('type', type)); };
|
|
@@ -1,9 +1,46 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
12
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
1
37
|
import { useCallback, useContext, useMemo, useState } from 'react';
|
|
2
38
|
import { runTaskAction } from '@reltio/mdm-sdk';
|
|
3
39
|
import { showWorkflowError } from '../helpers/errors';
|
|
4
40
|
import { isOpenTask } from '../helpers/common';
|
|
5
41
|
import { WorkflowTasksContext } from '../../../contexts/WorkflowTasksContext';
|
|
6
42
|
import { useMdmTenant, useMdmUsername, useMdmWorkflowEnvironmentUrl, useMdmWorkflowPath } from '../../../contexts/MdmModuleContext';
|
|
43
|
+
import { useCommentDialog } from '../../../contexts/CommentDialogContext';
|
|
7
44
|
export var useWorkflowActions = function (task, onActionSuccess) {
|
|
8
45
|
var _a = task !== null && task !== void 0 ? task : {}, possibleActions = _a.possibleActions, assignee = _a.assignee, taskId = _a.taskId, isOpen = _a.isOpen;
|
|
9
46
|
var workflowTasks = useContext(WorkflowTasksContext);
|
|
@@ -11,34 +48,57 @@ export var useWorkflowActions = function (task, onActionSuccess) {
|
|
|
11
48
|
var environment = useMdmWorkflowEnvironmentUrl();
|
|
12
49
|
var tenant = useMdmTenant();
|
|
13
50
|
var username = useMdmUsername();
|
|
51
|
+
var showCommentDialog = useCommentDialog();
|
|
14
52
|
var _b = useState(false), actionRequestIsInProgress = _b[0], setActionRequestIsInProgress = _b[1];
|
|
15
53
|
var handleActionSuccess = onActionSuccess !== null && onActionSuccess !== void 0 ? onActionSuccess : workflowTasks === null || workflowTasks === void 0 ? void 0 : workflowTasks.onActionSuccess;
|
|
16
|
-
var performTaskAction = useCallback(function (action
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
54
|
+
var performTaskAction = useCallback(function (action, commentRequired) {
|
|
55
|
+
return function (comment) { return __awaiter(void 0, void 0, void 0, function () {
|
|
56
|
+
var processInstanceComment;
|
|
57
|
+
return __generator(this, function (_a) {
|
|
58
|
+
switch (_a.label) {
|
|
59
|
+
case 0:
|
|
60
|
+
if (!(workflowPath && taskId)) return [3 /*break*/, 3];
|
|
61
|
+
setActionRequestIsInProgress(true);
|
|
62
|
+
processInstanceComment = typeof comment === 'string' && comment.length ? comment : null;
|
|
63
|
+
if (!(commentRequired && !processInstanceComment)) return [3 /*break*/, 2];
|
|
64
|
+
return [4 /*yield*/, showCommentDialog()];
|
|
65
|
+
case 1:
|
|
66
|
+
processInstanceComment = _a.sent();
|
|
67
|
+
if (processInstanceComment === null) {
|
|
68
|
+
setActionRequestIsInProgress(false);
|
|
69
|
+
return [2 /*return*/];
|
|
70
|
+
}
|
|
71
|
+
_a.label = 2;
|
|
72
|
+
case 2:
|
|
73
|
+
runTaskAction({
|
|
74
|
+
taskId: taskId,
|
|
75
|
+
workflowPath: workflowPath,
|
|
76
|
+
environment: environment,
|
|
77
|
+
tenant: tenant,
|
|
78
|
+
action: action,
|
|
79
|
+
processInstanceComment: processInstanceComment
|
|
80
|
+
})
|
|
81
|
+
.then(function () {
|
|
82
|
+
handleActionSuccess === null || handleActionSuccess === void 0 ? void 0 : handleActionSuccess(action);
|
|
83
|
+
})
|
|
84
|
+
.catch(showWorkflowError)
|
|
85
|
+
.finally(function () {
|
|
86
|
+
setActionRequestIsInProgress(false);
|
|
87
|
+
});
|
|
88
|
+
_a.label = 3;
|
|
89
|
+
case 3: return [2 /*return*/];
|
|
90
|
+
}
|
|
34
91
|
});
|
|
35
|
-
}
|
|
36
|
-
}
|
|
92
|
+
}); };
|
|
93
|
+
}, [workflowPath, taskId, environment, tenant, handleActionSuccess, showCommentDialog]);
|
|
37
94
|
var actions = useMemo(function () {
|
|
38
95
|
return username === assignee && isOpenTask(isOpen)
|
|
39
96
|
? (possibleActions || []).map(function (_a) {
|
|
40
|
-
var action = _a.action, label = _a.label;
|
|
41
|
-
return ({
|
|
97
|
+
var action = _a.action, label = _a.label, commentRequired = _a.commentRequired;
|
|
98
|
+
return ({
|
|
99
|
+
text: label,
|
|
100
|
+
onClick: performTaskAction(action, commentRequired)
|
|
101
|
+
});
|
|
42
102
|
})
|
|
43
103
|
: [];
|
|
44
104
|
}, [possibleActions, performTaskAction, username, assignee, isOpen]);
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { WorkflowDefinition } from '@reltio/mdm-sdk';
|
|
2
|
+
export declare const useWorkflowDefinitions: ({ all, canViewDefinitions }?: {
|
|
3
|
+
all?: boolean;
|
|
4
|
+
canViewDefinitions?: boolean;
|
|
5
|
+
}) => {
|
|
6
|
+
definitions: WorkflowDefinition[];
|
|
7
|
+
loading: boolean;
|
|
3
8
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react';
|
|
2
|
-
import { processDefinitions } from '@reltio/mdm-sdk';
|
|
1
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
2
|
+
import { memoizeWith, processDefinitions } from '@reltio/mdm-sdk';
|
|
3
3
|
import { useSafePromise } from '../../../hooks/useSafePromise';
|
|
4
4
|
import { useMdmEntity, useMdmTenant, useMdmWorkflowEnvironmentUrl, useMdmWorkflowPath } from '../../../contexts/MdmModuleContext';
|
|
5
5
|
var filterDefinitions = function (definitions, entityTypeUri) {
|
|
@@ -8,26 +8,39 @@ var filterDefinitions = function (definitions, entityTypeUri) {
|
|
|
8
8
|
return manualStart && (!objectTypes || (objectTypes === null || objectTypes === void 0 ? void 0 : objectTypes.some(function (uri) { return uri === entityTypeUri; })));
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
|
|
12
|
-
var
|
|
11
|
+
var memoizedProcessDefinitions = memoizeWith(function (_a) {
|
|
12
|
+
var workflowPath = _a.workflowPath, environment = _a.environment, tenant = _a.tenant;
|
|
13
|
+
return "".concat(workflowPath, "-").concat(environment, "-").concat(tenant);
|
|
14
|
+
}, processDefinitions);
|
|
15
|
+
export var useWorkflowDefinitions = function (_a) {
|
|
16
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.all, all = _c === void 0 ? false : _c, _d = _b.canViewDefinitions, canViewDefinitions = _d === void 0 ? true : _d;
|
|
17
|
+
var _e = useState([]), definitions = _e[0], setDefinitions = _e[1];
|
|
18
|
+
var _f = useState(false), loading = _f[0], setLoading = _f[1];
|
|
13
19
|
var workflowPath = useMdmWorkflowPath();
|
|
14
20
|
var environment = useMdmWorkflowEnvironmentUrl();
|
|
15
21
|
var tenant = useMdmTenant();
|
|
16
22
|
var entity = useMdmEntity();
|
|
17
|
-
var entityType = entity.type;
|
|
23
|
+
var entityType = entity === null || entity === void 0 ? void 0 : entity.type;
|
|
18
24
|
var safePromise = useSafePromise();
|
|
19
25
|
useEffect(function () {
|
|
20
|
-
|
|
26
|
+
if (!canViewDefinitions) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
setLoading(true);
|
|
30
|
+
safePromise(memoizedProcessDefinitions({ workflowPath: workflowPath, environment: environment, tenant: tenant }))
|
|
21
31
|
.then(function (_a) {
|
|
22
32
|
var data = _a.data;
|
|
23
33
|
if (!data) {
|
|
24
34
|
return;
|
|
25
35
|
}
|
|
26
|
-
setDefinitions(filterDefinitions(data, entityType));
|
|
36
|
+
setDefinitions(all ? data : filterDefinitions(data, entityType));
|
|
27
37
|
})
|
|
28
38
|
.catch(function (error) {
|
|
29
39
|
console.warn('Workflow error', error);
|
|
40
|
+
})
|
|
41
|
+
.finally(function () {
|
|
42
|
+
setLoading(false);
|
|
30
43
|
});
|
|
31
|
-
}, [entityType, workflowPath, environment, tenant]);
|
|
32
|
-
return { definitions: definitions };
|
|
44
|
+
}, [entityType, workflowPath, environment, tenant, all, canViewDefinitions]);
|
|
45
|
+
return useMemo(function () { return ({ definitions: definitions, loading: loading }); }, [definitions, loading]);
|
|
33
46
|
};
|
|
@@ -11,3 +11,4 @@ export { useWorkflowActions } from './hooks/useWorkflowActions';
|
|
|
11
11
|
export { useWorkflowCheckPermission } from './hooks/useWorkflowCheckPermission';
|
|
12
12
|
export { useWorkflowTasks } from './hooks/useWorkflowTasks';
|
|
13
13
|
export { useWorkflowDefaultActionSuccessHandler } from './hooks/useWorkflowDefaultActionSuccessHandler';
|
|
14
|
+
export { findWorkflowDefinitionByType } from './helpers/common';
|
|
@@ -13,3 +13,5 @@ export { useWorkflowActions } from './hooks/useWorkflowActions';
|
|
|
13
13
|
export { useWorkflowCheckPermission } from './hooks/useWorkflowCheckPermission';
|
|
14
14
|
export { useWorkflowTasks } from './hooks/useWorkflowTasks';
|
|
15
15
|
export { useWorkflowDefaultActionSuccessHandler } from './hooks/useWorkflowDefaultActionSuccessHandler';
|
|
16
|
+
// helpers
|
|
17
|
+
export { findWorkflowDefinitionByType } from './helpers/common';
|