Skip to content

Commit

Permalink
Merge pull request #871 from InseeFrLab/dialog-delete
Browse files Browse the repository at this point in the history
feat: Improve dialog text when multiple deletion
  • Loading branch information
garronej authored Nov 6, 2024
2 parents dccc0de + 432fbf3 commit f44ed73
Show file tree
Hide file tree
Showing 12 changed files with 74 additions and 57 deletions.
1 change: 0 additions & 1 deletion web/src/core/usecases/fileExplorer/thunks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ export const thunks = {
(...args): { cleanup: () => void } => {
const { directoryPath, viewMode } = params;

console.log("initialize", viewMode);
const [dispatch, getState, { evtAction }] = args;

const ctx = Evt.newCtx();
Expand Down
12 changes: 7 additions & 5 deletions web/src/ui/i18n/resources/de.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -387,11 +387,13 @@ export const translations: Translations<"de"> = {
"do not display again": "Nicht mehr anzeigen",
"untitled what": ({ what }) => `${what}_namenlos`,
directory: "Verzeichnis",
"deletion dialog title": ({ deleteWhat }) => `Einen ${deleteWhat} löschen?`,
"deletion dialog body": ({ deleteWhat }) => `
Sie sind dabei, einen ${deleteWhat} zu löschen.
Durch diese Aktion können Daten verloren gehen, die mit diesem ${deleteWhat} verknüpft sind.
`,
multiple: "Elemente",
"deletion dialog title": ({ deleteWhat, isPlural }) =>
`Möchten Sie ${isPlural ? "mehrere" : "ein"} ${deleteWhat} löschen?`,
"deletion dialog body": ({ deleteWhat, isPlural }) => `
Sie sind dabei, ${isPlural ? "mehrere" : "ein"} ${deleteWhat} zu löschen.
Diese Aktion könnte zum Verlust der mit ${isPlural ? "diesen" : "diesem"} ${deleteWhat} verbundenen Daten führen.
`,
"already a directory with this name":
"Es gibt bereits ein Verzeichnis mit diesem Namen",
"can't be empty": "Darf nicht leer sein",
Expand Down
13 changes: 7 additions & 6 deletions web/src/ui/i18n/resources/en.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -397,14 +397,15 @@ export const translations: Translations<"en"> = {
cancel: "cancel",
delete: "delete",
"do not display again": "Don't display again",

"untitled what": ({ what }) => `untitled_${what}`,
directory: "folder",
"deletion dialog title": ({ deleteWhat }) => `Delete a ${deleteWhat} ?`,
"deletion dialog body": ({
deleteWhat
}) => `You are about to delete ${deleteWhat}.
This action can't be reverted.`,
multiple: "items",
"deletion dialog title": ({ deleteWhat, isPlural }) =>
`Delete ${isPlural ? "these" : "this"} ${deleteWhat}?`,
"deletion dialog body": ({ deleteWhat, isPlural }) => `
You are about to delete ${isPlural ? "these" : "this"} ${deleteWhat}.
This action may result in the loss of data associated with ${isPlural ? "these" : "this"} ${deleteWhat}.
`,
"already a directory with this name":
"There is already a directory with this name",
"can't be empty": "Can't be empty",
Expand Down
13 changes: 7 additions & 6 deletions web/src/ui/i18n/resources/es.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -408,14 +408,15 @@ export const translations: Translations<"en"> = {
cancel: "cancelar",
delete: "eliminar",
"do not display again": "No mostrar de nuevo",

"untitled what": ({ what }) => `sin_título_${what}`,
directory: "carpeta",
"deletion dialog title": ({ deleteWhat }) => `¿Eliminar un ${deleteWhat} ?`,
"deletion dialog body": ({
deleteWhat
}) => `Estás a punto de eliminar ${deleteWhat}.
Esta acción no se puede revertir.`,
multiple: "elementos",
"deletion dialog title": ({ deleteWhat, isPlural }) =>
`¿Eliminar ${isPlural ? "estos" : "este"} ${deleteWhat}?`,
"deletion dialog body": ({ deleteWhat, isPlural }) => `
Está a punto de eliminar ${isPlural ? "estos" : "este"} ${deleteWhat}.
Esta acción puede resultar en la pérdida de datos asociados a ${isPlural ? "estos" : "este"} ${deleteWhat}.
`,
"already a directory with this name": "Ya existe una carpeta con este nombre",
"can't be empty": "No puede estar vacío",
"new directory": "Nueva carpeta"
Expand Down
11 changes: 7 additions & 4 deletions web/src/ui/i18n/resources/fi.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -402,12 +402,15 @@ export const translations: Translations<"fi"> = {
cancel: "peruuta",
delete: "poista",
"do not display again": "Älä näytä uudelleen",

"untitled what": ({ what }) => `nimetön_${what}`,
directory: "hakemisto",
"deletion dialog title": ({ deleteWhat }) => `Poista ${deleteWhat}?`,
"deletion dialog body": ({ deleteWhat }) => `Olet poistamassa ${deleteWhat}.
Tätä toimintoa ei voi peruuttaa.`,
multiple: "kohteet",
"deletion dialog title": ({ deleteWhat, isPlural }) =>
`Poistetaanko ${isPlural ? "nämä" : "tämä"} ${deleteWhat}?`,
"deletion dialog body": ({ deleteWhat, isPlural }) => `
Olet poistamassa ${isPlural ? "näitä" : "tätä"} ${deleteWhat}.
Tämä toiminto voi johtaa näihin liittyvien tietojen menetykseen ${isPlural ? "näihin" : "tähän"} ${deleteWhat}.
`,
"already a directory with this name": "Tämän niminen hakemisto on jo olemassa",
"can't be empty": "Ei voi olla tyhjä",
"new directory": "Uusi hakemisto"
Expand Down
11 changes: 6 additions & 5 deletions web/src/ui/i18n/resources/fr.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -384,13 +384,14 @@ export const translations: Translations<"fr"> = {
cancel: "annuler",
delete: "supprimer",
"do not display again": "Ne plus afficher",

"untitled what": ({ what }) => `${what}_sans_nom`,
multiple: "éléments",
directory: "dossier",
"deletion dialog title": ({ deleteWhat }) => `Supprimer un ${deleteWhat} ?`,
"deletion dialog body": ({ deleteWhat }) => `
Vous êtes sur le point de supprimer un ${deleteWhat}.
Cette action entraînera la perte potentielle des données liées à ce ${deleteWhat}.
"deletion dialog title": ({ deleteWhat, isPlural }) =>
`Supprimer ${isPlural ? "des" : "un"} ${deleteWhat} ?`,
"deletion dialog body": ({ deleteWhat, isPlural }) => `
Vous êtes sur le point de supprimer ${isPlural ? "des" : "un"} ${deleteWhat}.
Cette action entraînera la perte potentielle des données liées à ${isPlural ? "ces" : "ce"} ${deleteWhat}.
`,
"already a directory with this name": "Il y a déjà un dossier avec ce nom",
"can't be empty": "Ne peut être vide",
Expand Down
12 changes: 7 additions & 5 deletions web/src/ui/i18n/resources/it.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -384,11 +384,13 @@ export const translations: Translations<"it"> = {

"untitled what": ({ what }) => `${what}_senza_nome`,
directory: "cartella",
"deletion dialog title": ({ deleteWhat }) => `Eliminare un ${deleteWhat}?`,
"deletion dialog body": ({ deleteWhat }) => `
Stai per eliminare un ${deleteWhat}.
Questa azione potrebbe comportare la potenziale perdita dei dati associati a questo ${deleteWhat}.
`,
multiple: "elementi",
"deletion dialog title": ({ deleteWhat, isPlural }) =>
`Eliminare ${isPlural ? "questi" : "questo"} ${deleteWhat}?`,
"deletion dialog body": ({ deleteWhat, isPlural }) => `
Stai per eliminare ${isPlural ? "questi" : "questo"} ${deleteWhat}.
Questa azione potrebbe comportare la perdita dei dati associati a ${isPlural ? "questi" : "questo"} ${deleteWhat}.
`,
"already a directory with this name": "Esiste già una cartella con questo nome",
"can't be empty": "Non può essere vuoto",
"new directory": "Nuova cartella"
Expand Down
12 changes: 7 additions & 5 deletions web/src/ui/i18n/resources/nl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -384,11 +384,13 @@ export const translations: Translations<"nl"> = {

"untitled what": ({ what }) => `${what}_naamloos`,
directory: "map",
"deletion dialog title": ({ deleteWhat }) => `Een ${deleteWhat} verwijderen ?`,
"deletion dialog body": ({ deleteWhat }) => `
Je staat op het punt om een ${deleteWhat} te verwijderen.
Deze actie zal resulteren in het mogelijke verlies van de gegevens gekoppeld aan deze ${deleteWhat}.
`,
multiple: "items",
"deletion dialog title": ({ deleteWhat, isPlural }) =>
`${isPlural ? "Deze" : "Dit"} ${deleteWhat} verwijderen?`,
"deletion dialog body": ({ deleteWhat, isPlural }) => `
U staat op het punt om ${isPlural ? "deze" : "dit"} ${deleteWhat} te verwijderen.
Deze actie kan leiden tot het verlies van gegevens die gekoppeld zijn aan ${isPlural ? "deze" : "dit"} ${deleteWhat}.
`,
"already a directory with this name": "Er bestaat al een map met deze naam",
"can't be empty": "Kan niet leeg zijn",
"new directory": "Nieuwe map"
Expand Down
11 changes: 7 additions & 4 deletions web/src/ui/i18n/resources/no.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -409,10 +409,13 @@ export const translations: Translations<"no"> = {

"untitled what": ({ what }) => `uten tittel_${what}`,
directory: "mappe",
"deletion dialog title": ({ deleteWhat }) => `Slett ${deleteWhat}?`,
"deletion dialog body": ({ deleteWhat }) =>
`Du er i ferd med å slette ${deleteWhat}.
Denne handlingen kan ikke reverseres.`,
multiple: "elementer",
"deletion dialog title": ({ deleteWhat, isPlural }) =>
`Slett ${isPlural ? "disse" : "denne"} ${deleteWhat}?`,
"deletion dialog body": ({ deleteWhat, isPlural }) => `
Du er i ferd med å slette ${isPlural ? "disse" : "denne"} ${deleteWhat}.
Denne handlingen kan føre til tap av data knyttet til ${isPlural ? "disse" : "dette"} ${deleteWhat}.
`,
"already a directory with this name":
"Det finnes allerede en mappe med dette navnet",
"can't be empty": "Kan ikke være tom",
Expand Down
12 changes: 7 additions & 5 deletions web/src/ui/i18n/resources/zh-CN.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -349,11 +349,13 @@ export const translations: Translations<"zh-CN"> = {
"do not display again": "不要再显示",
"untitled what": ({ what }) => `untitled_${what}`,
directory: "目录",
"deletion dialog title": ({ deleteWhat }) => `删除 ${deleteWhat} ?`,
"deletion dialog body": ({ deleteWhat }) => `
您即将删除 ${deleteWhat} 服务.
此操作将导致与此 ${deleteWhat} 服务相关的数据的潜在丢失
`,
multiple: "项目",
"deletion dialog title": ({ deleteWhat, isPlural }) =>
`删除${isPlural ? "这些" : "此"}${deleteWhat}?`,
"deletion dialog body": ({ deleteWhat, isPlural }) => `
您将要删除${isPlural ? "这些" : "此"}${deleteWhat}
此操作可能导致与${isPlural ? "这些" : "此"}${deleteWhat}相关的数据丢失。
`,
"already a directory with this name": "已经有一个同名的文件夹",
"can't be empty": "不能为空",
create: "建立",
Expand Down
21 changes: 11 additions & 10 deletions web/src/ui/pages/myFiles/Explorer/Explorer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,7 @@ export const Explorer = memo((props: ExplorerProps) => {

const [deletionDialogState, setDeletionDialogState] = useState<
| {
kind: "file" | "directory";
basename: string;
kind: "file" | "directory" | "multiple";
resolveDoProceedToDeletion: (doProceedToDeletion: boolean) => void;
}
| undefined
Expand Down Expand Up @@ -261,7 +260,6 @@ export const Explorer = memo((props: ExplorerProps) => {

setDeletionDialogState({
kind: item.kind,
basename: item.basename,
resolveDoProceedToDeletion: dDoProceedToDeletion.resolve
});

Expand All @@ -287,9 +285,7 @@ export const Explorer = memo((props: ExplorerProps) => {
const dDoProceedToDeletion = new Deferred();

setDeletionDialogState({
//TODO : handle multiple deletion in dialog
kind: items[0].kind,
basename: items[0].basename,
kind: items.length === 1 ? items[0].kind : "multiple",
resolveDoProceedToDeletion: dDoProceedToDeletion.resolve
});

Expand Down Expand Up @@ -447,10 +443,14 @@ export const Explorer = memo((props: ExplorerProps) => {
deletionDialogState === undefined
? ""
: t(deletionDialogState.kind);
const isPlural =
deletionDialogState === undefined
? false
: deletionDialogState.kind === "multiple";

return {
title: t("deletion dialog title", { deleteWhat }),
body: t("deletion dialog body", { deleteWhat })
title: t("deletion dialog title", { deleteWhat, isPlural }),
body: t("deletion dialog body", { deleteWhat, isPlural })
};
})()}
isOpen={deletionDialogState !== undefined}
Expand Down Expand Up @@ -489,11 +489,12 @@ const { i18n } = declareComponentKeys<
| { K: "untitled what"; P: { what: string } }
| "directory"
| "file"
| "multiple"
| "secret"
| "cancel"
| "delete"
| { K: "deletion dialog title"; P: { deleteWhat: string } }
| { K: "deletion dialog body"; P: { deleteWhat: string } }
| { K: "deletion dialog title"; P: { deleteWhat: string; isPlural: boolean } }
| { K: "deletion dialog body"; P: { deleteWhat: string; isPlural: boolean } }
| "do not display again"
| "already a directory with this name"
| "can't be empty"
Expand Down
2 changes: 1 addition & 1 deletion web/src/ui/pages/myFiles/MyFiles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function MyFiles(props: Props) {

useEffect(() => {
if (currentWorkingDirectoryView === undefined) return;
console.log(viewMode);

routes[route.name]({
...route.params,
path: currentWorkingDirectoryView.directoryPath,
Expand Down

0 comments on commit f44ed73

Please sign in to comment.