feat: logo et favicon, confirmation modale, fil d'ariane, e-mails sombres #4
+2
-2
@@ -47,8 +47,8 @@ SMTP_PASSWORD=
|
||||
SMTP_FROM=
|
||||
# true si le serveur SMTP exige TLS des la connexion (port 465).
|
||||
SMTP_SECURE=false
|
||||
# Logo des courriels. Par defaut PUBLIC_ORIGIN/logo.png ; a surcharger si le
|
||||
# logo est heberge ailleurs. URL joignable depuis Internet.
|
||||
# Logo des courriels. Par defaut le logo embarque (backend/src/assets/logo.png,
|
||||
# joint au message) ; renseigner une URL pour forcer une image distante.
|
||||
MAIL_LOGO_URL=
|
||||
|
||||
# --- Limitation des connexions -------------------------------------------
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 138 KiB |
@@ -60,8 +60,8 @@ const schema = z.object({
|
||||
SMTP_FROM: z.string().min(3),
|
||||
SMTP_SECURE: bool(false),
|
||||
/**
|
||||
* Logo des courriels. Par defaut celui publie par le front
|
||||
* (`PUBLIC_ORIGIN/logo.png`) ; l'URL doit etre joignable depuis Internet.
|
||||
* Logo des courriels. Par defaut le logo embarque (`backend/src/assets/logo.png`,
|
||||
* joint au message) ; renseigner une URL pour forcer une image distante.
|
||||
*/
|
||||
MAIL_LOGO_URL: z
|
||||
.string()
|
||||
|
||||
@@ -15,10 +15,17 @@ export interface Branding {
|
||||
footer: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Identifiant de la piece jointe du logo. Le logo est embarque dans le message
|
||||
* (voir `mail.ts`) : l'image s'affiche meme si le client bloque les ressources
|
||||
* distantes. `MAIL_LOGO_URL` force une image distante a la place.
|
||||
*/
|
||||
export const LOGO_CID = "cohaise-logo";
|
||||
|
||||
export const branding = (config: Config): Branding => ({
|
||||
appName: "CoHaiSe Cloud",
|
||||
origin: config.PUBLIC_ORIGIN,
|
||||
logoUrl: config.MAIL_LOGO_URL ?? new URL("/logo.png", config.PUBLIC_ORIGIN).toString(),
|
||||
logoUrl: config.MAIL_LOGO_URL ?? `cid:${LOGO_CID}`,
|
||||
color: "#b71c1c",
|
||||
footer: config.SMTP_FROM,
|
||||
});
|
||||
@@ -54,18 +61,18 @@ export const renderMail = (brand: Branding, content: MailContent): RenderedMail
|
||||
const paragraphs = (content.paragraphs ?? [])
|
||||
.map(
|
||||
(paragraph) =>
|
||||
`<p style="margin:0 0 16px;font-size:15px;line-height:1.6;color:#3f3f46;">${escapeHtml(paragraph)}</p>`,
|
||||
`<p style="margin:0 0 16px;font-size:15px;line-height:1.6;color:#c9c2c2;text-align:center;">${escapeHtml(paragraph)}</p>`,
|
||||
)
|
||||
.join("");
|
||||
|
||||
const credentials = content.credentials
|
||||
? `
|
||||
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="margin:0 0 24px;background:#fafafa;border:1px solid #e4e4e7;border-radius:10px;">
|
||||
<tr><td style="padding:16px 18px;font-family:${FONT};">
|
||||
<p style="margin:0 0 10px;font:600 12px ${FONT};letter-spacing:.04em;text-transform:uppercase;color:#71717a;">Vos identifiants</p>
|
||||
<p style="margin:0 0 6px;font:400 14px ${FONT};color:#3f3f46;">Adresse : <strong style="color:#18181b;">${escapeHtml(content.credentials.email)}</strong></p>
|
||||
<p style="margin:0;font:400 14px ${FONT};color:#3f3f46;">Mot de passe temporaire :
|
||||
<span style="font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:14px;background:#ffffff;border:1px solid #e4e4e7;border-radius:6px;padding:2px 8px;color:#18181b;">${escapeHtml(content.credentials.password)}</span>
|
||||
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="margin:0 auto 26px;max-width:420px;background:#1b1212;border:1px solid #332222;border-radius:10px;">
|
||||
<tr><td style="padding:16px 18px;font-family:${FONT};text-align:left;">
|
||||
<p style="margin:0 0 10px;font:600 12px ${FONT};letter-spacing:.04em;text-transform:uppercase;color:#9c9292;">Vos identifiants</p>
|
||||
<p style="margin:0 0 6px;font:400 14px ${FONT};color:#c9c2c2;">Adresse : <strong style="color:#f7f5f5;">${escapeHtml(content.credentials.email)}</strong></p>
|
||||
<p style="margin:0;font:400 14px ${FONT};color:#c9c2c2;">Mot de passe temporaire :
|
||||
<span style="font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:14px;background:#241818;border:1px solid #3a2828;border-radius:6px;padding:2px 8px;color:#f7f5f5;">${escapeHtml(content.credentials.password)}</span>
|
||||
</p>
|
||||
</td></tr>
|
||||
</table>`
|
||||
@@ -73,16 +80,16 @@ export const renderMail = (brand: Branding, content: MailContent): RenderedMail
|
||||
|
||||
const cta = content.cta
|
||||
? `
|
||||
<table role="presentation" cellpadding="0" cellspacing="0" style="margin:0 0 24px;">
|
||||
<table role="presentation" cellpadding="0" cellspacing="0" align="center" style="margin:0 auto 26px;">
|
||||
<tr><td align="center" style="background:${brand.color};border-radius:10px;">
|
||||
<a href="${escapeHtml(content.cta.url)}" style="display:inline-block;padding:13px 30px;font:600 15px ${FONT};color:#ffffff;text-decoration:none;">${escapeHtml(content.cta.label)}</a>
|
||||
<a href="${escapeHtml(content.cta.url)}" style="display:inline-block;padding:14px 32px;font:600 15px ${FONT};color:#ffffff;text-decoration:none;">${escapeHtml(content.cta.label)}</a>
|
||||
</td></tr>
|
||||
</table>`
|
||||
: "";
|
||||
|
||||
const note = content.note
|
||||
? `
|
||||
<p style="margin:0;font:400 13px ${FONT};line-height:1.6;color:#71717a;">${escapeHtml(content.note)}</p>`
|
||||
<p style="margin:0;font:400 13px ${FONT};line-height:1.6;color:#8a8282;text-align:center;">${escapeHtml(content.note)}</p>`
|
||||
: "";
|
||||
|
||||
const html = `<!doctype html>
|
||||
@@ -90,32 +97,39 @@ export const renderMail = (brand: Branding, content: MailContent): RenderedMail
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<meta name="color-scheme" content="light only">
|
||||
<meta name="color-scheme" content="dark only">
|
||||
<meta name="supported-color-schemes" content="dark only">
|
||||
<title>${escapeHtml(content.heading)}</title>
|
||||
</head>
|
||||
<body style="margin:0;padding:0;background:#f4f4f5;">
|
||||
<div style="display:none;max-height:0;overflow:hidden;opacity:0;color:#f4f4f5;">${escapeHtml(content.preview)}</div>
|
||||
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="background:#f4f4f5;padding:32px 12px;">
|
||||
<body style="margin:0;padding:0;background:#050000;">
|
||||
<div style="display:none;max-height:0;overflow:hidden;opacity:0;color:#050000;">${escapeHtml(content.preview)}</div>
|
||||
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="background:#050000;padding:32px 12px;">
|
||||
<tr><td align="center">
|
||||
<table role="presentation" width="560" cellpadding="0" cellspacing="0" style="width:100%;max-width:560px;background:#ffffff;border:1px solid #e4e4e7;border-radius:14px;overflow:hidden;">
|
||||
<tr><td style="background:${brand.color};padding:18px 28px;">
|
||||
<a href="${escapeHtml(brand.origin)}" style="text-decoration:none;">
|
||||
<img src="${escapeHtml(brand.logoUrl)}" width="34" height="34" alt="" style="vertical-align:middle;border:0;border-radius:9px;background:#ffffff;">
|
||||
<span style="vertical-align:middle;margin-left:12px;font:600 17px ${FONT};color:#ffffff;">${escapeHtml(brand.appName)}</span>
|
||||
</a>
|
||||
<table role="presentation" width="560" cellpadding="0" cellspacing="0" style="width:100%;max-width:560px;background:#140d0d;border:1px solid #2a1c1c;border-radius:14px;overflow:hidden;">
|
||||
<tr><td style="background:${brand.color};padding:17px 28px;text-align:center;">
|
||||
<span style="font:700 14px ${FONT};letter-spacing:.18em;text-transform:uppercase;color:#ffffff;">${escapeHtml(brand.appName)}</span>
|
||||
</td></tr>
|
||||
<tr><td style="padding:32px 28px 6px;font-family:${FONT};">
|
||||
<h1 style="margin:0 0 16px;font:600 21px ${FONT};line-height:1.3;color:#18181b;">${escapeHtml(content.heading)}</h1>
|
||||
<p style="margin:0 0 16px;font:400 15px ${FONT};line-height:1.6;color:#3f3f46;">${escapeHtml(content.intro)}</p>
|
||||
<tr><td style="padding:40px 30px 6px;font-family:${FONT};text-align:center;">
|
||||
<h1 style="margin:0 0 18px;font:700 28px ${FONT};line-height:1.25;color:#f7f5f5;">${escapeHtml(content.heading)}</h1>
|
||||
<p style="margin:0 0 28px;font:400 15px ${FONT};line-height:1.65;color:#c9c2c2;">${escapeHtml(content.intro)}</p>
|
||||
</td></tr>
|
||||
<tr><td style="padding:0 30px 14px;font-family:${FONT};text-align:center;">
|
||||
${paragraphs}${credentials}${cta}${note}
|
||||
</td></tr>
|
||||
<tr><td style="padding:20px 28px 28px;font-family:${FONT};">
|
||||
<hr style="border:0;border-top:1px solid #e4e4e7;margin:0 0 16px;">
|
||||
<p style="margin:0 0 4px;font:400 12px ${FONT};line-height:1.6;color:#71717a;">Message automatique : merci de ne pas repondre a cet e-mail.</p>
|
||||
<p style="margin:0;font:400 12px ${FONT};line-height:1.6;color:#a1a1aa;">${escapeHtml(brand.footer)}</p>
|
||||
<tr><td style="padding:20px 28px 24px;background:#0d0808;border-top:1px solid #2a1c1c;">
|
||||
<table role="presentation" width="100%" cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<td style="vertical-align:middle;font-family:${FONT};">
|
||||
<p style="margin:0 0 4px;font:400 12px ${FONT};line-height:1.6;color:#8a8282;">Message automatique : merci de ne pas repondre a cet e-mail.</p>
|
||||
<p style="margin:0;font:400 12px ${FONT};line-height:1.6;color:#8a8282;">${escapeHtml(brand.footer)}</p>
|
||||
</td>
|
||||
<td align="right" style="vertical-align:middle;padding-left:16px;">
|
||||
<img src="${escapeHtml(brand.logoUrl)}" width="44" height="44" alt="" style="display:block;border:0;border-radius:10px;background:#ffffff;">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td></tr>
|
||||
</table>
|
||||
<p style="margin:18px 0 0;font:400 12px ${FONT};color:#a1a1aa;">${escapeHtml(brand.appName)} — <a href="${escapeHtml(brand.origin)}" style="color:#a1a1aa;">${escapeHtml(brand.origin.replace(/^https?:\/\//, ""))}</a></p>
|
||||
</td></tr>
|
||||
</table>
|
||||
</body>
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
import { createTransport, type Transporter } from "nodemailer";
|
||||
import type { Config } from "./config.js";
|
||||
import { LOGO_CID } from "./mail-template.js";
|
||||
|
||||
/**
|
||||
* Envoi de courriel via SMTP.
|
||||
@@ -9,6 +11,20 @@ import type { Config } from "./config.js";
|
||||
* laisser une reinitialisation de mot de passe silencieusement sans effet.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Logo embarque dans les messages. Le chemin remonte depuis `src/lib` ou
|
||||
* `dist/lib` vers `backend/src/assets/logo.png`, present dans l'image.
|
||||
*/
|
||||
const LOGO_PATH = new URL("../../src/assets/logo.png", import.meta.url);
|
||||
|
||||
const loadLogo = (): Buffer | null => {
|
||||
try {
|
||||
return readFileSync(LOGO_PATH);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
export interface MailMessage {
|
||||
to: string;
|
||||
subject: string;
|
||||
@@ -33,14 +49,22 @@ export const createMailer = (config: Config): Mailer => {
|
||||
disableUrlAccess: true,
|
||||
});
|
||||
|
||||
// Logo embarque une seule fois. `MAIL_LOGO_URL` le remplace par une image
|
||||
// distante : dans ce cas on n'attache rien.
|
||||
const logo = config.MAIL_LOGO_URL ? null : loadLogo();
|
||||
|
||||
return {
|
||||
send: async (message) => {
|
||||
const inlineLogo = logo !== null && message.html?.includes(`cid:${LOGO_CID}`) === true;
|
||||
await transport.sendMail({
|
||||
from: config.SMTP_FROM,
|
||||
to: message.to,
|
||||
subject: message.subject,
|
||||
text: message.text,
|
||||
...(message.html ? { html: message.html } : {}),
|
||||
...(inlineLogo
|
||||
? { attachments: [{ filename: "logo.png", content: logo, cid: LOGO_CID }] }
|
||||
: {}),
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
+6
-3
@@ -115,9 +115,12 @@ par tous les membres authentifiés, en écriture pour son propriétaire.
|
||||
## Courriels
|
||||
|
||||
Les messages sortants sont construits par `backend/src/lib/mail-template.ts` :
|
||||
gabarit HTML aux couleurs de l'app (`#b71c1c`), logo (`MAIL_LOGO_URL`, défaut
|
||||
`PUBLIC_ORIGIN/logo.png`), bouton d'action et mention **ne pas répondre**. Un
|
||||
repli texte accompagne chaque envoi.
|
||||
gabarit HTML aux couleurs de l'app (`#b71c1c`), logo, bouton d'action et mention
|
||||
**ne pas répondre**. Un repli texte accompagne chaque envoi.
|
||||
|
||||
Le logo `backend/src/assets/logo.png` est **embarqué** dans le message (pièce
|
||||
jointe `cid`), donc visible même quand le client bloque les images distantes.
|
||||
`MAIL_LOGO_URL` force une image distante à la place.
|
||||
|
||||
Points d'envoi : réinitialisation du mot de passe, changement d'adresse, et
|
||||
**notification au nouvel utilisateur** à la création d'un compte admin
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ pose problème (`backend/src/lib/config.ts`).
|
||||
| `SMTP_USER` / `SMTP_PASSWORD` | authentification (vides = relais local) | vide |
|
||||
| `SMTP_FROM` | adresse d'expédition | — |
|
||||
| `SMTP_SECURE` | TLS implicite (port 465) | `false` |
|
||||
| `MAIL_LOGO_URL` | logo des courriels (défaut `PUBLIC_ORIGIN/logo.png`) | vide |
|
||||
| `MAIL_LOGO_URL` | logo distant des courriels (sinon logo embarqué `backend/src/assets/logo.png`) | vide |
|
||||
| `RATE_LIMIT_LOGIN_MAX` | tentatives par fenêtre | `10` |
|
||||
| `RATE_LIMIT_LOGIN_WINDOW_MS` | largeur de fenêtre | `60000` |
|
||||
| `LOG_LEVEL` | `silent…debug` | `info` |
|
||||
|
||||
+2
-2
@@ -7,8 +7,8 @@
|
||||
<meta name="theme-color" content="#b71c1c" />
|
||||
<title>CoHaiSe Cloud</title>
|
||||
<link rel="icon" href="/favicon.ico" sizes="any" />
|
||||
<link rel="icon" type="image/png" href="/logo.png" />
|
||||
<link rel="apple-touch-icon" href="/logo.png" />
|
||||
<link rel="icon" type="image/png" href="/icon.png" />
|
||||
<link rel="apple-touch-icon" href="/icon.png" />
|
||||
<script src="/theme.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 138 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 50 KiB |
@@ -58,6 +58,11 @@ export const AppShell = () => {
|
||||
|
||||
const brand = (
|
||||
<NavLink to="/files" className="flex items-center gap-2" onClick={() => setMenuOpen(false)}>
|
||||
<img
|
||||
src="/icon.png"
|
||||
alt=""
|
||||
className="h-7 w-7 shrink-0 rounded-md ring-1 ring-black/5"
|
||||
/>
|
||||
<span className="font-display text-xs font-semibold uppercase tracking-logo text-accent">
|
||||
CoHaiSe
|
||||
</span>
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
import {
|
||||
createContext,
|
||||
useCallback,
|
||||
useContext,
|
||||
useState,
|
||||
type ReactNode,
|
||||
} from "react";
|
||||
import { Button } from "../ui/index.js";
|
||||
import { Modal } from "./feedback.js";
|
||||
|
||||
export interface ConfirmOptions {
|
||||
/** Titre de la modale. */
|
||||
title?: string;
|
||||
/** Corps du message ; accepte du balisage pour mettre un nom en valeur. */
|
||||
message: ReactNode;
|
||||
confirmLabel?: string;
|
||||
cancelLabel?: string;
|
||||
/** `danger` reserve l'action a une operation destructive. */
|
||||
tone?: "default" | "danger";
|
||||
}
|
||||
|
||||
type ConfirmFn = (options: ConfirmOptions) => Promise<boolean>;
|
||||
|
||||
interface PendingConfirm {
|
||||
options: ConfirmOptions;
|
||||
resolve: (value: boolean) => void;
|
||||
}
|
||||
|
||||
const ConfirmContext = createContext<ConfirmFn | null>(null);
|
||||
|
||||
/**
|
||||
* Remplace `window.confirm` par une modale maison aux couleurs de l'app.
|
||||
* `useConfirm()` renvoie une promesse resolue a `true` (confirme) ou `false`.
|
||||
*/
|
||||
export const ConfirmProvider = ({ children }: { children: ReactNode }) => {
|
||||
const [pending, setPending] = useState<PendingConfirm | null>(null);
|
||||
|
||||
const confirm = useCallback<ConfirmFn>(
|
||||
(options) => new Promise<boolean>((resolve) => setPending({ options, resolve })),
|
||||
[],
|
||||
);
|
||||
|
||||
const answer = (value: boolean) => {
|
||||
if (pending) pending.resolve(value);
|
||||
setPending(null);
|
||||
};
|
||||
|
||||
const tone = pending?.options.tone ?? "default";
|
||||
|
||||
return (
|
||||
<ConfirmContext.Provider value={confirm}>
|
||||
{children}
|
||||
<Modal
|
||||
open={pending !== null}
|
||||
title={pending?.options.title ?? "Confirmation"}
|
||||
onClose={() => answer(false)}
|
||||
>
|
||||
<div className="flex flex-col gap-5">
|
||||
<p className="text-sm leading-relaxed text-muted-foreground">
|
||||
{pending?.options.message}
|
||||
</p>
|
||||
<div className="flex justify-end gap-2">
|
||||
<Button variant="ghost" size="md" onClick={() => answer(false)}>
|
||||
{pending?.options.cancelLabel ?? "Annuler"}
|
||||
</Button>
|
||||
<Button
|
||||
variant={tone === "danger" ? "destructive" : "primary"}
|
||||
size="md"
|
||||
autoFocus
|
||||
onClick={() => answer(true)}
|
||||
>
|
||||
{pending?.options.confirmLabel ?? "Confirmer"}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Modal>
|
||||
</ConfirmContext.Provider>
|
||||
);
|
||||
};
|
||||
|
||||
export const useConfirm = (): ConfirmFn => {
|
||||
const context = useContext(ConfirmContext);
|
||||
if (!context) throw new Error("useConfirm doit etre utilise sous ConfirmProvider");
|
||||
return context;
|
||||
};
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { ReactNode } from "react";
|
||||
import { useEffect, type ReactNode } from "react";
|
||||
import { cn } from "../ui/index.js";
|
||||
import { CloseIcon } from "./icons.js";
|
||||
|
||||
@@ -11,13 +11,27 @@ export const Modal = ({
|
||||
open: boolean;
|
||||
title: string;
|
||||
onClose: () => void;
|
||||
children: React.ReactNode;
|
||||
children: ReactNode;
|
||||
}) => {
|
||||
useEffect(() => {
|
||||
if (!open) return;
|
||||
const onKeyDown = (event: KeyboardEvent) => {
|
||||
if (event.key === "Escape") onClose();
|
||||
};
|
||||
window.addEventListener("keydown", onKeyDown);
|
||||
const previousOverflow = document.body.style.overflow;
|
||||
document.body.style.overflow = "hidden";
|
||||
return () => {
|
||||
window.removeEventListener("keydown", onKeyDown);
|
||||
document.body.style.overflow = previousOverflow;
|
||||
};
|
||||
}, [open, onClose]);
|
||||
|
||||
if (!open) return null;
|
||||
return (
|
||||
<div className="fixed inset-0 z-50 flex items-center justify-center p-4">
|
||||
<div
|
||||
className="absolute inset-0 bg-black/40"
|
||||
className="animate-overlay-in absolute inset-0 bg-black/40 backdrop-blur-[2px]"
|
||||
onClick={onClose}
|
||||
aria-hidden="true"
|
||||
/>
|
||||
@@ -25,7 +39,7 @@ export const Modal = ({
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
aria-label={title}
|
||||
className="relative w-full max-w-md rounded-lg border border-border bg-surface p-4 shadow-lg"
|
||||
className="animate-panel-in relative w-full max-w-md rounded-lg border border-border bg-surface p-4 shadow-lg"
|
||||
>
|
||||
<div className="mb-4 flex items-center justify-between gap-4">
|
||||
<h2 className="font-display text-xs font-semibold uppercase tracking-label text-foreground">
|
||||
@@ -35,7 +49,7 @@ export const Modal = ({
|
||||
type="button"
|
||||
onClick={onClose}
|
||||
aria-label="Fermer"
|
||||
className="text-muted-foreground transition-colors hover:text-foreground"
|
||||
className="rounded-sm text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-ring focus-visible:ring-2 focus-visible:outline-none"
|
||||
>
|
||||
<CloseIcon className="h-5 w-5" />
|
||||
</button>
|
||||
|
||||
@@ -145,6 +145,12 @@ export const CloseIcon = (props: IconProps) => (
|
||||
</svg>
|
||||
);
|
||||
|
||||
export const ArrowLeftIcon = (props: IconProps) => (
|
||||
<svg {...base(props)}>
|
||||
<path d="M19 12H5M11 18l-6-6 6-6" />
|
||||
</svg>
|
||||
);
|
||||
|
||||
export const PenIcon = (props: IconProps) => (
|
||||
<svg {...base(props)}>
|
||||
<path d="M4 20h4L18.5 9.5a2.1 2.1 0 0 0-3-3L5 17v3Z" />
|
||||
|
||||
@@ -3,6 +3,7 @@ import { createRoot } from "react-dom/client";
|
||||
import { BrowserRouter } from "react-router-dom";
|
||||
import { App } from "./App.js";
|
||||
import { SessionProvider } from "./lib/session.js";
|
||||
import { ConfirmProvider } from "./components/confirm.js";
|
||||
import "./styles/index.css";
|
||||
|
||||
const container = document.getElementById("root");
|
||||
@@ -15,7 +16,9 @@ createRoot(container).render(
|
||||
<StrictMode>
|
||||
<BrowserRouter>
|
||||
<SessionProvider>
|
||||
<App />
|
||||
<ConfirmProvider>
|
||||
<App />
|
||||
</ConfirmProvider>
|
||||
</SessionProvider>
|
||||
</BrowserRouter>
|
||||
</StrictMode>,
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
type StorageLocation,
|
||||
} from "../lib/api.js";
|
||||
import { Alert, Badge, EmptyState, Modal, PageHeader } from "../components/feedback.js";
|
||||
import { useConfirm } from "../components/confirm.js";
|
||||
import { IconAction } from "../components/IconAction.js";
|
||||
import {
|
||||
ActivityIcon,
|
||||
@@ -38,6 +39,7 @@ const StatCard = ({ label, value }: { label: string; value: string }) => (
|
||||
);
|
||||
|
||||
export const AdminUsers = () => {
|
||||
const confirm = useConfirm();
|
||||
const [users, setUsers] = useState<AdminUser[] | null>(null);
|
||||
const [stats, setStats] = useState<AdminStats | null>(null);
|
||||
const [q, setQ] = useState("");
|
||||
@@ -95,7 +97,18 @@ export const AdminUsers = () => {
|
||||
};
|
||||
|
||||
const removeUser = async (user: AdminUser) => {
|
||||
if (!window.confirm(`Supprimer définitivement ${user.email} ?`)) return;
|
||||
const ok = await confirm({
|
||||
title: "Supprimer le membre",
|
||||
message: (
|
||||
<>
|
||||
Supprimer définitivement <span className="font-semibold text-foreground">{user.email}</span>{" "}
|
||||
ainsi que ses fichiers ? Cette action est irréversible.
|
||||
</>
|
||||
),
|
||||
confirmLabel: "Supprimer",
|
||||
tone: "danger",
|
||||
});
|
||||
if (!ok) return;
|
||||
setBusy(user.id);
|
||||
setError(null);
|
||||
try {
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
} from "../lib/api.js";
|
||||
import { useSession } from "../lib/session.js";
|
||||
import { Alert, Badge, EmptyState, PageHeader } from "../components/feedback.js";
|
||||
import { useConfirm } from "../components/confirm.js";
|
||||
import { IconAction } from "../components/IconAction.js";
|
||||
import {
|
||||
CreateFolderDialog,
|
||||
@@ -17,6 +18,7 @@ import {
|
||||
ShareDialog,
|
||||
} from "../components/dialogs.js";
|
||||
import {
|
||||
ArrowLeftIcon,
|
||||
DownloadIcon,
|
||||
FileIcon,
|
||||
FolderIcon,
|
||||
@@ -48,6 +50,7 @@ const isImage = (file: UploadedFile): boolean =>
|
||||
|
||||
export const Browser = () => {
|
||||
const { user, refresh } = useSession();
|
||||
const confirm = useConfirm();
|
||||
const [path, setPath] = useState<Crumb[]>([{ id: null, name: "Racine" }]);
|
||||
const [folders, setFolders] = useState<Folder[]>([]);
|
||||
const [files, setFiles] = useState<UploadedFile[]>([]);
|
||||
@@ -111,7 +114,18 @@ export const Browser = () => {
|
||||
|
||||
const removeTarget = async (target: Target) => {
|
||||
const label = target.type === "folder" ? "ce dossier" : "ce fichier";
|
||||
if (!window.confirm(`Placer ${label} dans la corbeille ?`)) return;
|
||||
const ok = await confirm({
|
||||
title: "Mettre à la corbeille",
|
||||
message: (
|
||||
<>
|
||||
Placer <span className="font-semibold text-foreground">{target.name}</span> ({label}) dans la
|
||||
corbeille ?
|
||||
</>
|
||||
),
|
||||
confirmLabel: "Corbeille",
|
||||
tone: "danger",
|
||||
});
|
||||
if (!ok) return;
|
||||
setRemoving(target.id);
|
||||
setError(null);
|
||||
try {
|
||||
@@ -153,32 +167,45 @@ export const Browser = () => {
|
||||
description="Vos dossiers et fichiers. Envoyez un fichier ou créez un dossier."
|
||||
/>
|
||||
|
||||
<nav aria-label="Fil d'Ariane">
|
||||
<ol className="flex flex-wrap items-center gap-1.5 text-xs">
|
||||
{path.map((crumb, index) => (
|
||||
<li key={`${crumb.id ?? "root"}-${index}`} className="flex items-center gap-1.5">
|
||||
{index > 0 ? (
|
||||
<span className="text-border" aria-hidden="true">
|
||||
/
|
||||
</span>
|
||||
) : null}
|
||||
{index === path.length - 1 ? (
|
||||
<span className="font-medium text-foreground" aria-current="page">
|
||||
{crumb.name}
|
||||
</span>
|
||||
) : (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => goTo(index)}
|
||||
className="text-muted-foreground underline-offset-2 transition-colors hover:text-foreground hover:underline"
|
||||
>
|
||||
{crumb.name}
|
||||
</button>
|
||||
)}
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
</nav>
|
||||
<div className="flex flex-wrap items-center gap-3">
|
||||
{path.length > 1 ? (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => goTo(path.length - 2)}
|
||||
className="inline-flex items-center gap-1.5 rounded-sm border border-border-control bg-surface px-2.5 py-1.5 font-display text-[0.6875rem] font-semibold uppercase tracking-label text-foreground transition-colors duration-fast hover:bg-surface-hover focus-visible:ring-ring focus-visible:ring-2 focus-visible:outline-none"
|
||||
>
|
||||
<ArrowLeftIcon className="h-3.5 w-3.5" />
|
||||
Retour
|
||||
</button>
|
||||
) : null}
|
||||
|
||||
<nav aria-label="Fil d'Ariane" className="min-w-0">
|
||||
<ol className="flex flex-wrap items-center gap-1.5 text-xs">
|
||||
{path.map((crumb, index) => (
|
||||
<li key={`${crumb.id ?? "root"}-${index}`} className="flex items-center gap-1.5">
|
||||
{index > 0 ? (
|
||||
<span className="text-border" aria-hidden="true">
|
||||
/
|
||||
</span>
|
||||
) : null}
|
||||
{index === path.length - 1 ? (
|
||||
<span className="font-medium text-foreground" aria-current="page">
|
||||
{crumb.name}
|
||||
</span>
|
||||
) : (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => goTo(index)}
|
||||
className="text-muted-foreground underline-offset-2 transition-colors hover:text-foreground hover:underline"
|
||||
>
|
||||
{crumb.name}
|
||||
</button>
|
||||
)}
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
<Card>
|
||||
<div className="flex flex-col gap-3 p-4 sm:flex-row sm:items-center sm:justify-between">
|
||||
|
||||
@@ -37,12 +37,21 @@ export const ChangePassword = () => {
|
||||
<main className="flex min-h-dvh items-center justify-center bg-background px-4 py-10">
|
||||
<div className="w-full max-w-sm">
|
||||
<header className="mb-6 text-center">
|
||||
<p className="font-display text-xs font-semibold uppercase tracking-logo text-accent">
|
||||
CoHaiSe
|
||||
</p>
|
||||
<h1 className="font-display mt-2 text-lg font-semibold uppercase tracking-label text-foreground">
|
||||
Nouveau mot de passe
|
||||
</h1>
|
||||
<div className="flex items-center justify-center gap-3">
|
||||
<img
|
||||
src="/icon.png"
|
||||
alt=""
|
||||
className="h-12 w-12 rounded-xl ring-1 ring-black/5"
|
||||
/>
|
||||
<div className="text-left">
|
||||
<p className="font-display text-xs font-semibold uppercase tracking-logo text-accent">
|
||||
CoHaiSe
|
||||
</p>
|
||||
<h1 className="font-display text-lg font-semibold uppercase tracking-label text-foreground">
|
||||
Nouveau mot de passe
|
||||
</h1>
|
||||
</div>
|
||||
</div>
|
||||
<p className="mt-2 text-sm leading-relaxed text-muted-foreground">
|
||||
Bienvenue {user?.first_name ?? ""}. Ce mot de passe a été défini par un
|
||||
administrateur : choisissez le vôtre.
|
||||
|
||||
@@ -37,12 +37,21 @@ export const ConfirmEmail = () => {
|
||||
<main className="flex min-h-dvh items-center justify-center bg-background px-4 py-10">
|
||||
<div className="w-full max-w-sm">
|
||||
<header className="mb-6 text-center">
|
||||
<p className="font-display text-xs font-semibold uppercase tracking-logo text-accent">
|
||||
CoHaiSe
|
||||
</p>
|
||||
<h1 className="font-display mt-2 text-lg font-semibold uppercase tracking-label text-foreground">
|
||||
Changement d'adresse
|
||||
</h1>
|
||||
<div className="flex items-center justify-center gap-3">
|
||||
<img
|
||||
src="/icon.png"
|
||||
alt=""
|
||||
className="h-12 w-12 rounded-xl ring-1 ring-black/5"
|
||||
/>
|
||||
<div className="text-left">
|
||||
<p className="font-display text-xs font-semibold uppercase tracking-logo text-accent">
|
||||
CoHaiSe
|
||||
</p>
|
||||
<h1 className="font-display text-lg font-semibold uppercase tracking-label text-foreground">
|
||||
Changement d'adresse
|
||||
</h1>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<Card>
|
||||
|
||||
@@ -28,12 +28,21 @@ export const ForgotPassword = () => {
|
||||
<main className="flex min-h-dvh items-center justify-center bg-background px-4 py-10">
|
||||
<div className="w-full max-w-sm">
|
||||
<header className="mb-6 text-center">
|
||||
<p className="font-display text-xs font-semibold uppercase tracking-logo text-accent">
|
||||
CoHaiSe
|
||||
</p>
|
||||
<h1 className="font-display mt-2 text-lg font-semibold uppercase tracking-label text-foreground">
|
||||
Mot de passe oublié
|
||||
</h1>
|
||||
<div className="flex items-center justify-center gap-3">
|
||||
<img
|
||||
src="/icon.png"
|
||||
alt=""
|
||||
className="h-12 w-12 rounded-xl ring-1 ring-black/5"
|
||||
/>
|
||||
<div className="text-left">
|
||||
<p className="font-display text-xs font-semibold uppercase tracking-logo text-accent">
|
||||
CoHaiSe
|
||||
</p>
|
||||
<h1 className="font-display text-lg font-semibold uppercase tracking-label text-foreground">
|
||||
Mot de passe oublié
|
||||
</h1>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<Card>
|
||||
|
||||
@@ -33,12 +33,21 @@ export const Login = () => {
|
||||
<main className="flex min-h-dvh items-center justify-center bg-background px-4 py-10">
|
||||
<div className="w-full max-w-sm">
|
||||
<header className="mb-6 text-center">
|
||||
<p className="font-display text-xs font-semibold uppercase tracking-logo text-accent">
|
||||
CoHaiSe
|
||||
</p>
|
||||
<h1 className="font-display mt-2 text-lg font-semibold uppercase tracking-label text-foreground">
|
||||
Cloud
|
||||
</h1>
|
||||
<div className="flex items-center justify-center gap-3">
|
||||
<img
|
||||
src="/icon.png"
|
||||
alt=""
|
||||
className="h-12 w-12 rounded-xl ring-1 ring-black/5"
|
||||
/>
|
||||
<div className="text-left">
|
||||
<p className="font-display text-xs font-semibold uppercase tracking-logo text-accent">
|
||||
CoHaiSe
|
||||
</p>
|
||||
<h1 className="font-display text-lg font-semibold uppercase tracking-label text-foreground">
|
||||
Cloud
|
||||
</h1>
|
||||
</div>
|
||||
</div>
|
||||
<p className="mt-2 text-sm leading-relaxed text-muted-foreground">
|
||||
Connectez-vous pour accéder à vos fichiers.
|
||||
</p>
|
||||
|
||||
@@ -3,10 +3,12 @@ import { Button, Card, CardContent, CardDescription, CardHeader, CardTitle, Inpu
|
||||
import { ApiError, api, formatDate, type SessionInfo } from "../lib/api.js";
|
||||
import { useSession } from "../lib/session.js";
|
||||
import { Alert, Badge, PageHeader } from "../components/feedback.js";
|
||||
import { useConfirm } from "../components/confirm.js";
|
||||
import { TrashIcon } from "../components/icons.js";
|
||||
|
||||
export const Profile = () => {
|
||||
const { user, refresh } = useSession();
|
||||
const confirm = useConfirm();
|
||||
|
||||
const [firstName, setFirstName] = useState(user?.first_name ?? "");
|
||||
const [lastName, setLastName] = useState(user?.last_name ?? "");
|
||||
@@ -107,7 +109,14 @@ export const Profile = () => {
|
||||
};
|
||||
|
||||
const revokeSession = async (session: SessionInfo) => {
|
||||
if (session.current && !window.confirm("Fermer la session en cours ?")) return;
|
||||
if (session.current) {
|
||||
const ok = await confirm({
|
||||
title: "Fermer la session",
|
||||
message: "Fermer la session en cours vous déconnectera immédiatement.",
|
||||
confirmLabel: "Fermer",
|
||||
});
|
||||
if (!ok) return;
|
||||
}
|
||||
setRevoking(session.id);
|
||||
setSessionsError(null);
|
||||
try {
|
||||
|
||||
@@ -35,12 +35,21 @@ export const ResetPassword = () => {
|
||||
<main className="flex min-h-dvh items-center justify-center bg-background px-4 py-10">
|
||||
<div className="w-full max-w-sm">
|
||||
<header className="mb-6 text-center">
|
||||
<p className="font-display text-xs font-semibold uppercase tracking-logo text-accent">
|
||||
CoHaiSe
|
||||
</p>
|
||||
<h1 className="font-display mt-2 text-lg font-semibold uppercase tracking-label text-foreground">
|
||||
Nouveau mot de passe
|
||||
</h1>
|
||||
<div className="flex items-center justify-center gap-3">
|
||||
<img
|
||||
src="/icon.png"
|
||||
alt=""
|
||||
className="h-12 w-12 rounded-xl ring-1 ring-black/5"
|
||||
/>
|
||||
<div className="text-left">
|
||||
<p className="font-display text-xs font-semibold uppercase tracking-logo text-accent">
|
||||
CoHaiSe
|
||||
</p>
|
||||
<h1 className="font-display text-lg font-semibold uppercase tracking-label text-foreground">
|
||||
Nouveau mot de passe
|
||||
</h1>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<Card>
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
type TrashFolder,
|
||||
} from "../lib/api.js";
|
||||
import { Alert, EmptyState, PageHeader } from "../components/feedback.js";
|
||||
import { useConfirm } from "../components/confirm.js";
|
||||
import { IconAction } from "../components/IconAction.js";
|
||||
import { FileIcon, FolderIcon, RestoreIcon, TrashIcon } from "../components/icons.js";
|
||||
|
||||
@@ -19,6 +20,7 @@ interface TrashData {
|
||||
}
|
||||
|
||||
export const Trash = () => {
|
||||
const confirm = useConfirm();
|
||||
const [data, setData] = useState<TrashData | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
@@ -54,11 +56,33 @@ export const Trash = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const emptyTrash = () => {
|
||||
if (!window.confirm("Vider définitivement la corbeille ?")) return;
|
||||
const emptyTrash = async () => {
|
||||
const ok = await confirm({
|
||||
title: "Vider la corbeille",
|
||||
message: "Tous les éléments seront définitivement supprimés. Cette action est irréversible.",
|
||||
confirmLabel: "Vider",
|
||||
tone: "danger",
|
||||
});
|
||||
if (!ok) return;
|
||||
void run("empty", () => api.emptyTrash());
|
||||
};
|
||||
|
||||
const purge = async (key: string, name: string, action: () => Promise<unknown>) => {
|
||||
const ok = await confirm({
|
||||
title: "Supprimer définitivement",
|
||||
message: (
|
||||
<>
|
||||
Supprimer définitivement <span className="font-semibold text-foreground">{name}</span> ?
|
||||
Cette action est irréversible.
|
||||
</>
|
||||
),
|
||||
confirmLabel: "Supprimer",
|
||||
tone: "danger",
|
||||
});
|
||||
if (!ok) return;
|
||||
void run(key, action);
|
||||
};
|
||||
|
||||
const empty = data !== null && data.folders.length === 0 && data.files.length === 0;
|
||||
|
||||
return (
|
||||
@@ -125,11 +149,11 @@ export const Trash = () => {
|
||||
icon={<TrashIcon className="h-4 w-4" />}
|
||||
tone="danger"
|
||||
isLoading={busy === `purge-${folder.id}`}
|
||||
onClick={() => {
|
||||
if (window.confirm(`Supprimer définitivement « ${folder.name} » ?`)) {
|
||||
void run(`purge-${folder.id}`, () => api.purgeFolder(folder.id));
|
||||
}
|
||||
}}
|
||||
onClick={() =>
|
||||
void purge(`purge-${folder.id}`, folder.name, () =>
|
||||
api.purgeFolder(folder.id),
|
||||
)
|
||||
}
|
||||
/>
|
||||
</li>
|
||||
))}
|
||||
@@ -170,7 +194,7 @@ export const Trash = () => {
|
||||
isLoading={busy === `purge-${file.id}`}
|
||||
tone="danger"
|
||||
onClick={() =>
|
||||
void run(`purge-${file.id}`, () => api.purgeFile(file.id))
|
||||
void purge(`purge-${file.id}`, file.name, () => api.purgeFile(file.id))
|
||||
}
|
||||
/>
|
||||
</li>
|
||||
|
||||
@@ -103,3 +103,42 @@
|
||||
@utility duration-slow {
|
||||
transition-duration: var(--cohaise-duration-slow);
|
||||
}
|
||||
|
||||
/* Entree des surfaces modales (overlay + panneau). */
|
||||
@keyframes cohaise-overlay-in {
|
||||
from {
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes cohaise-panel-in {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(0.5rem) scale(0.98);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0) scale(1);
|
||||
}
|
||||
}
|
||||
|
||||
@utility animate-overlay-in {
|
||||
animation: cohaise-overlay-in var(--cohaise-duration-base) var(--cohaise-ease-out-soft) both;
|
||||
}
|
||||
|
||||
@utility animate-panel-in {
|
||||
animation: cohaise-panel-in var(--cohaise-duration-base) var(--cohaise-ease-out-soft) both;
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
*,
|
||||
*::before,
|
||||
*::after {
|
||||
animation-duration: 0.01ms !important;
|
||||
animation-iteration-count: 1 !important;
|
||||
transition-duration: 0.01ms !important;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user