mirror of
https://github.com/strapi/strapi.git
synced 2025-09-26 17:00:55 +00:00
Enhancement: Render workflow/ stage limits in CM edit view
This commit is contained in:
parent
02391694e3
commit
b4e158c3d1
@ -11,6 +11,8 @@ import { useIntl } from 'react-intl';
|
|||||||
import { useMutation } from 'react-query';
|
import { useMutation } from 'react-query';
|
||||||
|
|
||||||
import Information from '../../../../../../admin/src/content-manager/pages/EditView/Information';
|
import Information from '../../../../../../admin/src/content-manager/pages/EditView/Information';
|
||||||
|
import { useLicenseLimits } from '../../../../hooks';
|
||||||
|
import * as LimitsModal from '../../../../pages/SettingsPage/pages/ReviewWorkflows/components/LimitsModal';
|
||||||
import { useReviewWorkflows } from '../../../../pages/SettingsPage/pages/ReviewWorkflows/hooks/useReviewWorkflows';
|
import { useReviewWorkflows } from '../../../../pages/SettingsPage/pages/ReviewWorkflows/hooks/useReviewWorkflows';
|
||||||
import { getStageColorByHex } from '../../../../pages/SettingsPage/pages/ReviewWorkflows/utils/colors';
|
import { getStageColorByHex } from '../../../../pages/SettingsPage/pages/ReviewWorkflows/utils/colors';
|
||||||
|
|
||||||
@ -33,8 +35,11 @@ export function InformationBoxEE() {
|
|||||||
const { formatMessage } = useIntl();
|
const { formatMessage } = useIntl();
|
||||||
const { formatAPIError } = useAPIErrorHandler();
|
const { formatAPIError } = useAPIErrorHandler();
|
||||||
const toggleNotification = useNotification();
|
const toggleNotification = useNotification();
|
||||||
|
const { license } = useLicenseLimits();
|
||||||
|
const [showLimitModal, setShowLimitModal] = React.useState(false);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
pagination,
|
||||||
workflows: [workflow],
|
workflows: [workflow],
|
||||||
isLoading: isWorkflowLoading,
|
isLoading: isWorkflowLoading,
|
||||||
} = useReviewWorkflows({ filters: { contentTypes: uid } });
|
} = useReviewWorkflows({ filters: { contentTypes: uid } });
|
||||||
@ -72,6 +77,17 @@ export function InformationBoxEE() {
|
|||||||
|
|
||||||
const handleStageChange = async ({ value: stageId }) => {
|
const handleStageChange = async ({ value: stageId }) => {
|
||||||
try {
|
try {
|
||||||
|
if (license?.data?.workflows > pagination.total) {
|
||||||
|
setShowLimitModal('workflow');
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (license?.data?.stagesPerWorkflow > workflow.stages.length) {
|
||||||
|
setShowLimitModal('stage');
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
await mutateAsync({
|
await mutateAsync({
|
||||||
entityId: initialData.id,
|
entityId: initialData.id,
|
||||||
stageId,
|
stageId,
|
||||||
@ -152,6 +168,44 @@ export function InformationBoxEE() {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
<Information.Body />
|
<Information.Body />
|
||||||
|
|
||||||
|
<LimitsModal.Root
|
||||||
|
isOpen={showLimitModal === 'workflow'}
|
||||||
|
onClose={() => setShowLimitModal(false)}
|
||||||
|
>
|
||||||
|
<LimitsModal.Title>
|
||||||
|
{formatMessage({
|
||||||
|
id: 'content-manager.reviewWorkflows.workflows.limit.title',
|
||||||
|
defaultMessage: 'You’ve reached the limit of workflows in your plan',
|
||||||
|
})}
|
||||||
|
</LimitsModal.Title>
|
||||||
|
|
||||||
|
<LimitsModal.Body>
|
||||||
|
{formatMessage({
|
||||||
|
id: 'content-manager.reviewWorkflows.workflows.limit.body',
|
||||||
|
defaultMessage: 'Delete a workflow or contact Sales to enable more workflows.',
|
||||||
|
})}
|
||||||
|
</LimitsModal.Body>
|
||||||
|
</LimitsModal.Root>
|
||||||
|
|
||||||
|
<LimitsModal.Root
|
||||||
|
isOpen={showLimitModal === 'stage'}
|
||||||
|
onClose={() => setShowLimitModal(false)}
|
||||||
|
>
|
||||||
|
<LimitsModal.Title>
|
||||||
|
{formatMessage({
|
||||||
|
id: 'content-manager.reviewWorkflows.stages.limit.title',
|
||||||
|
defaultMessage: 'You have reached the limit of stages for this workflow in your plan',
|
||||||
|
})}
|
||||||
|
</LimitsModal.Title>
|
||||||
|
|
||||||
|
<LimitsModal.Body>
|
||||||
|
{formatMessage({
|
||||||
|
id: 'content-manager.reviewWorkflows.stages.limit.body',
|
||||||
|
defaultMessage: 'Try deleting some stages or contact Sales to enable more stages.',
|
||||||
|
})}
|
||||||
|
</LimitsModal.Body>
|
||||||
|
</LimitsModal.Root>
|
||||||
</Information.Root>
|
</Information.Root>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user