feat(files): improve bulk selection, upload progress and i18n (#17)
CD — Deployment / deploy (push) Successful in 15s
CD — Deployment / deploy (push) Successful in 15s
PR automatique de feat/bulk-selection-ux vers main. --------- Co-authored-by: xEsiah <[email protected]> Reviewed-on: #17 Reviewed-by: Esiah <[email protected]> Co-authored-by: Gitea Actions <-[email protected]>
This commit was merged in pull request #17.
This commit is contained in:
@@ -339,6 +339,35 @@ export const Browser = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const removeSelected = async () => {
|
||||
const ok = await confirm({
|
||||
title: t("Mettre à la corbeille"),
|
||||
message: t("{count} élément(s) seront placés dans la corbeille.", {
|
||||
count: selectedItems.length,
|
||||
}),
|
||||
confirmLabel: t("Corbeille"),
|
||||
tone: "danger",
|
||||
});
|
||||
if (!ok) return;
|
||||
setError(null);
|
||||
try {
|
||||
for (const target of selectedItems) {
|
||||
if (target.type === "folder") await api.deleteFolder(target.id);
|
||||
else await api.deleteFile(target.id);
|
||||
}
|
||||
clearSelection();
|
||||
await reload();
|
||||
void refresh();
|
||||
} catch (caught) {
|
||||
const msg =
|
||||
caught instanceof ApiError
|
||||
? caught.message
|
||||
: t("Suppression impossible.");
|
||||
setError(msg);
|
||||
toast.error(msg);
|
||||
}
|
||||
};
|
||||
|
||||
const toggleStar = async (file: UploadedFile) => {
|
||||
setError(null);
|
||||
try {
|
||||
@@ -603,21 +632,26 @@ export const Browser = () => {
|
||||
>
|
||||
{t("Déplacer")}
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="secondary"
|
||||
onClick={() => {
|
||||
for (const target of selectedItems) {
|
||||
if (target.type === "file") {
|
||||
const link = document.createElement("a");
|
||||
link.href = api.downloadUrl(target.id);
|
||||
link.download = target.name;
|
||||
link.click();
|
||||
}
|
||||
}
|
||||
}}
|
||||
>
|
||||
{t("Télécharger")}
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="destructive"
|
||||
onClick={() =>
|
||||
void Promise.all(
|
||||
selectedItems.map((target) =>
|
||||
target.type === "folder"
|
||||
? api.deleteFolder(target.id)
|
||||
: api.deleteFile(target.id),
|
||||
),
|
||||
).then(async () => {
|
||||
clearSelection();
|
||||
await reload();
|
||||
})
|
||||
}
|
||||
onClick={() => void removeSelected()}
|
||||
>
|
||||
{t("Supprimer")}
|
||||
</Button>
|
||||
@@ -677,15 +711,17 @@ export const Browser = () => {
|
||||
aria-label={t("Sélectionner {name}", {
|
||||
name: folder.name,
|
||||
})}
|
||||
onChange={(event) => {
|
||||
event.stopPropagation();
|
||||
toggleSelection(`f:${folder.id}`);
|
||||
}}
|
||||
onClick={(event) => event.stopPropagation()}
|
||||
onChange={() => toggleSelection(`f:${folder.id}`)}
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
onClick={(event) => {
|
||||
event.stopPropagation();
|
||||
if (selectedItems.length > 0) {
|
||||
toggleSelection(`f:${folder.id}`);
|
||||
return;
|
||||
}
|
||||
open(folder);
|
||||
}}
|
||||
className="flex min-w-0 flex-1 items-center gap-3 rounded-sm p-1 text-left focus-visible:ring-ring focus-visible:ring-2 focus-visible:outline-none"
|
||||
@@ -795,10 +831,8 @@ export const Browser = () => {
|
||||
aria-label={t("Sélectionner {name}", {
|
||||
name: file.name,
|
||||
})}
|
||||
onChange={(event) => {
|
||||
event.stopPropagation();
|
||||
toggleSelection(`i:${file.id}`);
|
||||
}}
|
||||
onClick={(event) => event.stopPropagation()}
|
||||
onChange={() => toggleSelection(`i:${file.id}`)}
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
|
||||
Reference in New Issue
Block a user