Skip to content

Commit

Permalink
chore(#1294199): update ResourceForm texts
Browse files Browse the repository at this point in the history
  • Loading branch information
botisSmile committed Jul 1, 2024
1 parent e526a87 commit 0507717
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
8 changes: 4 additions & 4 deletions packages/components/public/locales/en/resourceForm.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
8 changes: 4 additions & 4 deletions packages/components/public/locales/fr/resourceForm.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
IErrorsForm,
IMainContext,
concatenateValuesWithLineBreaks,
firstLetterUppercase,
initResourceData,
isError,
} from '@elastic-suite/gally-admin-shared'
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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',
})
Expand Down Expand Up @@ -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={
Expand Down

0 comments on commit 0507717

Please sign in to comment.