@reltio/components 1.4.2207 → 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.
- package/cjs/features/workflow/ChangeRequestEditor/ChangeRequestEditor.js +1 -2
- package/cjs/features/workflow/ChangeRequestEditor/components/ChangeItemEditor/ChangeItemEditor.js +2 -1
- package/cjs/features/workflow/ChangeRequestEditor/components/ChangeItemRow/ChangeItemRow.js +4 -4
- package/cjs/features/workflow/ChangeRequestEditor/components/DCRValueEditor/DCRValueEditor.d.ts +1 -1
- package/cjs/features/workflow/ChangeRequestEditor/components/DCRValueEditorFactory/DCRValueEditorFactory.d.ts +1 -1
- package/cjs/features/workflow/ChangeRequestEditor/hooks/useChangeRequestEditor.d.ts +2 -1
- package/cjs/features/workflow/ChangeRequestEditor/hooks/useChangeRequestEditor.js +14 -8
- package/cjs/features/workflow/ReviewDCRDialog/ReviewDCRDialog.js +10 -7
- package/cjs/features/workflow/TaskActionButtons/TaskActionButtons.js +6 -4
- package/cjs/features/workflow/WorkflowTaskCard/components/DataChangeRequestTaskCard/DataChangeRequestTaskCard.js +8 -3
- package/cjs/features/workflow/WorkflowTaskCard/components/GenericWorkflowTaskCard/GenericWorkflowTaskCard.js +6 -4
- package/cjs/features/workflow/{ChangeRequestEditor/context → contexts/ChangeRequestEditorContext}/index.d.ts +1 -0
- package/cjs/features/workflow/{ChangeRequestEditor/context → contexts/ChangeRequestEditorContext}/index.js +12 -0
- package/cjs/features/workflow/helpers/dcr.d.ts +8 -1
- package/cjs/features/workflow/helpers/dcr.js +186 -1
- package/cjs/features/workflow/hooks/useApplyDcrChanges.d.ts +3 -0
- package/cjs/features/workflow/hooks/useApplyDcrChanges.js +145 -0
- package/cjs/features/workflow/hooks/useWorkflowActions.d.ts +7 -2
- package/cjs/features/workflow/hooks/useWorkflowActions.js +31 -8
- package/cjs/features/workflow/types.d.ts +4 -0
- package/features/workflow/ChangeRequestEditor/ChangeRequestEditor.js +1 -2
- package/features/workflow/ChangeRequestEditor/components/ChangeItemEditor/ChangeItemEditor.js +2 -1
- package/features/workflow/ChangeRequestEditor/components/ChangeItemRow/ChangeItemRow.js +1 -1
- package/features/workflow/ChangeRequestEditor/components/DCRValueEditor/DCRValueEditor.d.ts +1 -1
- package/features/workflow/ChangeRequestEditor/components/DCRValueEditorFactory/DCRValueEditorFactory.d.ts +1 -1
- package/features/workflow/ChangeRequestEditor/hooks/useChangeRequestEditor.d.ts +2 -1
- package/features/workflow/ChangeRequestEditor/hooks/useChangeRequestEditor.js +8 -2
- package/features/workflow/ReviewDCRDialog/ReviewDCRDialog.js +10 -7
- package/features/workflow/TaskActionButtons/TaskActionButtons.js +6 -4
- package/features/workflow/WorkflowTaskCard/components/DataChangeRequestTaskCard/DataChangeRequestTaskCard.js +9 -4
- package/features/workflow/WorkflowTaskCard/components/GenericWorkflowTaskCard/GenericWorkflowTaskCard.js +6 -4
- package/features/workflow/{ChangeRequestEditor/context → contexts/ChangeRequestEditorContext}/index.d.ts +1 -0
- package/features/workflow/{ChangeRequestEditor/context → contexts/ChangeRequestEditorContext}/index.js +13 -1
- package/features/workflow/helpers/dcr.d.ts +8 -1
- package/features/workflow/helpers/dcr.js +186 -2
- package/features/workflow/hooks/useApplyDcrChanges.d.ts +3 -0
- package/features/workflow/hooks/useApplyDcrChanges.js +141 -0
- package/features/workflow/hooks/useWorkflowActions.d.ts +7 -2
- package/features/workflow/hooks/useWorkflowActions.js +31 -8
- package/features/workflow/types.d.ts +4 -0
- package/package.json +2 -2
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
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);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
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;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.useApplyDcrChanges = void 0;
|
|
40
|
+
var react_1 = require("react");
|
|
41
|
+
var react_context_selector_1 = require("@fluentui/react-context-selector");
|
|
42
|
+
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
43
|
+
var ramda_1 = require("ramda");
|
|
44
|
+
var MdmModuleContext_1 = require("../../../contexts/MdmModuleContext");
|
|
45
|
+
var ChangeRequestEditorContext_1 = require("../contexts/ChangeRequestEditorContext");
|
|
46
|
+
var dcr_1 = require("../helpers/dcr");
|
|
47
|
+
var withChangeRequestId = function (dcrUri) { return function (url) {
|
|
48
|
+
return url + (url.includes('?') ? '&' : '?') + "changeRequestId=".concat(encodeURIComponent(dcrUri.split('/')[1]));
|
|
49
|
+
}; };
|
|
50
|
+
var useApplyDcrChanges = function (dcr) {
|
|
51
|
+
var getLinesByChangeId = (0, react_context_selector_1.useContextSelector)(ChangeRequestEditorContext_1.ChangeRequestEditorContext, function (context) { return context.getLinesByChangeId; });
|
|
52
|
+
var metadata = (0, MdmModuleContext_1.useMdmMetadata)();
|
|
53
|
+
var applyDcrChanges = (0, react_1.useCallback)(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
54
|
+
var _a, rejectedChangeIds, updatedChanges, deleteEntityAttributes, deleteRelationAttributes, deleteChangeResults, deleteEntityAttributesResults, deleteRelationAttributesResults, deleteChangeFailures, error_1, deleteEntityAttributesFailures, deleteRelationAttributesFailures;
|
|
55
|
+
return __generator(this, function (_b) {
|
|
56
|
+
switch (_b.label) {
|
|
57
|
+
case 0:
|
|
58
|
+
if (!(dcr === null || dcr === void 0 ? void 0 : dcr.changes)) return [3 /*break*/, 11];
|
|
59
|
+
_a = (0, dcr_1.buildDCRSavePlan)(dcr.changes, getLinesByChangeId, metadata), rejectedChangeIds = _a.rejectedChangeIds, updatedChanges = _a.updatedChanges, deleteEntityAttributes = _a.deleteEntityAttributes, deleteRelationAttributes = _a.deleteRelationAttributes;
|
|
60
|
+
deleteChangeResults = [];
|
|
61
|
+
deleteEntityAttributesResults = [];
|
|
62
|
+
deleteRelationAttributesResults = [];
|
|
63
|
+
if (!(rejectedChangeIds.length > 0)) return [3 /*break*/, 2];
|
|
64
|
+
return [4 /*yield*/, (0, mdm_sdk_1.promiseAllSettled)(rejectedChangeIds.map(function (changeId) {
|
|
65
|
+
return (0, mdm_sdk_1.deleteChangeRequestItem)({ dcrUri: dcr.uri, changeItemId: changeId });
|
|
66
|
+
}))];
|
|
67
|
+
case 1:
|
|
68
|
+
deleteChangeResults = _b.sent();
|
|
69
|
+
_b.label = 2;
|
|
70
|
+
case 2:
|
|
71
|
+
deleteChangeFailures = deleteChangeResults.filter(function (result) { return result.status === 'rejected'; });
|
|
72
|
+
if (deleteChangeFailures.length) {
|
|
73
|
+
return [2 /*return*/, {
|
|
74
|
+
proceed: false,
|
|
75
|
+
error: new Error("Failed to delete DCR change(s): ".concat(deleteChangeFailures.map(function (result) { return result.reason; }).join(', ')))
|
|
76
|
+
}];
|
|
77
|
+
}
|
|
78
|
+
if (!!(0, ramda_1.isEmpty)(updatedChanges)) return [3 /*break*/, 6];
|
|
79
|
+
_b.label = 3;
|
|
80
|
+
case 3:
|
|
81
|
+
_b.trys.push([3, 5, , 6]);
|
|
82
|
+
return [4 /*yield*/, (0, mdm_sdk_1.updateChangeRequest)({ dcrUri: dcr.uri, payload: updatedChanges })];
|
|
83
|
+
case 4:
|
|
84
|
+
_b.sent();
|
|
85
|
+
return [3 /*break*/, 6];
|
|
86
|
+
case 5:
|
|
87
|
+
error_1 = _b.sent();
|
|
88
|
+
return [2 /*return*/, {
|
|
89
|
+
proceed: false,
|
|
90
|
+
error: error_1
|
|
91
|
+
}];
|
|
92
|
+
case 6:
|
|
93
|
+
if (!!(0, ramda_1.isEmpty)(deleteEntityAttributes)) return [3 /*break*/, 8];
|
|
94
|
+
return [4 /*yield*/, (0, mdm_sdk_1.promiseAllSettled)(Object.entries(deleteEntityAttributes).map(function (_a) {
|
|
95
|
+
var entityUri = _a[0], diff = _a[1];
|
|
96
|
+
return (0, mdm_sdk_1.entityCumulativeUpdate)({
|
|
97
|
+
uri: entityUri,
|
|
98
|
+
diff: diff,
|
|
99
|
+
uriPreprocessor: withChangeRequestId(dcr.uri)
|
|
100
|
+
});
|
|
101
|
+
}))];
|
|
102
|
+
case 7:
|
|
103
|
+
deleteEntityAttributesResults = _b.sent();
|
|
104
|
+
_b.label = 8;
|
|
105
|
+
case 8:
|
|
106
|
+
deleteEntityAttributesFailures = deleteEntityAttributesResults.filter(function (result) { return result.status === 'rejected'; });
|
|
107
|
+
if (deleteEntityAttributesFailures.length) {
|
|
108
|
+
return [2 /*return*/, {
|
|
109
|
+
proceed: false,
|
|
110
|
+
error: new Error("Failed to delete entity attributes: ".concat(deleteEntityAttributesFailures.map(function (result) { return result.reason; }).join(', ')))
|
|
111
|
+
}];
|
|
112
|
+
}
|
|
113
|
+
if (!!(0, ramda_1.isEmpty)(deleteRelationAttributes)) return [3 /*break*/, 10];
|
|
114
|
+
return [4 /*yield*/, (0, mdm_sdk_1.promiseAllSettled)(Object.entries(deleteRelationAttributes).map(function (_a) {
|
|
115
|
+
var relationUri = _a[0], diff = _a[1];
|
|
116
|
+
return (0, mdm_sdk_1.updateRelationWithDiff)({
|
|
117
|
+
uri: relationUri,
|
|
118
|
+
diff: diff,
|
|
119
|
+
uriPreprocessor: withChangeRequestId(dcr.uri)
|
|
120
|
+
});
|
|
121
|
+
}))];
|
|
122
|
+
case 9:
|
|
123
|
+
deleteRelationAttributesResults = _b.sent();
|
|
124
|
+
_b.label = 10;
|
|
125
|
+
case 10:
|
|
126
|
+
deleteRelationAttributesFailures = deleteRelationAttributesResults.filter(function (result) { return result.status === 'rejected'; });
|
|
127
|
+
if (deleteRelationAttributesFailures.length) {
|
|
128
|
+
return [2 /*return*/, {
|
|
129
|
+
proceed: false,
|
|
130
|
+
error: new Error("Failed to delete relation attributes: ".concat(deleteRelationAttributesFailures.map(function (result) { return result.reason; }).join(', ')))
|
|
131
|
+
}];
|
|
132
|
+
}
|
|
133
|
+
return [2 /*return*/, {
|
|
134
|
+
proceed: true
|
|
135
|
+
}];
|
|
136
|
+
case 11: return [2 /*return*/, {
|
|
137
|
+
proceed: false,
|
|
138
|
+
error: new Error('No changes to apply')
|
|
139
|
+
}];
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
}); }, [dcr, getLinesByChangeId, metadata]);
|
|
143
|
+
return applyDcrChanges;
|
|
144
|
+
};
|
|
145
|
+
exports.useApplyDcrChanges = useApplyDcrChanges;
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { WorkflowTaskData } from '@reltio/mdm-sdk';
|
|
2
|
-
import { TaskAction } from '../types';
|
|
2
|
+
import { BeforeActionOutcome, TaskAction } from '../types';
|
|
3
3
|
type Task = Partial<Pick<WorkflowTaskData, 'taskId' | 'possibleActions' | 'assignee' | 'isOpen'>>;
|
|
4
|
-
|
|
4
|
+
type Props = {
|
|
5
|
+
task: Task;
|
|
6
|
+
onActionSuccess?: (action: string) => void;
|
|
7
|
+
beforeAction?: () => Promise<BeforeActionOutcome>;
|
|
8
|
+
};
|
|
9
|
+
export declare const useWorkflowActions: ({ task, onActionSuccess, beforeAction }: Props) => {
|
|
5
10
|
actions: TaskAction[];
|
|
6
11
|
actionRequestIsInProgress: boolean;
|
|
7
12
|
};
|
|
@@ -44,23 +44,25 @@ var common_1 = require("../helpers/common");
|
|
|
44
44
|
var WorkflowTasksContext_1 = require("../../../contexts/WorkflowTasksContext");
|
|
45
45
|
var MdmModuleContext_1 = require("../../../contexts/MdmModuleContext");
|
|
46
46
|
var CommentDialogContext_1 = require("../../../contexts/CommentDialogContext");
|
|
47
|
-
var
|
|
48
|
-
|
|
47
|
+
var errors_2 = require("../../../helpers/errors");
|
|
48
|
+
var useWorkflowActions = function (_a) {
|
|
49
|
+
var task = _a.task, onActionSuccess = _a.onActionSuccess, beforeAction = _a.beforeAction;
|
|
50
|
+
var _b = task !== null && task !== void 0 ? task : {}, possibleActions = _b.possibleActions, assignee = _b.assignee, taskId = _b.taskId, isOpen = _b.isOpen;
|
|
49
51
|
var workflowTasks = (0, react_1.useContext)(WorkflowTasksContext_1.WorkflowTasksContext);
|
|
50
52
|
var workflowPath = (0, MdmModuleContext_1.useMdmWorkflowPath)();
|
|
51
53
|
var environment = (0, MdmModuleContext_1.useMdmWorkflowEnvironmentUrl)();
|
|
52
54
|
var tenant = (0, MdmModuleContext_1.useMdmTenant)();
|
|
53
55
|
var username = (0, MdmModuleContext_1.useMdmUsername)();
|
|
54
56
|
var showCommentDialog = (0, CommentDialogContext_1.useCommentDialog)();
|
|
55
|
-
var
|
|
57
|
+
var _c = (0, react_1.useState)(false), actionRequestIsInProgress = _c[0], setActionRequestIsInProgress = _c[1];
|
|
56
58
|
var handleActionSuccess = onActionSuccess !== null && onActionSuccess !== void 0 ? onActionSuccess : workflowTasks === null || workflowTasks === void 0 ? void 0 : workflowTasks.onActionSuccess;
|
|
57
59
|
var performTaskAction = (0, react_1.useCallback)(function (action, commentRequired) {
|
|
58
60
|
return function (comment) { return __awaiter(void 0, void 0, void 0, function () {
|
|
59
|
-
var processInstanceComment;
|
|
61
|
+
var processInstanceComment, outcome, error_1;
|
|
60
62
|
return __generator(this, function (_a) {
|
|
61
63
|
switch (_a.label) {
|
|
62
64
|
case 0:
|
|
63
|
-
if (!(workflowPath && taskId)) return [3 /*break*/,
|
|
65
|
+
if (!(workflowPath && taskId)) return [3 /*break*/, 7];
|
|
64
66
|
setActionRequestIsInProgress(true);
|
|
65
67
|
processInstanceComment = typeof comment === 'string' && comment.length ? comment : null;
|
|
66
68
|
if (!(commentRequired && !processInstanceComment)) return [3 /*break*/, 2];
|
|
@@ -73,6 +75,27 @@ var useWorkflowActions = function (task, onActionSuccess) {
|
|
|
73
75
|
}
|
|
74
76
|
_a.label = 2;
|
|
75
77
|
case 2:
|
|
78
|
+
if (!beforeAction) return [3 /*break*/, 6];
|
|
79
|
+
_a.label = 3;
|
|
80
|
+
case 3:
|
|
81
|
+
_a.trys.push([3, 5, , 6]);
|
|
82
|
+
return [4 /*yield*/, beforeAction()];
|
|
83
|
+
case 4:
|
|
84
|
+
outcome = _a.sent();
|
|
85
|
+
if (!outcome.proceed) {
|
|
86
|
+
if (outcome.error) {
|
|
87
|
+
(0, errors_2.showDefaultErrorMessage)(outcome.error);
|
|
88
|
+
}
|
|
89
|
+
setActionRequestIsInProgress(false);
|
|
90
|
+
return [2 /*return*/];
|
|
91
|
+
}
|
|
92
|
+
return [3 /*break*/, 6];
|
|
93
|
+
case 5:
|
|
94
|
+
error_1 = _a.sent();
|
|
95
|
+
(0, errors_2.showDefaultErrorMessage)(error_1);
|
|
96
|
+
setActionRequestIsInProgress(false);
|
|
97
|
+
return [2 /*return*/];
|
|
98
|
+
case 6:
|
|
76
99
|
(0, mdm_sdk_1.runTaskAction)({
|
|
77
100
|
taskId: taskId,
|
|
78
101
|
workflowPath: workflowPath,
|
|
@@ -88,12 +111,12 @@ var useWorkflowActions = function (task, onActionSuccess) {
|
|
|
88
111
|
.finally(function () {
|
|
89
112
|
setActionRequestIsInProgress(false);
|
|
90
113
|
});
|
|
91
|
-
_a.label =
|
|
92
|
-
case
|
|
114
|
+
_a.label = 7;
|
|
115
|
+
case 7: return [2 /*return*/];
|
|
93
116
|
}
|
|
94
117
|
});
|
|
95
118
|
}); };
|
|
96
|
-
}, [workflowPath, taskId, environment, tenant, handleActionSuccess, showCommentDialog]);
|
|
119
|
+
}, [workflowPath, taskId, environment, tenant, handleActionSuccess, showCommentDialog, beforeAction]);
|
|
97
120
|
var actions = (0, react_1.useMemo)(function () {
|
|
98
121
|
return username === assignee && (0, common_1.isOpenTask)(isOpen)
|
|
99
122
|
? (possibleActions || []).map(function (_a) {
|
|
@@ -5,7 +5,6 @@ import Typography from '@mui/material/Typography';
|
|
|
5
5
|
import { addLineIdToValue } from './helpers/helpers';
|
|
6
6
|
import SvgSuggestedChanges from '../../../icons/SuggestedChanges';
|
|
7
7
|
import { EntityChangesGroup, SkeletonEntityChangesGroupLoader } from './components/EntityChangesGroup';
|
|
8
|
-
import { ChangeRequestEditorProvider } from './context';
|
|
9
8
|
import styles from './ChangeRequestEditor.module.css';
|
|
10
9
|
export var ChangeRequestEditor = function (_a) {
|
|
11
10
|
var dcr = _a.dcr, task = _a.task, groupedObjects = _a.groupedObjects;
|
|
@@ -23,5 +22,5 @@ export var ChangeRequestEditor = function (_a) {
|
|
|
23
22
|
React.createElement("div", { className: styles.suggestedChangesIcon },
|
|
24
23
|
React.createElement(SvgSuggestedChanges, null)),
|
|
25
24
|
React.createElement(Typography, { variant: "h6", className: styles.suggestedChangesTitle }, i18n.text('Suggested changes'))),
|
|
26
|
-
dcrLoaded ? (
|
|
25
|
+
dcrLoaded ? (groupedObjects.map(function (object, index) { return (React.createElement(EntityChangesGroup, { key: "entity-".concat(index), entityInfo: object.entity, relationsInfo: object.relations, task: task, dcr: enrichedDCR })); })) : (React.createElement(SkeletonEntityChangesGroupLoader, null))));
|
|
27
26
|
};
|
package/features/workflow/ChangeRequestEditor/components/ChangeItemEditor/ChangeItemEditor.js
CHANGED
|
@@ -21,7 +21,7 @@ export var ChangeItemEditor = function (_a) {
|
|
|
21
21
|
var _b, _c, _d;
|
|
22
22
|
var change = _a.change, _e = _a.editable, editable = _e === void 0 ? true : _e, classes = _a.classes;
|
|
23
23
|
var metadata = useMdmMetadata();
|
|
24
|
-
var _f = useChangeRequestEditor({ change: change }), handleChange = _f.handleChange, handleReject = _f.handleReject, handleRevert = _f.handleRevert, lineData = _f.lineData, isLineRejected = _f.isLineRejected, isParentLineRejected = _f.isParentLineRejected, isUpdated = _f.isUpdated, hasChangeId = _f.hasChangeId;
|
|
24
|
+
var _f = useChangeRequestEditor({ change: change }), handleChange = _f.handleChange, handleReject = _f.handleReject, handleRevert = _f.handleRevert, lineData = _f.lineData, isLineRejected = _f.isLineRejected, isParentLineRejected = _f.isParentLineRejected, isUpdated = _f.isUpdated, hasChangeId = _f.hasChangeId, isSubAttributeOfDeletedAttribute = _f.isSubAttributeOfDeletedAttribute;
|
|
25
25
|
var entity = useMdmEntity();
|
|
26
26
|
var entityType = getEntityType(metadata, entity === null || entity === void 0 ? void 0 : entity.type);
|
|
27
27
|
var isUpdateOperation = change.operation === DCROperationTypes.EDITED;
|
|
@@ -48,6 +48,7 @@ export var ChangeItemEditor = function (_a) {
|
|
|
48
48
|
!isUpdated &&
|
|
49
49
|
!isParentLineRejected &&
|
|
50
50
|
hasChangeId &&
|
|
51
|
+
!isSubAttributeOfDeletedAttribute &&
|
|
51
52
|
!(change.isReferenceSubAttribute && !editable);
|
|
52
53
|
var showStatusChips = !isParentLineRejected;
|
|
53
54
|
var isRejected = isLineRejected || isParentLineRejected;
|
|
@@ -3,7 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import { useContextSelector } from '@fluentui/react-context-selector';
|
|
4
4
|
import { DCROperationTypes } from '@reltio/mdm-sdk';
|
|
5
5
|
import { isEditableChange } from '../../helpers/helpers';
|
|
6
|
-
import { ChangeRequestEditorContext } from '
|
|
6
|
+
import { ChangeRequestEditorContext } from '../../../contexts/ChangeRequestEditorContext';
|
|
7
7
|
import { ChangeItemEditor, ChangeItemOldValue } from '../ChangeItemEditor';
|
|
8
8
|
import { extractLineIds } from '../../../helpers/merge';
|
|
9
9
|
import styles from './ChangeItemRow.module.css';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { AttributeType, ChangeValue, PrimitiveValue, SimpleAttributeValue } from '@reltio/mdm-sdk';
|
|
3
|
-
import { LineDataValue } from '
|
|
3
|
+
import { LineDataValue } from '../../../contexts/ChangeRequestEditorContext';
|
|
4
4
|
type Props = {
|
|
5
5
|
attributeType: AttributeType;
|
|
6
6
|
value: LineDataValue | ChangeValue;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { AttributeType, ChangeValue, DataTypeDefinition, PrimitiveValue, SimpleAttributeValue } from '@reltio/mdm-sdk';
|
|
3
|
-
import { LineDataValue } from '
|
|
3
|
+
import { LineDataValue } from '../../../contexts/ChangeRequestEditorContext';
|
|
4
4
|
type Props = {
|
|
5
5
|
attributeType: AttributeType;
|
|
6
6
|
value: LineDataValue | ChangeValue;
|
|
@@ -7,10 +7,11 @@ export declare const useChangeRequestEditor: ({ change }: Props) => {
|
|
|
7
7
|
handleChange: (newValue: SimpleAttributeValue | string[] | PrimitiveValue) => void;
|
|
8
8
|
handleReject: () => void;
|
|
9
9
|
handleRevert: () => void;
|
|
10
|
-
lineData: import("
|
|
10
|
+
lineData: import("../../contexts/ChangeRequestEditorContext").LineData;
|
|
11
11
|
isLineRejected: boolean;
|
|
12
12
|
isParentLineRejected: boolean;
|
|
13
13
|
isUpdated: boolean;
|
|
14
14
|
hasChangeId: boolean;
|
|
15
|
+
isSubAttributeOfDeletedAttribute: any;
|
|
15
16
|
};
|
|
16
17
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useCallback } from 'react';
|
|
2
2
|
import { useContextSelector } from '@fluentui/react-context-selector';
|
|
3
|
-
import {
|
|
3
|
+
import { DCROperationTypes } from '@reltio/mdm-sdk';
|
|
4
|
+
import { ChangeRequestEditorContext } from '../../contexts/ChangeRequestEditorContext';
|
|
4
5
|
import { extractLineIds } from '../../helpers/merge';
|
|
5
6
|
var emptyLineIds = [];
|
|
6
7
|
export var useChangeRequestEditor = function (_a) {
|
|
@@ -16,6 +17,10 @@ export var useChangeRequestEditor = function (_a) {
|
|
|
16
17
|
var isUpdated = useContextSelector(ChangeRequestEditorContext, function (context) { return context.getIsLineUpdated(lineIds[0]); });
|
|
17
18
|
var isLineRejected = lineData === null || lineData === void 0 ? void 0 : lineData.isRejected;
|
|
18
19
|
var hasChangeId = lineIds.length > 0;
|
|
20
|
+
var isSubAttributeOfDeletedAttribute = change.operation === DCROperationTypes.DELETED &&
|
|
21
|
+
change.level > 0 &&
|
|
22
|
+
lineIds.length > 0 &&
|
|
23
|
+
lineIds[0].includes('/value/');
|
|
19
24
|
var handleChange = useCallback(function (newValue) {
|
|
20
25
|
updateChange(lineIds, typeof newValue === 'object' && 'value' in newValue ? newValue : { value: newValue });
|
|
21
26
|
}, [lineIds, updateChange]);
|
|
@@ -33,6 +38,7 @@ export var useChangeRequestEditor = function (_a) {
|
|
|
33
38
|
isLineRejected: isLineRejected,
|
|
34
39
|
isParentLineRejected: isParentLineRejected,
|
|
35
40
|
isUpdated: isUpdated,
|
|
36
|
-
hasChangeId: hasChangeId
|
|
41
|
+
hasChangeId: hasChangeId,
|
|
42
|
+
isSubAttributeOfDeletedAttribute: isSubAttributeOfDeletedAttribute
|
|
37
43
|
};
|
|
38
44
|
};
|
|
@@ -9,7 +9,6 @@ import i18n from 'ui-i18n';
|
|
|
9
9
|
import { useWorkflowCheckPermission } from '../hooks/useWorkflowCheckPermission';
|
|
10
10
|
import { useWorkflowActions } from '../hooks/useWorkflowActions';
|
|
11
11
|
import { useMdmEntity } from '../../../contexts/MdmModuleContext';
|
|
12
|
-
import { ChangeRequestEditorProvider } from '../ChangeRequestEditor/context';
|
|
13
12
|
import { ProfileBand } from '../../../ProfileBand';
|
|
14
13
|
import { DueDateField } from '../DueDateField';
|
|
15
14
|
import { PrioritySelector } from '../PrioritySelector';
|
|
@@ -18,17 +17,22 @@ import { WorkflowComments } from '../WorkflowComments';
|
|
|
18
17
|
import { WorkflowActionButtons } from '../WorkflowActionButtons';
|
|
19
18
|
import { DCRSummaryInfo } from './components/DCRSummaryInfo/DCRSummaryInfo';
|
|
20
19
|
import { ChangeRequestEditor } from '../ChangeRequestEditor';
|
|
20
|
+
import { useApplyDcrChanges } from '../hooks/useApplyDcrChanges';
|
|
21
21
|
import styles from './ReviewDCRDialog.module.css';
|
|
22
22
|
export var ReviewDCRDialog = function (_a) {
|
|
23
23
|
var open = _a.open, onClose = _a.onClose, dcr = _a.dcr, task = _a.task, groupedObjects = _a.groupedObjects;
|
|
24
24
|
var entity = useMdmEntity();
|
|
25
25
|
var checkWorkflowPermission = useWorkflowCheckPermission();
|
|
26
26
|
var canViewComments = checkWorkflowPermission('VIEW_PROCESS_INSTANCE_COMMENTS');
|
|
27
|
+
var applyDcrChanges = useApplyDcrChanges(dcr);
|
|
27
28
|
var _b = useWorkflowActions({
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
task: {
|
|
30
|
+
taskId: task.taskId,
|
|
31
|
+
possibleActions: task.possibleActions,
|
|
32
|
+
assignee: task.assignee,
|
|
33
|
+
isOpen: task.isOpen
|
|
34
|
+
},
|
|
35
|
+
beforeAction: applyDcrChanges
|
|
32
36
|
}), workflowActions = _b.actions, actionRequestIsInProgress = _b.actionRequestIsInProgress;
|
|
33
37
|
return (React.createElement(Dialog, { open: open, onClose: onClose, fullScreen: true },
|
|
34
38
|
React.createElement(DialogTitle, { className: styles.dialogTitle },
|
|
@@ -49,8 +53,7 @@ export var ReviewDCRDialog = function (_a) {
|
|
|
49
53
|
React.createElement("div", { className: styles.editableItem },
|
|
50
54
|
React.createElement(AssigneeSelector, { taskId: task.taskId, assignee: task.assignee, isTaskOpen: task.isOpen })))),
|
|
51
55
|
React.createElement("div", { className: styles.changesSection },
|
|
52
|
-
React.createElement(
|
|
53
|
-
React.createElement(ChangeRequestEditor, { dcr: dcr, task: task, groupedObjects: groupedObjects })))),
|
|
56
|
+
React.createElement(ChangeRequestEditor, { dcr: dcr, task: task, groupedObjects: groupedObjects }))),
|
|
54
57
|
canViewComments && (React.createElement(WorkflowComments, { workflowActions: workflowActions, actionRequestIsInProgress: actionRequestIsInProgress, preferredAction: task.preferredAction, taskId: task.taskId, processInstanceComments: task.processInstanceComments, isTaskOpen: task.isOpen, showActionButtons: false, alwaysExpanded: true, classes: {
|
|
55
58
|
container: styles.commentsRootContainer,
|
|
56
59
|
commentsContainer: styles.commentsContainer
|
|
@@ -6,10 +6,12 @@ export var TaskActionButtons = function (_a) {
|
|
|
6
6
|
var task = _a.task;
|
|
7
7
|
var taskId = task.taskId, possibleActions = task.possibleActions, assignee = task.assignee, isOpen = task.isOpen, preferredAction = task.preferredAction;
|
|
8
8
|
var _b = useWorkflowActions({
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
task: {
|
|
10
|
+
taskId: taskId,
|
|
11
|
+
possibleActions: possibleActions,
|
|
12
|
+
assignee: assignee,
|
|
13
|
+
isOpen: isOpen
|
|
14
|
+
}
|
|
13
15
|
}), actions = _b.actions, disabled = _b.actionRequestIsInProgress;
|
|
14
16
|
var _c = partition(propEq('text', preferredAction === null || preferredAction === void 0 ? void 0 : preferredAction.label), actions), preferredActions = _c[0], otherActions = _c[1];
|
|
15
17
|
return (React.createElement(React.Fragment, null,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React, { useCallback, useContext, useMemo, useState } from 'react';
|
|
2
2
|
import { isNil } from 'ramda';
|
|
3
|
+
import { isDCRUri } from '@reltio/mdm-sdk';
|
|
3
4
|
import DcrTaskIcon from '../../../../../icons/DcrTaskIcon';
|
|
4
|
-
import { useMdmReviewDCREnabled, useMdmUsername } from '../../../../../contexts/MdmModuleContext';
|
|
5
|
+
import { useMdmEntity, useMdmReviewDCREnabled, useMdmUsername } from '../../../../../contexts/MdmModuleContext';
|
|
5
6
|
import { GenericWorkflowTaskCard } from '../GenericWorkflowTaskCard';
|
|
6
7
|
import { AttributesChanges } from '../../../AttributesChanges';
|
|
7
8
|
import { LineDecorator } from '../../../LineDecorator';
|
|
@@ -9,11 +10,14 @@ import { useChangeRequest } from '../../../hooks/useChangeRequest';
|
|
|
9
10
|
import { getDCRUri } from '../../../helpers/common';
|
|
10
11
|
import { ReviewDCRDialog } from '../../../ReviewDCRDialog';
|
|
11
12
|
import { ReviewDCRButton } from '../../../ReviewDCRButton';
|
|
13
|
+
import { ChangeRequestEditorProvider } from '../../../contexts/ChangeRequestEditorContext';
|
|
12
14
|
import { WorkflowTasksContext } from '../../../../../contexts/WorkflowTasksContext';
|
|
13
15
|
export var DataChangeRequestTaskCard = function (_a) {
|
|
14
16
|
var task = _a.task;
|
|
15
17
|
var reviewDCREnabledByEntityType = (useContext(WorkflowTasksContext) || {}).reviewDCR;
|
|
16
18
|
var reviewDCREnabled = useMdmReviewDCREnabled();
|
|
19
|
+
var entity = useMdmEntity();
|
|
20
|
+
var isDCREntity = isDCRUri(entity === null || entity === void 0 ? void 0 : entity.uri);
|
|
17
21
|
var isReviewDCREnabled = isNil(reviewDCREnabledByEntityType) ? reviewDCREnabled : reviewDCREnabledByEntityType;
|
|
18
22
|
var username = useMdmUsername();
|
|
19
23
|
var _b = useState(false), isReviewDCRDialogOpen = _b[0], setIsReviewDCRDialogOpen = _b[1];
|
|
@@ -26,12 +30,13 @@ export var DataChangeRequestTaskCard = function (_a) {
|
|
|
26
30
|
var handleCloseReviewDCRDialog = useCallback(function () {
|
|
27
31
|
setIsReviewDCRDialogOpen(false);
|
|
28
32
|
}, []);
|
|
29
|
-
var showReviewDCRButton = isReviewDCREnabled && assignee == username;
|
|
30
|
-
var showReviewDialog = isReviewDCRDialogOpen && (showReviewDCRButton || isReviewDCREnabled);
|
|
33
|
+
var showReviewDCRButton = !isDCREntity && isReviewDCREnabled && assignee == username;
|
|
34
|
+
var showReviewDialog = !isDCREntity && isReviewDCRDialogOpen && (showReviewDCRButton || isReviewDCREnabled);
|
|
31
35
|
var customActionsSlot = useMemo(function () { return showReviewDCRButton && React.createElement(ReviewDCRButton, { onClick: handleReviewDCR }); }, [showReviewDCRButton, handleReviewDCR]);
|
|
32
36
|
return (React.createElement(React.Fragment, null,
|
|
33
37
|
React.createElement(GenericWorkflowTaskCard, { task: task, Icon: DcrTaskIcon, customActionsSlot: customActionsSlot }, dcr &&
|
|
34
38
|
groupedObjects.map(function (object, index) { return (React.createElement(LineDecorator, { key: index, last: index === groupedObjects.length - 1, divider: true },
|
|
35
39
|
React.createElement(AttributesChanges, { entityInfo: object.entity, relationsInfo: object.relations, changes: dcr.changes, objectsInfo: dcr.objectsInfo, dcrUri: dcrUri }))); })),
|
|
36
|
-
showReviewDialog && (React.createElement(
|
|
40
|
+
showReviewDialog && (React.createElement(ChangeRequestEditorProvider, null,
|
|
41
|
+
React.createElement(ReviewDCRDialog, { open: isReviewDCRDialogOpen, onClose: handleCloseReviewDCRDialog, dcr: dcr, groupedObjects: groupedObjects, task: task })))));
|
|
37
42
|
};
|
|
@@ -26,10 +26,12 @@ export var GenericWorkflowTaskCard = function (_a) {
|
|
|
26
26
|
var checkWorkflowPermission = useWorkflowCheckPermission();
|
|
27
27
|
var canViewComments = checkWorkflowPermission('VIEW_PROCESS_INSTANCE_COMMENTS');
|
|
28
28
|
var _d = useWorkflowActions({
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
task: {
|
|
30
|
+
taskId: taskId,
|
|
31
|
+
possibleActions: possibleActions,
|
|
32
|
+
assignee: assignee,
|
|
33
|
+
isOpen: isTaskOpen
|
|
34
|
+
}
|
|
33
35
|
}), workflowActions = _d.actions, actionRequestIsInProgress = _d.actionRequestIsInProgress;
|
|
34
36
|
return (React.createElement("div", { className: styles.card },
|
|
35
37
|
React.createElement("div", { className: classnames((_b = {}, _b[styles.withBackground] = isExpanded, _b)) },
|
|
@@ -10,6 +10,7 @@ export type LineData = {
|
|
|
10
10
|
type ChangeRequestEditorContextType = {
|
|
11
11
|
updateChange: (lineIds: string[], data: LineDataValue) => void;
|
|
12
12
|
getLineData: (lineId: string) => LineData | undefined;
|
|
13
|
+
getLinesByChangeId: (changeId: string) => Array<[string, LineData]>;
|
|
13
14
|
rejectChange: (lineIds: string[]) => void;
|
|
14
15
|
revertChangeUpdateOrReject: (lineIds: string[]) => void;
|
|
15
16
|
getIsParentLineRejected: (lineId: string) => boolean;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import React, { useCallback, useState } from 'react';
|
|
1
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
2
|
import { isNil } from 'ramda';
|
|
3
3
|
import { createContext } from '@fluentui/react-context-selector';
|
|
4
4
|
export var ChangeRequestEditorContext = createContext({
|
|
5
5
|
updateChange: undefined,
|
|
6
6
|
getLineData: undefined,
|
|
7
|
+
getLinesByChangeId: undefined,
|
|
7
8
|
rejectChange: undefined,
|
|
8
9
|
revertChangeUpdateOrReject: undefined,
|
|
9
10
|
getIsParentLineRejected: undefined,
|
|
@@ -13,6 +14,7 @@ export var ChangeRequestEditorContext = createContext({
|
|
|
13
14
|
export var ChangeRequestEditorProvider = function (_a) {
|
|
14
15
|
var children = _a.children;
|
|
15
16
|
var _b = useState(new Map()), lineDataMap = _b[0], setLineDataMap = _b[1];
|
|
17
|
+
var lineDataMapRef = useRef(lineDataMap);
|
|
16
18
|
var updateChange = useCallback(function (lineIds, data) {
|
|
17
19
|
setLineDataMap(function (prevMap) {
|
|
18
20
|
var newMap = new Map(prevMap);
|
|
@@ -62,9 +64,19 @@ export var ChangeRequestEditorProvider = function (_a) {
|
|
|
62
64
|
var _a;
|
|
63
65
|
return !isNil((_a = lineDataMap.get(lineId)) === null || _a === void 0 ? void 0 : _a.value);
|
|
64
66
|
}, [lineDataMap]);
|
|
67
|
+
var getLinesByChangeId = useCallback(function (changeId) {
|
|
68
|
+
return Array.from(lineDataMapRef.current).filter(function (_a) {
|
|
69
|
+
var key = _a[0], _value = _a[1];
|
|
70
|
+
return key.split('/')[1] === changeId;
|
|
71
|
+
});
|
|
72
|
+
}, []);
|
|
73
|
+
useEffect(function () {
|
|
74
|
+
lineDataMapRef.current = lineDataMap;
|
|
75
|
+
}, [lineDataMap]);
|
|
65
76
|
var contextValue = {
|
|
66
77
|
updateChange: updateChange,
|
|
67
78
|
getLineData: getLineData,
|
|
79
|
+
getLinesByChangeId: getLinesByChangeId,
|
|
68
80
|
rejectChange: rejectChange,
|
|
69
81
|
revertChangeUpdateOrReject: revertChangeUpdateOrReject,
|
|
70
82
|
getIsParentLineRejected: getIsParentLineRejected,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ChangeRequest, DCRChanges, DCRObjectInfo, DCRObjectsInfo, GroupedObjectsInfo } from '@reltio/mdm-sdk';
|
|
1
|
+
import { AttributeDelete, ChangeRequest, DCRChange, DCRChanges, DCRObjectInfo, DCRObjectsInfo, GroupedObjectsInfo, Metadata } from '@reltio/mdm-sdk';
|
|
2
|
+
import { LineData } from '../contexts/ChangeRequestEditorContext';
|
|
2
3
|
export declare const getEntitiesObjects: any;
|
|
3
4
|
export declare const getRelationsObjects: any;
|
|
4
5
|
export declare const extractObjectsFromChangeRequest: (changes: DCRChanges, objectsInfo: DCRObjectsInfo) => DCRObjectInfo[];
|
|
@@ -7,3 +8,9 @@ export declare const createEntityRelationsObjectByRelation: any;
|
|
|
7
8
|
export declare const concatEntityRelationsObjects: (acc: Record<string, GroupedObjectsInfo>, object: GroupedObjectsInfo) => Record<string, GroupedObjectsInfo>;
|
|
8
9
|
export declare const getEntityUriForChangeRequest: (dcrUri: string, entityUri: string) => string;
|
|
9
10
|
export declare const isCreateEntityOperation: (dcr: ChangeRequest) => boolean;
|
|
11
|
+
export declare const buildDCRSavePlan: (changes: DCRChanges, getLinesByChangeId: (changeId: string) => Array<[string, LineData]>, metadata: Metadata) => {
|
|
12
|
+
rejectedChangeIds: string[];
|
|
13
|
+
updatedChanges: Record<string, DCRChange[]>;
|
|
14
|
+
deleteEntityAttributes: Record<string, AttributeDelete[]>;
|
|
15
|
+
deleteRelationAttributes: Record<string, AttributeDelete[]>;
|
|
16
|
+
};
|