@giteeteam/apps-team-components 1.3.2 → 1.4.1

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/README.md CHANGED
@@ -22,3 +22,6 @@ pnpm storybook
22
22
 
23
23
  # 1.3.x版本
24
24
  - team最低版本为4.23.0
25
+
26
+ # 1.4.x版本
27
+ - team最低版本为4.24.0
@@ -8,14 +8,10 @@ interface SelectTransitionProps {
8
8
  itemId: string;
9
9
  itemData: ItemResultProps;
10
10
  currentUser: Record<string, any>;
11
- workspace: string;
12
11
  setPopoverVisible: (flag: boolean) => void;
13
12
  name: string;
14
13
  objectId: string;
15
14
  workflowData: WorkflowDataProps;
16
- roleIds: string[];
17
- groupIds: string[];
18
- workspaceRoleIds: string[];
19
15
  approval: ApprovalData;
20
16
  checkIn: CheckInData;
21
17
  handleTransition: (updateTask: string, screenId: string, script: string) => void;
@@ -7,10 +7,12 @@ import { spinStyle, flowNextStyle, flowWrapperStyle, noPermissionStyle } from '.
7
7
  import TransitionButton from './TransitionButton.js';
8
8
  import View from './View.js';
9
9
 
10
- const SelectTransition = ({ fetching, flowing, tasks, itemId, itemData, currentUser, workspace, setPopoverVisible, name, objectId, workflowData, roleIds, groupIds, workspaceRoleIds, approval, checkIn, handleTransition, readonly, flowHandlerActive, }) => {
11
- return (jsx(ClassNames, { children: ({ cx, css }) => (jsxs(Fragment, { children: [fetching ? (jsx(Spin, { css: css(spinStyle) })) : tasks.length ? (jsx("div", { className: cx(css(flowNextStyle), `flow-next-global`), children: jsx("div", { className: cx(css(flowWrapperStyle)), children: tasks.map(task => {
12
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
13
- return (jsx(TransitionButton, { itemId: itemId, loading: flowing, text: task.name, item: itemData, workspace: workspace, userId: currentUser.id, groupIds: groupIds, roleIds: roleIds, workspaceRoleIds: workspaceRoleIds, currentTaskId: task.id, authUsers: (_b = (_a = task.parameters) === null || _a === void 0 ? void 0 : _a.permissionType) === null || _b === void 0 ? void 0 : _b.users, authRoles: (_d = (_c = task.parameters) === null || _c === void 0 ? void 0 : _c.permissionType) === null || _d === void 0 ? void 0 : _d.roles, authGroups: (_f = (_e = task.parameters) === null || _e === void 0 ? void 0 : _e.permissionType) === null || _f === void 0 ? void 0 : _f.groups, authUserFields: (_h = (_g = task.parameters) === null || _g === void 0 ? void 0 : _g.permissionType) === null || _h === void 0 ? void 0 : _h.customFields, authWorkSpaceRoles: (_k = (_j = task.parameters) === null || _j === void 0 ? void 0 : _j.permissionType) === null || _k === void 0 ? void 0 : _k.workspaceRoles, creatorAuth: (_m = (_l = task.parameters) === null || _l === void 0 ? void 0 : _l.permissionType) === null || _m === void 0 ? void 0 : _m.creatorAuth, scriptValidator: (_o = task.parameters) === null || _o === void 0 ? void 0 : _o.scriptValidator, conditions: (_p = task.parameters) === null || _p === void 0 ? void 0 : _p.fieldType, screenId: (_r = (_q = task.parameters) === null || _q === void 0 ? void 0 : _q.screen) === null || _r === void 0 ? void 0 : _r.key, target: task.target, approval: approval, checkIn: checkIn, handleTransition: handleTransition, hiddenPopover: () => setPopoverVisible(false), readonly: readonly, flowHandlerActive: flowHandlerActive }, task.id));
10
+ const SelectTransition = ({ fetching, flowing, tasks, setPopoverVisible, name, objectId, workflowData, handleTransition, readonly, }) => {
11
+ return (jsx(ClassNames, { children: ({ cx, css }) => (jsxs(Fragment, { children: [fetching ? (jsx(Spin, { css: css(spinStyle) })) : tasks.length ? (jsx("div", { className: cx(css(flowNextStyle), `flow-next-global`), children: jsx("div", { className: cx(css(flowWrapperStyle)), children: tasks
12
+ .filter(_task => { var _a; return !((_a = _task === null || _task === void 0 ? void 0 : _task.checkResult) === null || _a === void 0 ? void 0 : _a.isHide); })
13
+ .map(task => {
14
+ var _a, _b, _c;
15
+ return (jsx(TransitionButton, { loading: flowing, text: task.name, scriptValidator: (_a = task.parameters) === null || _a === void 0 ? void 0 : _a.scriptValidator, screenId: (_c = (_b = task.parameters) === null || _b === void 0 ? void 0 : _b.screen) === null || _c === void 0 ? void 0 : _c.key, target: task.target, handleTransition: handleTransition, readonly: readonly, conditionCheck: task === null || task === void 0 ? void 0 : task.checkResult }, task.id));
14
16
  }) }) })) : (jsx("span", { onClick: () => {
15
17
  setPopoverVisible(false);
16
18
  }, css: css(noPermissionStyle), children: i18n.t('pages.fields.view.noWorkflowOrAuth') })), jsx(View, { workflowData: workflowData, hiddenPopover: () => setPopoverVisible(false), name: name, objectId: objectId })] })) }));
@@ -1,35 +1,20 @@
1
1
  import React from 'react';
2
- import { ItemResultProps } from '../../../lib/types/item';
3
- import { ApprovalData, CheckInData, ConditionType, ListItemType, NodeItemProps } from '../../../lib/types/workflow';
4
- interface FlowButtonProps {
5
- itemId: string;
2
+ import { NodeItemProps } from '../../../lib/types/workflow';
3
+ interface TransitionButtonProps {
6
4
  loading: boolean;
7
5
  text: string;
8
6
  screenId: string;
9
- item: ItemResultProps;
10
- workspace: string;
11
- authRoles: ListItemType[] | undefined;
12
- authUsers: ListItemType[] | undefined;
13
- authGroups: ListItemType[] | undefined;
14
- authUserFields: ListItemType[] | undefined;
15
- authWorkSpaceRoles: ListItemType[] | undefined;
16
- creatorAuth: boolean | undefined;
17
7
  scriptValidator: string;
18
- userId: string;
19
- roleIds: string[];
20
- groupIds: string[];
21
- workspaceRoleIds: string[];
22
- currentTaskId: string;
23
- conditions?: ConditionType[];
24
- approval: ApprovalData;
25
- checkIn: CheckInData;
26
8
  handleTransition: (updateTask: string, screenId: string, script: string) => void;
27
9
  target: NodeItemProps & {
28
10
  type?: string;
29
11
  };
30
- hiddenPopover?: () => void;
31
12
  readonly?: boolean;
32
13
  flowHandlerActive?: boolean;
14
+ conditionCheck?: {
15
+ result: boolean;
16
+ message: string;
17
+ };
33
18
  }
34
- declare const _default: React.NamedExoticComponent<FlowButtonProps>;
19
+ declare const _default: React.NamedExoticComponent<TransitionButtonProps>;
35
20
  export default _default;
@@ -1,113 +1,22 @@
1
1
  import { jsx, jsxs, Fragment } from '@emotion/react/jsx-runtime';
2
- import { useState, useCallback, useEffect, useMemo, memo } from 'react';
2
+ import { useMemo, memo } from 'react';
3
3
  import { css, ClassNames } from '@emotion/react';
4
4
  import { Tooltip } from 'antd';
5
5
  import { WorkFlowStatusColor } from '../../../lib/global.js';
6
6
  import { i18n } from '../../../lib/i18n.js';
7
- import { checkTransition } from '../../../lib/workflow.js';
8
7
  import BaseOverflowTooltip from '../../common/overflow-tooltip/BaseOverflowTooltip.js';
9
8
  import { tipLineStyle, tooltipStyle, iconStyle, stateBoxStyle, flowStateStyle, flowBtnStyle, notAllowedStyle, pointerStyle } from './style/index.js';
10
9
 
11
- const ApprovalStatus = {
12
- approved: 'approved',
13
- rejected: 'rejected',
14
- };
15
- const CheckInStatus = {
16
- closed: 'closed',
17
- pending: 'pending',
18
- };
19
- const FlowButton = ({ loading, screenId, text, item, userId, roleIds, groupIds, workspaceRoleIds, authRoles, authUsers, authGroups, creatorAuth, authUserFields, authWorkSpaceRoles, scriptValidator, approval, checkIn, conditions = [], handleTransition, target, readonly, flowHandlerActive, }) => {
20
- const [isCheck, setIsCheck] = useState(true);
21
- const [tip, setTip] = useState('');
22
- const checkApproval = useCallback(() => {
23
- var _a;
24
- if (!approval.requireApproval)
25
- return true;
26
- const approvedTransitions = approval.transition.approved.map(approved => approved.label);
27
- const rejectedTransitions = approval.transition.rejected.map(rejected => rejected.label);
28
- const unrestrictedTransitions = ((_a = approval.transition.unrestricted) === null || _a === void 0 ? void 0 : _a.map(unrestricted => unrestricted.label)) || [];
29
- if ((ApprovalStatus.approved === approval.approvalStatus && approvedTransitions.includes(text)) ||
30
- (ApprovalStatus.rejected === approval.approvalStatus && rejectedTransitions.includes(text))) {
31
- return true;
32
- }
33
- if (![ApprovalStatus.approved, ApprovalStatus.rejected].includes(approval.approvalStatus) &&
34
- (unrestrictedTransitions === null || unrestrictedTransitions === void 0 ? void 0 : unrestrictedTransitions.includes(text))) {
35
- if (!approval.startApproval) {
36
- return true;
37
- }
38
- else {
39
- setTip(i18n.t('pages.fields.view.unrestrictedStatus'));
40
- return false;
41
- }
42
- }
43
- setTip(i18n.t('pages.fields.view.approvalStatus'));
44
- return false;
45
- }, [approval, text]);
46
- const validateCheckIn = useCallback(() => {
47
- if (!checkIn.requireCheckIn)
48
- return true;
49
- if (checkIn.checkInStatus !== CheckInStatus.pending) {
50
- return true;
51
- }
52
- return false;
53
- }, [checkIn]);
54
- const checkAuth = useCallback(async () => {
55
- setIsCheck(true);
56
- if (!checkApproval()) {
57
- setIsCheck(false);
58
- return;
59
- }
60
- if (!validateCheckIn()) {
61
- setTip(i18n.t('pages.fields.view.checkInStatus'));
62
- setIsCheck(false);
63
- return;
64
- }
65
- const transition = {
66
- parameters: {
67
- fieldType: conditions,
68
- permissionType: {
69
- users: authUsers,
70
- roles: authRoles,
71
- groups: authGroups,
72
- workspaceRoles: authWorkSpaceRoles,
73
- customFields: authUserFields,
74
- creatorAuth,
75
- },
76
- },
77
- };
78
- const checkResult = checkTransition(item, transition, { userId, roleIds, groupIds, workspaceRoleIds }, flowHandlerActive);
79
- if (!checkResult.result) {
80
- setTip(checkResult.message);
81
- setIsCheck(false);
82
- }
83
- }, [
84
- checkApproval,
85
- validateCheckIn,
86
- conditions,
87
- authUsers,
88
- authRoles,
89
- authGroups,
90
- authWorkSpaceRoles,
91
- authUserFields,
92
- creatorAuth,
93
- item,
94
- userId,
95
- roleIds,
96
- groupIds,
97
- workspaceRoleIds,
98
- flowHandlerActive,
99
- ]);
100
- useEffect(() => {
101
- checkAuth();
102
- }, [checkAuth]);
10
+ const TransitionButton = ({ loading, screenId, text, scriptValidator, handleTransition, target, readonly, conditionCheck, }) => {
103
11
  const tipContent = useMemo(() => {
12
+ const _tip = conditionCheck.message;
104
13
  if (readonly)
105
14
  return i18n.t('pages.fields.view.readonlyStatus');
106
- if (!tip)
15
+ if (!_tip)
107
16
  return '';
108
- const contents = tip.split('--');
17
+ const contents = _tip.split('--');
109
18
  return (jsx("div", { children: contents.map((text, index) => (jsx("p", { css: css(tipLineStyle), children: text }, String(index)))) }));
110
- }, [tip, readonly]);
19
+ }, [readonly, conditionCheck]);
111
20
  const OverflowText = ({ text, target }) => {
112
21
  var _a, _b;
113
22
  return (jsxs(Fragment, { children: [jsx(BaseOverflowTooltip, { css: css(tooltipStyle), title: text, children: text }), jsx("span", { css: css(iconStyle), children: " \u2192 " }), jsx("div", { css: css(stateBoxStyle), children: jsx(BaseOverflowTooltip, { css: css(flowStateStyle), style: {
@@ -116,13 +25,13 @@ const FlowButton = ({ loading, screenId, text, item, userId, roleIds, groupIds,
116
25
  }, title: target.name, children: target.name }) })] }));
117
26
  };
118
27
  return (jsx(ClassNames, { children: ({ cx, css }) => {
119
- return isCheck && !readonly ? (jsx("div", { className: cx(css(flowBtnStyle), loading ? css(notAllowedStyle) : css(pointerStyle)), onClick: () => {
28
+ return conditionCheck ? ((conditionCheck === null || conditionCheck === void 0 ? void 0 : conditionCheck.result) && !readonly ? (jsx("div", { className: cx(css(flowBtnStyle), loading ? css(notAllowedStyle) : css(pointerStyle)), onClick: () => {
120
29
  if (!loading) {
121
30
  handleTransition(text, screenId, scriptValidator);
122
31
  }
123
- }, children: jsx(OverflowText, { text: text, target: target }) })) : (jsx(Tooltip, { title: tipContent, placement: "right", children: jsx("div", { className: cx(css(flowBtnStyle), css(notAllowedStyle)), children: jsx(OverflowText, { text: text, target: target }) }) }));
32
+ }, children: jsx(OverflowText, { text: text, target: target }) })) : (jsx(Tooltip, { title: tipContent, placement: "right", children: jsx("div", { className: cx(css(flowBtnStyle), css(notAllowedStyle)), children: jsx(OverflowText, { text: text, target: target }) }) }))) : null;
124
33
  } }));
125
34
  };
126
- var TransitionButton = memo(FlowButton);
35
+ var TransitionButton$1 = memo(TransitionButton);
127
36
 
128
- export { TransitionButton as default };
37
+ export { TransitionButton$1 as default };
@@ -8,7 +8,7 @@ import { cloneDeep } from 'lodash-es';
8
8
  import useCurrentUser from '../../../lib/hooks/useCurrentUser.js';
9
9
  import useWorkflowConfig from '../../../lib/hooks/useWorkflowConfig.js';
10
10
  import { i18n } from '../../../lib/i18n.js';
11
- import { useWorkflowPermission, getScriptUser } from '../../../lib/workflow.js';
11
+ import { useWorkflowPermission, checkFlowHandler, getScriptUser } from '../../../lib/workflow.js';
12
12
  import { useItem } from '../../item/hooks.js';
13
13
  import SelectFlowHandler from './SelectFlowHandler.js';
14
14
  import SelectTransition from './SelectTransition.js';
@@ -27,6 +27,14 @@ const DEFAULT_APPROVAL_DATA = {
27
27
  startApproval: false,
28
28
  };
29
29
  const DEFAULT_CHECK_IN_DATA = { requireCheckIn: false, checkInStatus: '', transition: null };
30
+ const ApprovalStatus = {
31
+ approved: 'approved',
32
+ rejected: 'rejected',
33
+ };
34
+ const CheckInStatus = {
35
+ closed: 'closed',
36
+ pending: 'pending',
37
+ };
30
38
  const TransitionPanel = ({ itemId, itemType, workspace, objectId, onTransitionSuccess, name, readonly, setPopoverVisible, isProcessing, flowing, setFlowing, flowHandlerActive, flowUsers, loadingFlowUsers, fetchFlowUsers, }) => {
31
39
  var _a;
32
40
  const [updateTransitionText, setUpdateTransitionText] = useState('');
@@ -46,12 +54,69 @@ const TransitionPanel = ({ itemId, itemType, workspace, objectId, onTransitionSu
46
54
  newItem.current = itemId;
47
55
  };
48
56
  }, [itemId, objectId]);
49
- const { checkTransitionScript, getWorkflowData, getItemStatus, runTransition } = useWorkflowConfig();
57
+ const { checkTransitionScript, getWorkflowData, getItemStatus, runTransition, postCheckTransitions, hideDisabledStatusTransition, } = useWorkflowConfig();
50
58
  const { currentUser } = useCurrentUser();
51
- const [groupIds, roleIds, workspaceRoleIds] = useWorkflowPermission((_a = itemData === null || itemData === void 0 ? void 0 : itemData.workspace) === null || _a === void 0 ? void 0 : _a.objectId);
59
+ const [groupIds, , workspaceRoleIds] = useWorkflowPermission((_a = itemData === null || itemData === void 0 ? void 0 : itemData.workspace) === null || _a === void 0 ? void 0 : _a.objectId);
52
60
  const [tasks, setTasks] = useState([]);
53
61
  const [workflowData, setWorkflowData] = useState({ nodes: [], transitions: [] });
54
- const updateWorkflowMessage = useCallback((workflowData, statusId) => {
62
+ const [checkResultList, setCheckResultList] = useState([]);
63
+ const checkApproval = useCallback(({ text }) => {
64
+ var _a;
65
+ if (!approval.requireApproval)
66
+ return [true];
67
+ const approvedTransitions = approval.transition.approved.map(approved => approved.label);
68
+ const rejectedTransitions = approval.transition.rejected.map(rejected => rejected.label);
69
+ const unrestrictedTransitions = ((_a = approval.transition.unrestricted) === null || _a === void 0 ? void 0 : _a.map(unrestricted => unrestricted.label)) || [];
70
+ if ((ApprovalStatus.approved === approval.approvalStatus && approvedTransitions.includes(text)) ||
71
+ (ApprovalStatus.rejected === approval.approvalStatus && rejectedTransitions.includes(text))) {
72
+ return [true];
73
+ }
74
+ if (![ApprovalStatus.approved, ApprovalStatus.rejected].includes(approval.approvalStatus) &&
75
+ (unrestrictedTransitions === null || unrestrictedTransitions === void 0 ? void 0 : unrestrictedTransitions.includes(text))) {
76
+ if (!approval.startApproval) {
77
+ return [true];
78
+ }
79
+ else {
80
+ return [false, i18n.t('pages.fields.view.unrestrictedStatus')];
81
+ }
82
+ }
83
+ return [false, i18n.t('pages.fields.view.approvalStatus')];
84
+ }, [approval]);
85
+ const validateCheckIn = useCallback(() => {
86
+ if (!checkIn.requireCheckIn)
87
+ return true;
88
+ if (checkIn.checkInStatus !== CheckInStatus.pending) {
89
+ return true;
90
+ }
91
+ return false;
92
+ }, [checkIn]);
93
+ const checkOneTransition = useCallback(({ text, conditionCheck }) => {
94
+ const [checkApprovalResult, checkApprovalMessage] = checkApproval({ text });
95
+ if (!checkApprovalResult) {
96
+ return {
97
+ result: false,
98
+ message: checkApprovalMessage,
99
+ };
100
+ }
101
+ if (!validateCheckIn()) {
102
+ return {
103
+ result: false,
104
+ message: i18n.t('pages.fields.view.checkInStatus'),
105
+ };
106
+ }
107
+ const checkResult = checkFlowHandler(itemData, { userId: currentUser.id }, flowHandlerActive);
108
+ if (checkResult && !checkResult.result) {
109
+ return checkResult;
110
+ }
111
+ if (!(conditionCheck === null || conditionCheck === void 0 ? void 0 : conditionCheck.result) && conditionCheck) {
112
+ if (hideDisabledStatusTransition === 'enabled') {
113
+ return { result: false, isHide: true };
114
+ }
115
+ return conditionCheck;
116
+ }
117
+ return { result: true };
118
+ }, [checkApproval, currentUser, flowHandlerActive, hideDisabledStatusTransition, validateCheckIn, itemData]);
119
+ const getTheTargetTransitions = useCallback(({ workflowData, statusId }) => {
55
120
  var _a;
56
121
  if (workflowData && statusId) {
57
122
  const transitions = workflowData.transitions || [];
@@ -65,6 +130,12 @@ const TransitionPanel = ({ itemId, itemType, workspace, objectId, onTransitionSu
65
130
  arr[i].target.type = nodes[index].key || nodes[index].statusType;
66
131
  }
67
132
  const list = ((_a = workflowData.transitions) === null || _a === void 0 ? void 0 : _a.filter(transition => transition.source.key === statusId)) || [];
133
+ return list;
134
+ }
135
+ }, []);
136
+ const updateWorkflowMessage = useCallback((workflowData, statusId, checkResultList) => {
137
+ const list = getTheTargetTransitions({ workflowData, statusId });
138
+ if (list.length > 0) {
68
139
  const sortList = list.map(item => {
69
140
  var _a;
70
141
  const propertiesListItem = (_a = item.properties) === null || _a === void 0 ? void 0 : _a.find(v => v.key === PROPERTY_ACTION_SORT_KEY);
@@ -77,12 +148,21 @@ const TransitionPanel = ({ itemId, itemType, workspace, objectId, onTransitionSu
77
148
  return item;
78
149
  });
79
150
  sortList.sort((item1, item2) => item1.orderNumber - item2.orderNumber);
80
- setTasks(sortList);
151
+ const _sortList = sortList.map(_task => {
152
+ var _a;
153
+ const conditionCheck = (_a = checkResultList.find(_checkResult => _checkResult.transitionId === _task.id)) === null || _a === void 0 ? void 0 : _a.result;
154
+ const allResult = checkOneTransition({ text: _task.name, conditionCheck });
155
+ return {
156
+ ..._task,
157
+ checkResult: allResult,
158
+ };
159
+ });
160
+ setTasks(_sortList);
81
161
  const { approval, checkIn } = getWorkflowConfig(workflowData, statusId);
82
162
  setApproval(approval);
83
163
  setCheckIn(checkIn);
84
164
  }
85
- }, []);
165
+ }, [checkOneTransition, getTheTargetTransitions]);
86
166
  const refresh = useCallback(async () => {
87
167
  try {
88
168
  if (!itemId) {
@@ -92,21 +172,38 @@ const TransitionPanel = ({ itemId, itemType, workspace, objectId, onTransitionSu
92
172
  const workflowData = await (getWorkflowData === null || getWorkflowData === void 0 ? void 0 : getWorkflowData(itemId));
93
173
  if (workflowData) {
94
174
  setWorkflowData(workflowData);
95
- updateWorkflowMessage(workflowData, statusId);
175
+ const targetList = getTheTargetTransitions({ workflowData, statusId });
176
+ if (targetList.length > 0) {
177
+ const checkResultList = await postCheckTransitions(targetList.map(_transition => ({
178
+ transitionId: _transition.id,
179
+ itemId,
180
+ workflowId: workflowData.objectId,
181
+ })));
182
+ setCheckResultList(checkResultList);
183
+ updateWorkflowMessage(workflowData, statusId, checkResultList);
184
+ }
96
185
  }
97
186
  }
98
187
  finally {
99
188
  setFetching(false);
100
189
  }
101
- }, [itemId, statusId, updateWorkflowMessage, getWorkflowData]);
190
+ }, [
191
+ itemId,
192
+ itemData,
193
+ statusId,
194
+ updateWorkflowMessage,
195
+ getWorkflowData,
196
+ postCheckTransitions,
197
+ getTheTargetTransitions,
198
+ ]);
102
199
  useEffect(() => {
103
200
  logger('refresh workflow');
104
201
  refresh();
105
202
  }, []);
106
203
  useEffect(() => {
107
204
  logger('updateWorkflowMessage', statusId);
108
- updateWorkflowMessage(workflowData, statusId);
109
- }, [statusId]);
205
+ updateWorkflowMessage(workflowData, statusId, checkResultList);
206
+ }, [statusId, workflowData, checkResultList, itemData]);
110
207
  const refreshItem = useCallback((status) => {
111
208
  if (newItem.current !== itemId) {
112
209
  return;
@@ -256,7 +353,7 @@ const TransitionPanel = ({ itemId, itemType, workspace, objectId, onTransitionSu
256
353
  refreshFlag.current++;
257
354
  refresh();
258
355
  });
259
- return (jsx(ClassNames, { children: () => transitionStep === TransitionStepType.SelectFlowHandler ? (jsx(SelectFlowHandler, { itemId: itemId, task: flowTask, onBack: () => setTransitionStep(TransitionStepType.SelectTransition), users: flowUsers, loading: flowing, loadingUser: loadingFlowUsers, fetchUsers: fetchFlowUsers, handleTransition: handleTransition })) : (jsx(SelectTransition, { fetching: fetching, flowing: flowing, tasks: tasks, itemId: itemId, itemData: itemData, currentUser: currentUser, workspace: workspace, setPopoverVisible: setPopoverVisible, name: name, objectId: objectId, workflowData: workflowData, roleIds: roleIds, groupIds: groupIds, workspaceRoleIds: workspaceRoleIds, approval: approval, checkIn: checkIn, handleTransition: handleTransition, readonly: readonly, flowHandlerActive: flowHandlerActive })) }));
356
+ return (jsx(ClassNames, { children: () => transitionStep === TransitionStepType.SelectFlowHandler ? (jsx(SelectFlowHandler, { itemId: itemId, task: flowTask, onBack: () => setTransitionStep(TransitionStepType.SelectTransition), users: flowUsers, loading: flowing, loadingUser: loadingFlowUsers, fetchUsers: fetchFlowUsers, handleTransition: handleTransition })) : (jsx(SelectTransition, { fetching: fetching, flowing: flowing, tasks: tasks, itemId: itemId, itemData: itemData, currentUser: currentUser, setPopoverVisible: setPopoverVisible, name: name, objectId: objectId, workflowData: workflowData, approval: approval, checkIn: checkIn, handleTransition: handleTransition, readonly: readonly, flowHandlerActive: flowHandlerActive })) }));
260
357
  };
261
358
  function getWorkflowConfig(workflow, statusId) {
262
359
  var _a, _b, _c, _d, _e;
@@ -5,6 +5,8 @@ export interface IWorkflowConfig {
5
5
  getWorkflowData?: (itemId: string) => Promise<any>;
6
6
  runTransition?: (params: Record<string, any>) => Promise<any>;
7
7
  getItemStatus?: (itemId: string) => Promise<any>;
8
+ postCheckTransitions?: (params: Record<string, any>[]) => Promise<any>;
9
+ hideDisabledStatusTransition?: string;
8
10
  }
9
11
  export interface IWorkflowConfigContext {
10
12
  workflow?: IWorkflowConfig;
@@ -107,5 +107,6 @@ interface CheckUserPermissionParams {
107
107
  export declare function checkUserPermission({ transition, userId, roleIds, groupIds, item, workspaceRoleIds, }: CheckUserPermissionParams): ResultType;
108
108
  export declare function checkItemCondition(transition: TransitionProps, item: ItemResultProps): ResultType;
109
109
  export declare function checkTransition(item: ItemResultProps, transition: TransitionProps, permissions: WorkflowPermissionType, flowHandlerActive?: boolean): ResultType;
110
+ export declare function checkFlowHandler(item: ItemResultProps, permissions: WorkflowPermissionType, flowHandlerActive?: boolean): ResultType;
110
111
  export declare const useWorkflowPermission: (workspaceId: ObjectId) => [ObjectId[], ObjectId[], ObjectId[]];
111
112
  export {};
@@ -375,6 +375,25 @@ function checkTransition(item, transition, permissions, flowHandlerActive) {
375
375
  return conditionCheck;
376
376
  return { result: true };
377
377
  }
378
+ function checkFlowHandler(item, permissions, flowHandlerActive) {
379
+ var _a, _b;
380
+ if (!item)
381
+ return { result: false };
382
+ if (flowHandlerActive && ((_b = (_a = item === null || item === void 0 ? void 0 : item.values) === null || _a === void 0 ? void 0 : _a.flowHandler) === null || _b === void 0 ? void 0 : _b.length)) {
383
+ const flowHandler = item.values.flowHandler;
384
+ const flowUser = flowHandler.find(user => user.value === permissions.userId);
385
+ if (flowUser) {
386
+ return { result: true };
387
+ }
388
+ else {
389
+ const tipUsers = flowHandler.map(user => user.label).join('、');
390
+ return {
391
+ result: false,
392
+ message: i18n.t('libs.default.tipText', { text: `${i18n.t('libs.workflow.flowHandler')}:${tipUsers}` }),
393
+ };
394
+ }
395
+ }
396
+ }
378
397
  const useWorkflowPermission = (workspaceId) => {
379
398
  const [roles, setRoles] = useState([]);
380
399
  const [groups, setGroups] = useState([]);
@@ -397,4 +416,4 @@ const useWorkflowPermission = (workspaceId) => {
397
416
  return [groups, roles, workspaceRoles];
398
417
  };
399
418
 
400
- export { DropdownConditions, ElementEnum, EmptyConditionList, NodeEnum, NumberConditions, StringConditions, checkItemCondition, checkTransition, checkUserPermission, getScriptUser, isEmptyCondition, useWorkflowPermission };
419
+ export { DropdownConditions, ElementEnum, EmptyConditionList, NodeEnum, NumberConditions, StringConditions, checkFlowHandler, checkItemCondition, checkTransition, checkUserPermission, getScriptUser, isEmptyCondition, useWorkflowPermission };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@giteeteam/apps-team-components",
3
- "version": "1.3.2",
3
+ "version": "1.4.1",
4
4
  "description": "Gitee team components",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",