@giteeteam/apps-team-components 1.11.2 → 1.11.3
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.
|
@@ -62,25 +62,46 @@ const TransitionPanel = ({ itemId, itemType, workspace, objectId, onTransitionSu
|
|
|
62
62
|
const [workflowData, setWorkflowData] = useState({ nodes: [], transitions: [] });
|
|
63
63
|
const [checkResultList, setCheckResultList] = useState([]);
|
|
64
64
|
const checkApproval = useCallback(({ text }) => {
|
|
65
|
-
var _a, _b;
|
|
66
65
|
if (!approval.requireApproval)
|
|
67
66
|
return [true];
|
|
68
|
-
const
|
|
69
|
-
const
|
|
70
|
-
const
|
|
71
|
-
const
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
67
|
+
const getTransitionLabels = type => { var _a; return ((_a = approval.transition[type]) === null || _a === void 0 ? void 0 : _a.map(item => item.label)) || []; };
|
|
68
|
+
const approvedTransitions = getTransitionLabels('approved');
|
|
69
|
+
const rejectedTransitions = getTransitionLabels('rejected');
|
|
70
|
+
const unrestrictedTransitions = getTransitionLabels('unrestricted');
|
|
71
|
+
const noResultRestrictions = getTransitionLabels('noResultRestriction');
|
|
72
|
+
const allConfiguredTransitions = [
|
|
73
|
+
...rejectedTransitions,
|
|
74
|
+
...approvedTransitions,
|
|
75
|
+
...unrestrictedTransitions,
|
|
76
|
+
...noResultRestrictions,
|
|
77
|
+
];
|
|
78
|
+
if (!allConfiguredTransitions.includes(text)) {
|
|
79
|
+
return [false, i18n.t('pages.fields.view.noWorkflowOrAuth')];
|
|
80
|
+
}
|
|
81
|
+
const isApprovedTransition = approvedTransitions.includes(text);
|
|
82
|
+
const isRejectedTransition = rejectedTransitions.includes(text);
|
|
83
|
+
const isUnrestrictedTransition = unrestrictedTransitions.includes(text);
|
|
84
|
+
const isNoResultRestrictionTransition = noResultRestrictions.includes(text);
|
|
85
|
+
const isStartApproval = approval.startApproval;
|
|
86
|
+
const finishStatus = [ApprovalStatus.approved, ApprovalStatus.rejected];
|
|
87
|
+
const isPendingStatus = !finishStatus.includes(approval.approvalStatus);
|
|
88
|
+
if (!isStartApproval && isPendingStatus) {
|
|
89
|
+
const errorMsg = isNoResultRestrictionTransition
|
|
90
|
+
? i18n.t('pages.fields.view.noResultRestrictedStatus')
|
|
91
|
+
: i18n.t('pages.fields.view.approvalStatus');
|
|
92
|
+
return isUnrestrictedTransition ? [true] : [false, errorMsg];
|
|
93
|
+
}
|
|
94
|
+
if (isNoResultRestrictionTransition) {
|
|
75
95
|
return [true];
|
|
76
96
|
}
|
|
77
|
-
if (!
|
|
78
|
-
|
|
79
|
-
|
|
97
|
+
if (isUnrestrictedTransition && !isRejectedTransition && !isApprovedTransition) {
|
|
98
|
+
return [false, i18n.t('pages.fields.view.unrestrictedStatus')];
|
|
99
|
+
}
|
|
100
|
+
if (isRejectedTransition && approval.approvalStatus === ApprovalStatus.rejected) {
|
|
80
101
|
return [true];
|
|
81
102
|
}
|
|
82
|
-
if (
|
|
83
|
-
return
|
|
103
|
+
if (isApprovedTransition && approval.approvalStatus === ApprovalStatus.approved) {
|
|
104
|
+
return [true];
|
|
84
105
|
}
|
|
85
106
|
return [false, i18n.t('pages.fields.view.approvalStatus')];
|
|
86
107
|
}, [approval]);
|