@giteeteam/apps-team-components 1.2.2-alpha.4 → 1.2.3-alpha.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/dist/components/fields/dropdown/ReadView.js +16 -1
- package/dist/components/fields/status/SelectTransition.js +30 -4
- package/dist/components/fields/status/TransitionButton.d.ts +6 -0
- package/dist/components/fields/status/TransitionButton.js +18 -9
- package/dist/lib/contexts/workflowConfig.d.ts +2 -0
- package/dist/lib/workflow.d.ts +1 -0
- package/dist/lib/workflow.js +19 -0
- package/package.json +1 -2
|
@@ -58,7 +58,22 @@ const DropdownReadView = memo(props => {
|
|
|
58
58
|
return optionsMap[label] ? getFormattedLabel(optionsMap[label]) : label;
|
|
59
59
|
}
|
|
60
60
|
}, [mode, options, optionsMap, value]);
|
|
61
|
-
|
|
61
|
+
const showValueTitle = useMemo(() => {
|
|
62
|
+
var _a;
|
|
63
|
+
if (!(value === null || value === void 0 ? void 0 : value.length))
|
|
64
|
+
return '';
|
|
65
|
+
if ((_a = value[0]) === null || _a === void 0 ? void 0 : _a.label) {
|
|
66
|
+
return value.map(item => item.label).join(',');
|
|
67
|
+
}
|
|
68
|
+
if (!(options === null || options === void 0 ? void 0 : options.length))
|
|
69
|
+
return '';
|
|
70
|
+
const result = value
|
|
71
|
+
.map(item => { var _a; return (item === null || item === void 0 ? void 0 : item.label) || ((_a = options.find(opt => opt.value === handleValue(item))) === null || _a === void 0 ? void 0 : _a.label); })
|
|
72
|
+
.filter(Boolean)
|
|
73
|
+
.join(',');
|
|
74
|
+
return result;
|
|
75
|
+
}, [options, value]);
|
|
76
|
+
return (_jsx(_Fragment, { children: showValue ? (_jsx(SimpleOverflowToolTip, { title: showValueTitle, children: showValue })) : (_jsx(EmptyField, { readonly: readonly })) }));
|
|
62
77
|
});
|
|
63
78
|
DropdownReadView.displayName = 'DropdownReadView';
|
|
64
79
|
export default DropdownReadView;
|
|
@@ -1,15 +1,41 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
-
import { memo } from 'react';
|
|
2
|
+
import { memo, useCallback, useEffect, useState } from 'react';
|
|
3
3
|
import { ClassNames } from '@emotion/react';
|
|
4
4
|
import { Spin } from 'antd';
|
|
5
|
+
import useWorkflowConfig from '../../../lib/hooks/useWorkflowConfig';
|
|
5
6
|
import { i18n } from '../../../lib/i18n';
|
|
6
7
|
import { flowNextStyle, flowWrapperStyle, noPermissionStyle, spinStyle } from './style';
|
|
7
8
|
import TransitionButton from './TransitionButton';
|
|
8
9
|
import View from './View';
|
|
9
10
|
const SelectTransition = ({ fetching, flowing, tasks, itemId, itemData, currentUser, workspace, setPopoverVisible, name, objectId, workflowData, roleIds, groupIds, workspaceRoleIds, approval, checkIn, handleTransition, readonly, flowHandlerActive, }) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
const [init, setInit] = useState(false);
|
|
12
|
+
const { postCheckTransitions, hideDisabledStatusTransition } = useWorkflowConfig();
|
|
13
|
+
const [checkResultList, setCheckResultList] = useState([]);
|
|
14
|
+
const [hideIds, setHideIds] = useState([]);
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
if (!init && workflowData.objectId && tasks.length && postCheckTransitions && itemId) {
|
|
17
|
+
setInit(true);
|
|
18
|
+
postCheckTransitions(tasks.map(_transition => ({
|
|
19
|
+
transitionId: _transition.id,
|
|
20
|
+
itemId,
|
|
21
|
+
workflowId: workflowData.objectId,
|
|
22
|
+
}))).then(checkResultList => {
|
|
23
|
+
setCheckResultList(checkResultList);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}, [init, itemId, workflowData, postCheckTransitions, tasks]);
|
|
27
|
+
const handleHide = useCallback(id => {
|
|
28
|
+
setHideIds(c => {
|
|
29
|
+
if (!c.includes(id)) {
|
|
30
|
+
return c.concat(id);
|
|
31
|
+
}
|
|
32
|
+
return c;
|
|
33
|
+
});
|
|
34
|
+
}, []);
|
|
35
|
+
const isAllHide = tasks.every(task => hideIds.includes(task.id));
|
|
36
|
+
return (_jsx(ClassNames, { children: ({ cx, css }) => (_jsxs(_Fragment, { children: [fetching ? (_jsx(Spin, { css: css(spinStyle) })) : tasks.length && !isAllHide ? (_jsx("div", { className: cx(css(flowNextStyle), `flow-next-global`), children: _jsx("div", { className: cx(css(flowWrapperStyle)), children: tasks.map(task => {
|
|
37
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
38
|
+
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, conditionKey: (_s = task.parameters) === null || _s === void 0 ? void 0 : _s.conditionKey, fieldTypeConditionKey: (_t = task.parameters) === null || _t === void 0 ? void 0 : _t.fieldTypeConditionKey, userConditionKey: (_v = (_u = task.parameters) === null || _u === void 0 ? void 0 : _u.permissionType) === null || _v === void 0 ? void 0 : _v.conditionKey, conditionCheck: (_w = checkResultList.find(checkResult => checkResult.transitionId === task.id)) === null || _w === void 0 ? void 0 : _w.result, hideDisabledStatusTransition: hideDisabledStatusTransition, onHide: handleHide }, task.id));
|
|
13
39
|
}) }) })) : (_jsx("span", { onClick: () => {
|
|
14
40
|
setPopoverVisible(false);
|
|
15
41
|
}, css: css(noPermissionStyle), children: i18n.t('pages.fields.view.noWorkflowOrAuth') })), _jsx(View, { workflowData: workflowData, hiddenPopover: () => setPopoverVisible(false), name: name, objectId: objectId })] })) }));
|
|
@@ -33,6 +33,12 @@ interface FlowButtonProps {
|
|
|
33
33
|
fieldTypeConditionKey: string;
|
|
34
34
|
userConditionKey: string;
|
|
35
35
|
flowHandlerActive?: boolean;
|
|
36
|
+
conditionCheck?: {
|
|
37
|
+
result: boolean;
|
|
38
|
+
message: string;
|
|
39
|
+
};
|
|
40
|
+
hideDisabledStatusTransition?: string;
|
|
41
|
+
onHide?: (id: string) => void;
|
|
36
42
|
}
|
|
37
43
|
declare const _default: React.NamedExoticComponent<FlowButtonProps>;
|
|
38
44
|
export default _default;
|
|
@@ -4,7 +4,7 @@ import { ClassNames, css } from '@emotion/react';
|
|
|
4
4
|
import { Tooltip } from 'antd';
|
|
5
5
|
import { WorkFlowStatusColor } from '../../../lib/global';
|
|
6
6
|
import { i18n } from '../../../lib/i18n';
|
|
7
|
-
import {
|
|
7
|
+
import { checkFlowHandler } from '../../../lib/workflow';
|
|
8
8
|
import BaseOverflowTooltip from '../../common/overflow-tooltip/BaseOverflowTooltip';
|
|
9
9
|
import { flowBtnStyle, flowStateStyle, iconStyle, notAllowedStyle, pointerStyle, stateBoxStyle, tipLineStyle, tooltipStyle, } from './style';
|
|
10
10
|
const ApprovalStatus = {
|
|
@@ -15,9 +15,10 @@ const CheckInStatus = {
|
|
|
15
15
|
closed: 'closed',
|
|
16
16
|
pending: 'pending',
|
|
17
17
|
};
|
|
18
|
-
const FlowButton = ({ loading, screenId, text, item, userId,
|
|
18
|
+
const FlowButton = ({ loading, screenId, text, item, userId, authRoles, authUsers, authGroups, creatorAuth, authUserFields, authWorkSpaceRoles, scriptValidator, approval, checkIn, conditions = [], handleTransition, target, readonly, conditionKey, fieldTypeConditionKey, userConditionKey, flowHandlerActive, conditionCheck, hideDisabledStatusTransition, onHide, currentTaskId, }) => {
|
|
19
19
|
const [isCheck, setIsCheck] = useState(true);
|
|
20
20
|
const [tip, setTip] = useState('');
|
|
21
|
+
const [hide, setHide] = useState(false);
|
|
21
22
|
const checkApproval = useCallback(() => {
|
|
22
23
|
var _a;
|
|
23
24
|
if (!approval.requireApproval)
|
|
@@ -77,12 +78,20 @@ const FlowButton = ({ loading, screenId, text, item, userId, roleIds, groupIds,
|
|
|
77
78
|
fieldTypeConditionKey,
|
|
78
79
|
},
|
|
79
80
|
};
|
|
80
|
-
|
|
81
|
-
if (!checkResult
|
|
82
|
-
|
|
81
|
+
let checkResult = checkFlowHandler(item, transition, { userId }, flowHandlerActive);
|
|
82
|
+
if (!checkResult) {
|
|
83
|
+
checkResult = conditionCheck;
|
|
84
|
+
}
|
|
85
|
+
if (!(checkResult === null || checkResult === void 0 ? void 0 : checkResult.result)) {
|
|
86
|
+
setTip(checkResult === null || checkResult === void 0 ? void 0 : checkResult.message);
|
|
83
87
|
setIsCheck(false);
|
|
88
|
+
if (hideDisabledStatusTransition === 'enabled') {
|
|
89
|
+
setHide(true);
|
|
90
|
+
onHide(currentTaskId);
|
|
91
|
+
}
|
|
84
92
|
}
|
|
85
93
|
}, [
|
|
94
|
+
hideDisabledStatusTransition,
|
|
86
95
|
checkApproval,
|
|
87
96
|
validateCheckIn,
|
|
88
97
|
conditions,
|
|
@@ -94,13 +103,13 @@ const FlowButton = ({ loading, screenId, text, item, userId, roleIds, groupIds,
|
|
|
94
103
|
creatorAuth,
|
|
95
104
|
item,
|
|
96
105
|
userId,
|
|
97
|
-
roleIds,
|
|
98
|
-
groupIds,
|
|
99
|
-
workspaceRoleIds,
|
|
100
106
|
conditionKey,
|
|
101
107
|
fieldTypeConditionKey,
|
|
102
108
|
userConditionKey,
|
|
103
109
|
flowHandlerActive,
|
|
110
|
+
conditionCheck,
|
|
111
|
+
onHide,
|
|
112
|
+
currentTaskId,
|
|
104
113
|
]);
|
|
105
114
|
useEffect(() => {
|
|
106
115
|
checkAuth();
|
|
@@ -125,7 +134,7 @@ const FlowButton = ({ loading, screenId, text, item, userId, roleIds, groupIds,
|
|
|
125
134
|
if (!loading) {
|
|
126
135
|
handleTransition(text, screenId, scriptValidator);
|
|
127
136
|
}
|
|
128
|
-
}, 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 }) }) }));
|
|
137
|
+
}, children: _jsx(OverflowText, { text: text, target: target }) })) : hide ? null : (_jsx(Tooltip, { title: tipContent, placement: "right", children: _jsx("div", { className: cx(css(flowBtnStyle), css(notAllowedStyle)), children: _jsx(OverflowText, { text: text, target: target }) }) }));
|
|
129
138
|
} }));
|
|
130
139
|
};
|
|
131
140
|
export default memo(FlowButton);
|
|
@@ -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;
|
package/dist/lib/workflow.d.ts
CHANGED
|
@@ -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, transition: TransitionProps, permissions: WorkflowPermissionType, flowHandlerActive?: boolean): ResultType;
|
|
110
111
|
export declare const useWorkflowPermission: (workspaceId: ObjectId) => [ObjectId[], ObjectId[], ObjectId[]];
|
|
111
112
|
export {};
|
package/dist/lib/workflow.js
CHANGED
|
@@ -440,6 +440,25 @@ export function checkTransition(item, transition, permissions, flowHandlerActive
|
|
|
440
440
|
}
|
|
441
441
|
}
|
|
442
442
|
}
|
|
443
|
+
export function checkFlowHandler(item, transition, permissions, flowHandlerActive) {
|
|
444
|
+
var _a, _b;
|
|
445
|
+
if (!item || !transition)
|
|
446
|
+
return { result: false };
|
|
447
|
+
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)) {
|
|
448
|
+
const flowHandler = item.values.flowHandler;
|
|
449
|
+
const flowUser = flowHandler.find(user => user.value === permissions.userId);
|
|
450
|
+
if (flowUser) {
|
|
451
|
+
return { result: true };
|
|
452
|
+
}
|
|
453
|
+
else {
|
|
454
|
+
const tipUsers = flowHandler.map(user => user.label).join('、');
|
|
455
|
+
return {
|
|
456
|
+
result: false,
|
|
457
|
+
message: i18n.t('libs.default.tipText', { text: `${i18n.t('libs.workflow.flowHandler')}:${tipUsers}` }),
|
|
458
|
+
};
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
}
|
|
443
462
|
export const useWorkflowPermission = (workspaceId) => {
|
|
444
463
|
const [roles, setRoles] = useState([]);
|
|
445
464
|
const [groups, setGroups] = useState([]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@giteeteam/apps-team-components",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3-alpha.1",
|
|
4
4
|
"description": "Gitee team components",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -64,7 +64,6 @@
|
|
|
64
64
|
"@emotion/cache": "^11.11.0",
|
|
65
65
|
"@emotion/react": "^11.11.1",
|
|
66
66
|
"debug": "^4.3.4",
|
|
67
|
-
"fs-extra": "^11.2.0",
|
|
68
67
|
"lodash-es": "^4.17.21"
|
|
69
68
|
}
|
|
70
69
|
}
|