From 0507717438b7bbc9f5915d335545ecf52fbdc7f3 Mon Sep 17 00:00:00 2001 From: Botis Date: Thu, 13 Jun 2024 15:24:05 +0200 Subject: [PATCH] chore(#1294199): update ResourceForm texts --- .../public/locales/en/resourceForm.json | 8 ++++---- .../public/locales/fr/resourceForm.json | 8 ++++---- .../ResourceForm/ResourceForm.tsx | 20 ++++++++++++------- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/packages/components/public/locales/en/resourceForm.json b/packages/components/public/locales/en/resourceForm.json index a4b8e2be..f94dad50 100644 --- a/packages/components/public/locales/en/resourceForm.json +++ b/packages/components/public/locales/en/resourceForm.json @@ -1,12 +1,12 @@ { "save": "Save", "create": "Create", - "alert.update": "Updating of form with success", - "alert.create": "Creating of form with success", - "alert.remove": "Form has been deleted with success", + "alert.update": "Updating of the {{entity}} with success", + "alert.create": "Creating of the {{entity}} with success", + "alert.remove": "{{entity}} has been deleted with success", "alert.error": "Une erreur s'est produite", "delete": "Delete", - "confirmation.message.delete": "Do you confirm the deletion of this form ?", + "confirmation.message.delete": "Are you sure you wish to delete this {{entity}}?", "cancel": "Cancel", "confirm": "Confirm", "error.form": "Error of form" diff --git a/packages/components/public/locales/fr/resourceForm.json b/packages/components/public/locales/fr/resourceForm.json index d691bbc6..2f306381 100644 --- a/packages/components/public/locales/fr/resourceForm.json +++ b/packages/components/public/locales/fr/resourceForm.json @@ -1,12 +1,12 @@ { - "alert.update": "Sauvegarde des données avec succès", - "alert.create": "Création du formulaire avec succès", - "alert.remove": "Le formulaire a été supprimé avec succès", + "alert.update": "Mise à jour de l'élément {{entity}} avec succès", + "alert.create": "Création de l'élément {{entity}} avec succès", + "alert.remove": "L'élément {{entity}} a été supprimé avec succès", "alert.error": "Une erreur s'est produite", "save": "Enregistrer", "create": "Créer", "delete": "Supprimer", - "confirmation.message.delete": "Confirmez-vous la suppression de ce formulaire ?", + "confirmation.message.delete": "Confirmez-vous la suppression de cet élément {{entity}} ?", "cancel": "Annuler", "confirm": "Confirmer", "error.form": "Erreur du formulaire" diff --git a/packages/components/src/components/stateful-pages/ResourceForm/ResourceForm.tsx b/packages/components/src/components/stateful-pages/ResourceForm/ResourceForm.tsx index ec860868..10337aa5 100644 --- a/packages/components/src/components/stateful-pages/ResourceForm/ResourceForm.tsx +++ b/packages/components/src/components/stateful-pages/ResourceForm/ResourceForm.tsx @@ -14,6 +14,7 @@ import { IErrorsForm, IMainContext, concatenateValuesWithLineBreaks, + firstLetterUppercase, initResourceData, isError, } from '@elastic-suite/gally-admin-shared' @@ -41,10 +42,12 @@ interface IProps { id?: string resourceName: string title?: string + entityLabel?: string } function ResourceForm(props: IProps): JSX.Element { - const { resourceName, id, title } = props + const { resourceName, id, title, entityLabel } = props + const entity = (entityLabel ?? resourceName).toLowerCase() const { t } = useTranslation('resourceForm') const resource = useResource(resourceName, IMainContext.FORM) // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -95,10 +98,13 @@ function ResourceForm(props: IProps): JSX.Element { } if (!isError(sendingToApi)) { setData(sendingToApi) - enqueueSnackbar(id ? t('alert.update') : t('alert.create'), { - onShut: closeSnackbar, - variant: 'success', - }) + enqueueSnackbar( + id ? t('alert.update', { entity }) : t('alert.create', { entity }), + { + onShut: closeSnackbar, + variant: 'success', + } + ) if (!id) { router.push('./grid') return @@ -137,7 +143,7 @@ function ResourceForm(props: IProps): JSX.Element { setIsLoading(true) const sendingToApi = await remove(id) if (!isError(sendingToApi)) { - enqueueSnackbar(t('alert.remove'), { + enqueueSnackbar(firstLetterUppercase(t('alert.remove', { entity })), { onShut: closeSnackbar, variant: 'success', }) @@ -185,7 +191,7 @@ function ResourceForm(props: IProps): JSX.Element { confirmationPopIn position="center" onConfirm={deleteData} - titlePopIn={t('confirmation.message.delete')} + titlePopIn={t('confirmation.message.delete', { entity })} cancelName={t('cancel')} confirmName={t('confirm')} triggerElement={