feat: logo et favicon, confirmation modale, fil d'ariane, e-mails sombres (#4)
CD — Déploiement / deploy (push) Failing after 25s

- logo embarque dans les e-mails (CID) et gabarit repense en mode sombre
- favicon multi-tailles + icone PNG, logo a gauche du titre (app et auth)
- modale de confirmation animee a la place de window.confirm
- bouton retour et fil d'ariane dans l'explorateur

---------

Co-authored-by: xEsiah <[email protected]>
Reviewed-on: #4
Reviewed-by: Esiah <[email protected]>
Co-authored-by: Gitea Actions <-[email protected]>
This commit was merged in pull request #4.
This commit is contained in:
Gitea Actions
2026-10-16 11:08:47 +00:00
committed by Esiah
co-authored by Esiah
parent 25b6e0669a
commit 9dd1ad72e0
105 changed files with 2638 additions and 592 deletions
+381
View File
@@ -0,0 +1,381 @@
import { useEffect, useState, type FormEvent } from "react";
import { Button, Input, cn } from "../ui/index.js";
import {
ApiError,
api,
formatDate,
type Folder,
type FolderPermission,
} from "../lib/api.js";
import { Alert, Modal } from "./feedback.js";
import { TrashIcon } from "./icons.js";
const LEVELS = ["read", "write", "admin"] as const;
const LEVEL_LABEL: Record<string, string> = {
read: "Lecture",
write: "Écriture",
admin: "Administration",
};
const messageOf = (caught: unknown, fallback: string): string =>
caught instanceof ApiError ? caught.message : fallback;
interface Target {
type: "folder" | "file";
id: string;
name: string;
}
export const CreateFolderDialog = ({
parentId,
onClose,
onCreated,
}: {
parentId: string | null;
onClose: () => void;
onCreated: () => void;
}) => {
const [name, setName] = useState("");
const [description, setDescription] = useState("");
const [error, setError] = useState<string | null>(null);
const [busy, setBusy] = useState(false);
const submit = async (event: FormEvent<HTMLFormElement>) => {
event.preventDefault();
setBusy(true);
setError(null);
try {
await api.createFolder(name, parentId, description.trim() || undefined);
onCreated();
} catch (caught) {
setError(messageOf(caught, "Création impossible."));
} finally {
setBusy(false);
}
};
return (
<Modal open title="Nouveau dossier" onClose={onClose}>
<form className="flex flex-col gap-4" onSubmit={(event) => void submit(event)}>
<Input
label="Nom"
required
maxLength={255}
autoFocus
placeholder="Contrats 2026"
value={name}
onChange={(event) => setName(event.target.value)}
/>
<Input
label="Description (optionnelle)"
maxLength={2000}
value={description}
onChange={(event) => setDescription(event.target.value)}
/>
{error ? <Alert>{error}</Alert> : null}
<div className="flex justify-end gap-2">
<Button variant="ghost" size="md" onClick={onClose}>
Annuler
</Button>
<Button type="submit" size="md" isLoading={busy}>
Créer
</Button>
</div>
</form>
</Modal>
);
};
export const RenameDialog = ({
target,
onClose,
onDone,
}: {
target: Target;
onClose: () => void;
onDone: () => void;
}) => {
const [name, setName] = useState(target.name);
const [error, setError] = useState<string | null>(null);
const [busy, setBusy] = useState(false);
const submit = async (event: FormEvent<HTMLFormElement>) => {
event.preventDefault();
setBusy(true);
setError(null);
try {
if (target.type === "folder") await api.updateFolder(target.id, { name });
else await api.renameFile(target.id, name);
onDone();
} catch (caught) {
setError(messageOf(caught, "Renommage impossible."));
} finally {
setBusy(false);
}
};
return (
<Modal open title="Renommer" onClose={onClose}>
<form className="flex flex-col gap-4" onSubmit={(event) => void submit(event)}>
<Input
label="Nom"
required
maxLength={255}
autoFocus
value={name}
onChange={(event) => setName(event.target.value)}
/>
{error ? <Alert>{error}</Alert> : null}
<div className="flex justify-end gap-2">
<Button variant="ghost" size="md" onClick={onClose}>
Annuler
</Button>
<Button type="submit" size="md" isLoading={busy}>
Enregistrer
</Button>
</div>
</form>
</Modal>
);
};
interface TreeEntry {
id: string;
label: string;
}
const loadTree = async (): Promise<TreeEntry[]> => {
const entries: TreeEntry[] = [];
const walk = async (parentId: string | null, prefix: string, depth: number): Promise<void> => {
if (depth > 6) return;
const { folders } = await api.folders(parentId);
for (const folder of folders) {
entries.push({ id: folder.id, label: `${prefix}${folder.name}` });
await walk(folder.id, `${prefix}${folder.name} / `, depth + 1);
}
};
await walk(null, "", 0);
return entries;
};
export const MoveDialog = ({
target,
onClose,
onDone,
}: {
target: Target;
onClose: () => void;
onDone: () => void;
}) => {
const [entries, setEntries] = useState<TreeEntry[] | null>(null);
const [destination, setDestination] = useState<string>("");
const [error, setError] = useState<string | null>(null);
const [busy, setBusy] = useState(false);
useEffect(() => {
loadTree()
.then(setEntries)
.catch((caught: unknown) => setError(messageOf(caught, "Chargement des dossiers impossible.")));
}, []);
const submit = async (event: FormEvent<HTMLFormElement>) => {
event.preventDefault();
setBusy(true);
setError(null);
const parentId = destination === "" ? null : destination;
try {
if (target.type === "folder") await api.moveFolder(target.id, parentId);
else await api.moveFile(target.id, parentId);
onDone();
} catch (caught) {
setError(messageOf(caught, "Déplacement impossible."));
} finally {
setBusy(false);
}
};
return (
<Modal open title="Déplacer" onClose={onClose}>
<form className="flex flex-col gap-4" onSubmit={(event) => void submit(event)}>
<p className="text-sm text-muted-foreground">
Destination de <span className="font-medium text-foreground">{target.name}</span>.
</p>
{entries === null && !error ? (
<Alert tone="info">Chargement des dossiers…</Alert>
) : (
<label className="flex flex-col gap-1.5">
<span className="font-display text-[0.6875rem] font-semibold uppercase tracking-label text-foreground">
Destination
</span>
<select
value={destination}
onChange={(event) => setDestination(event.target.value)}
className={cn(
"h-10 w-full rounded-sm border border-border-control bg-surface px-3 text-sm text-foreground",
"focus-visible:ring-ring focus-visible:border-border-strong focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-offset-background focus-visible:outline-none",
)}
>
<option value="">Racine</option>
{(entries ?? [])
.filter((entry) => entry.id !== target.id)
.map((entry) => (
<option key={entry.id} value={entry.id}>
{entry.label}
</option>
))}
</select>
</label>
)}
{error ? <Alert>{error}</Alert> : null}
<div className="flex justify-end gap-2">
<Button variant="ghost" size="md" onClick={onClose}>
Annuler
</Button>
<Button type="submit" size="md" isLoading={busy} disabled={entries === null}>
Déplacer
</Button>
</div>
</form>
</Modal>
);
};
export const ShareDialog = ({
folder,
onClose,
}: {
folder: Folder;
onClose: () => void;
}) => {
const [permissions, setPermissions] = useState<FolderPermission[] | null>(null);
const [email, setEmail] = useState("");
const [level, setLevel] = useState<string>("read");
const [expiresAt, setExpiresAt] = useState("");
const [error, setError] = useState<string | null>(null);
const [busy, setBusy] = useState(false);
const load = async () => {
try {
const { permissions: list } = await api.folderPermissions(folder.id);
setPermissions(list);
setError(null);
} catch (caught) {
setError(messageOf(caught, "Chargement des partages impossible."));
setPermissions([]);
}
};
useEffect(() => {
void load();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [folder.id]);
const grant = async (event: FormEvent<HTMLFormElement>) => {
event.preventDefault();
setBusy(true);
setError(null);
try {
const iso = expiresAt ? new Date(expiresAt).toISOString() : null;
await api.grantPermission(folder.id, email, level, expiresAt ? iso : null);
setEmail("");
setExpiresAt("");
await load();
} catch (caught) {
setError(messageOf(caught, "Partage impossible."));
} finally {
setBusy(false);
}
};
const revoke = async (userId: string) => {
setError(null);
try {
await api.revokePermission(folder.id, userId);
await load();
} catch (caught) {
setError(messageOf(caught, "Révocation impossible."));
}
};
return (
<Modal open title={`Partager « ${folder.name} »`} onClose={onClose}>
<div className="flex flex-col gap-5">
<form className="flex flex-col gap-3" onSubmit={(event) => void grant(event)}>
<Input
label="Adresse e-mail du membre"
type="email"
required
autoFocus
value={email}
onChange={(event) => setEmail(event.target.value)}
/>
<div className="grid grid-cols-2 gap-3">
<label className="flex flex-col gap-1.5">
<span className="font-display text-[0.6875rem] font-semibold uppercase tracking-label text-foreground">
Niveau
</span>
<select
value={level}
onChange={(event) => setLevel(event.target.value)}
className="h-10 w-full rounded-sm border border-border-control bg-surface px-3 text-sm text-foreground focus-visible:ring-ring focus-visible:border-border-strong focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-offset-background focus-visible:outline-none"
>
{LEVELS.map((value) => (
<option key={value} value={value}>
{LEVEL_LABEL[value]}
</option>
))}
</select>
</label>
<Input
label="Expire le"
type="date"
value={expiresAt}
onChange={(event) => setExpiresAt(event.target.value)}
/>
</div>
{error ? <Alert>{error}</Alert> : null}
<div className="flex justify-end">
<Button type="submit" size="md" isLoading={busy}>
Autoriser
</Button>
</div>
</form>
<div>
<h3 className="mb-2 font-display text-[0.6875rem] font-semibold uppercase tracking-label text-subtle-foreground">
Accès accordés
</h3>
{permissions === null ? (
<Alert tone="info">Chargement…</Alert>
) : permissions.length === 0 ? (
<p className="text-xs text-muted-foreground">Aucun partage pour ce dossier.</p>
) : (
<ul className="flex flex-col divide-y divide-border rounded-md border border-border">
{permissions.map((permission) => (
<li key={permission.user_id} className="flex items-center gap-3 px-3 py-2">
<span className="min-w-0 flex-1">
<span className="block truncate text-xs font-medium text-foreground">
{permission.first_name} {permission.last_name}
</span>
<span className="block truncate text-[0.6875rem] text-subtle-foreground">
{permission.email} · {LEVEL_LABEL[permission.level] ?? permission.level}
{permission.expires_at ? ` · jusqu'au ${formatDate(permission.expires_at)}` : ""}
</span>
</span>
<button
type="button"
aria-label={`Révoquer ${permission.email}`}
onClick={() => void revoke(permission.user_id)}
className="inline-flex h-8 w-8 items-center justify-center rounded-sm text-muted-foreground transition-colors hover:text-destructive"
>
<TrashIcon className="h-4 w-4" />
</button>
</li>
))}
</ul>
)}
</div>
</div>
</Modal>
);
};