From 23abbc63d8081eaaa44070005c8710add298972c Mon Sep 17 00:00:00 2001 From: Gustav Hansen Date: Tue, 11 Apr 2023 15:54:27 +0200 Subject: [PATCH] EditView: Display notification when a stage change was successful --- .../InformationBox/InformationBoxEE.js | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/packages/core/admin/ee/admin/content-manager/pages/EditView/InformationBox/InformationBoxEE.js b/packages/core/admin/ee/admin/content-manager/pages/EditView/InformationBox/InformationBoxEE.js index 504f72b126..b4a5ccb011 100644 --- a/packages/core/admin/ee/admin/content-manager/pages/EditView/InformationBox/InformationBoxEE.js +++ b/packages/core/admin/ee/admin/content-manager/pages/EditView/InformationBox/InformationBoxEE.js @@ -4,6 +4,7 @@ import { useCMEditViewDataManager, useAPIErrorHandler, useFetchClient, + useNotification, } from '@strapi/helper-plugin'; import { Field, FieldLabel, FieldError, Flex } from '@strapi/design-system'; import { useIntl } from 'react-intl'; @@ -24,18 +25,29 @@ export function InformationBoxEE() { const activeWorkflowStage = initialData?.[ATTRIBUTE_NAME] ?? null; const { formatMessage } = useIntl(); const { formatAPIError } = useAPIErrorHandler(); + const toggleNotification = useNotification(); const { workflows: { data: [workflow] = [] } = {} } = useReviewWorkflows(); - const { error, isLoading, mutateAsync } = useMutation(async ({ entityId, stageId, uid }) => { - const { - data: { data }, - } = await put(`/admin/content-manager/collection-types/${uid}/${entityId}/stage`, { - data: { id: stageId }, - }); + const { error, isLoading, mutateAsync } = useMutation( + async ({ entityId, stageId, uid }) => { + const { + data: { data }, + } = await put(`/admin/content-manager/collection-types/${uid}/${entityId}/stage`, { + data: { id: stageId }, + }); - return data; - }); + return data; + }, + { + onSuccess() { + toggleNotification({ + type: 'success', + message: { id: 'notification.success.saved', defaultMessage: 'Saved' }, + }); + }, + } + ); // stages are empty while the workflow is loading const options = (workflow?.stages ?? []).map(({ id, name }) => ({ value: id, label: name }));