@reltio/components 1.4.1890 → 1.4.1892

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.
@@ -1,7 +1,7 @@
1
1
  import { WorkflowTaskData } from '@reltio/mdm-sdk';
2
2
  import { TaskAction } from '../types';
3
- type Props = Pick<WorkflowTaskData, 'taskId' | 'possibleActions' | 'assignee' | 'isOpen'>;
4
- export declare const useWorkflowActions: ({ possibleActions, assignee, taskId, isOpen }: Props) => {
3
+ type Task = Partial<Pick<WorkflowTaskData, 'taskId' | 'possibleActions' | 'assignee' | 'isOpen'>>;
4
+ export declare const useWorkflowActions: (task: Task, onActionSuccess?: (action: string) => void) => {
5
5
  actions: TaskAction[];
6
6
  actionRequestIsInProgress: boolean;
7
7
  };
@@ -7,14 +7,15 @@ var errors_1 = require("../helpers/errors");
7
7
  var common_1 = require("../helpers/common");
8
8
  var WorkflowTasksContext_1 = require("../../../contexts/WorkflowTasksContext");
9
9
  var MdmModuleContext_1 = require("../../../contexts/MdmModuleContext");
10
- var useWorkflowActions = function (_a) {
11
- var possibleActions = _a.possibleActions, assignee = _a.assignee, taskId = _a.taskId, isOpen = _a.isOpen;
12
- var onActionSuccess = ((0, react_1.useContext)(WorkflowTasksContext_1.WorkflowTasksContext) || {}).onActionSuccess;
10
+ var useWorkflowActions = function (task, onActionSuccess) {
11
+ var _a = task !== null && task !== void 0 ? task : {}, possibleActions = _a.possibleActions, assignee = _a.assignee, taskId = _a.taskId, isOpen = _a.isOpen;
12
+ var workflowTasks = (0, react_1.useContext)(WorkflowTasksContext_1.WorkflowTasksContext);
13
13
  var workflowPath = (0, MdmModuleContext_1.useMdmWorkflowPath)();
14
14
  var environment = (0, MdmModuleContext_1.useMdmWorkflowEnvironmentUrl)();
15
15
  var tenant = (0, MdmModuleContext_1.useMdmTenant)();
16
16
  var username = (0, MdmModuleContext_1.useMdmUsername)();
17
17
  var _b = (0, react_1.useState)(false), actionRequestIsInProgress = _b[0], setActionRequestIsInProgress = _b[1];
18
+ var handleActionSuccess = onActionSuccess !== null && onActionSuccess !== void 0 ? onActionSuccess : workflowTasks === null || workflowTasks === void 0 ? void 0 : workflowTasks.onActionSuccess;
18
19
  var performTaskAction = (0, react_1.useCallback)(function (action) { return function (comment) {
19
20
  if (workflowPath && taskId) {
20
21
  setActionRequestIsInProgress(true);
@@ -28,14 +29,14 @@ var useWorkflowActions = function (_a) {
28
29
  processInstanceComment: processInstanceComment
29
30
  })
30
31
  .then(function () {
31
- onActionSuccess === null || onActionSuccess === void 0 ? void 0 : onActionSuccess(action);
32
+ handleActionSuccess === null || handleActionSuccess === void 0 ? void 0 : handleActionSuccess(action);
32
33
  })
33
34
  .catch(errors_1.showWorkflowError)
34
35
  .finally(function () {
35
36
  setActionRequestIsInProgress(false);
36
37
  });
37
38
  }
38
- }; }, [workflowPath, taskId, environment, tenant, onActionSuccess]);
39
+ }; }, [workflowPath, taskId, environment, tenant, handleActionSuccess]);
39
40
  var actions = (0, react_1.useMemo)(function () {
40
41
  return username === assignee && (0, common_1.isOpenTask)(isOpen)
41
42
  ? (possibleActions || []).map(function (_a) {
@@ -1,7 +1,7 @@
1
1
  import { WorkflowTaskData } from '@reltio/mdm-sdk';
2
2
  import { TaskAction } from '../types';
3
- type Props = Pick<WorkflowTaskData, 'taskId' | 'possibleActions' | 'assignee' | 'isOpen'>;
4
- export declare const useWorkflowActions: ({ possibleActions, assignee, taskId, isOpen }: Props) => {
3
+ type Task = Partial<Pick<WorkflowTaskData, 'taskId' | 'possibleActions' | 'assignee' | 'isOpen'>>;
4
+ export declare const useWorkflowActions: (task: Task, onActionSuccess?: (action: string) => void) => {
5
5
  actions: TaskAction[];
6
6
  actionRequestIsInProgress: boolean;
7
7
  };
@@ -4,14 +4,15 @@ import { showWorkflowError } from '../helpers/errors';
4
4
  import { isOpenTask } from '../helpers/common';
5
5
  import { WorkflowTasksContext } from '../../../contexts/WorkflowTasksContext';
6
6
  import { useMdmTenant, useMdmUsername, useMdmWorkflowEnvironmentUrl, useMdmWorkflowPath } from '../../../contexts/MdmModuleContext';
7
- export var useWorkflowActions = function (_a) {
8
- var possibleActions = _a.possibleActions, assignee = _a.assignee, taskId = _a.taskId, isOpen = _a.isOpen;
9
- var onActionSuccess = (useContext(WorkflowTasksContext) || {}).onActionSuccess;
7
+ export var useWorkflowActions = function (task, onActionSuccess) {
8
+ var _a = task !== null && task !== void 0 ? task : {}, possibleActions = _a.possibleActions, assignee = _a.assignee, taskId = _a.taskId, isOpen = _a.isOpen;
9
+ var workflowTasks = useContext(WorkflowTasksContext);
10
10
  var workflowPath = useMdmWorkflowPath();
11
11
  var environment = useMdmWorkflowEnvironmentUrl();
12
12
  var tenant = useMdmTenant();
13
13
  var username = useMdmUsername();
14
14
  var _b = useState(false), actionRequestIsInProgress = _b[0], setActionRequestIsInProgress = _b[1];
15
+ var handleActionSuccess = onActionSuccess !== null && onActionSuccess !== void 0 ? onActionSuccess : workflowTasks === null || workflowTasks === void 0 ? void 0 : workflowTasks.onActionSuccess;
15
16
  var performTaskAction = useCallback(function (action) { return function (comment) {
16
17
  if (workflowPath && taskId) {
17
18
  setActionRequestIsInProgress(true);
@@ -25,14 +26,14 @@ export var useWorkflowActions = function (_a) {
25
26
  processInstanceComment: processInstanceComment
26
27
  })
27
28
  .then(function () {
28
- onActionSuccess === null || onActionSuccess === void 0 ? void 0 : onActionSuccess(action);
29
+ handleActionSuccess === null || handleActionSuccess === void 0 ? void 0 : handleActionSuccess(action);
29
30
  })
30
31
  .catch(showWorkflowError)
31
32
  .finally(function () {
32
33
  setActionRequestIsInProgress(false);
33
34
  });
34
35
  }
35
- }; }, [workflowPath, taskId, environment, tenant, onActionSuccess]);
36
+ }; }, [workflowPath, taskId, environment, tenant, handleActionSuccess]);
36
37
  var actions = useMemo(function () {
37
38
  return username === assignee && isOpenTask(isOpen)
38
39
  ? (possibleActions || []).map(function (_a) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reltio/components",
3
- "version": "1.4.1890",
3
+ "version": "1.4.1892",
4
4
  "license": "SEE LICENSE IN LICENSE FILE",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./esm/index.js",
@@ -8,7 +8,7 @@
8
8
  "@fluentui/react-context-selector": "^9.1.26",
9
9
  "@react-google-maps/api": "2.7.0",
10
10
  "@react-sigma/core": "3.4.0",
11
- "@reltio/mdm-sdk": "^1.4.1823",
11
+ "@reltio/mdm-sdk": "^1.4.1825",
12
12
  "classnames": "^2.2.5",
13
13
  "d3-cloud": "^1.2.5",
14
14
  "d3-geo": "^2.0.1",