feat(ui): glass layout, icon actions and new icon set (#21)
CD — Deployment / deploy (push) Successful in 33s
PR automatique de feat/ui-glass-layout-icons vers main. --------- Co-authored-by: xEsiah <[email protected]> Reviewed-on: #21 Reviewed-by: Esiah <[email protected]> Co-authored-by: Gitea Actions <-[email protected]>
@@ -19,7 +19,8 @@ CLOUD_DB_DIR=../db
|
||||
CLOUD_MEDIA_DIR=../media
|
||||
|
||||
# --- Session (obligatoire pour toute API) -------------------------------
|
||||
# Secret de chiffrement des sessions. Obligatoire, 32 caracteres minimum.
|
||||
# Secret qui poivre (HMAC-SHA-256) les jetons de session stockes en base.
|
||||
# Obligatoire, 32 caracteres minimum. Le changer invalide toutes les sessions.
|
||||
# Generation :
|
||||
# node -e "console.log(require('node:crypto').randomBytes(32).toString('hex'))"
|
||||
SESSION_SECRET=
|
||||
|
||||
@@ -32,7 +32,7 @@ L'app répond sur **`http://localhost:8083`** (variable `COHAISE_HTTP_PORT`).
|
||||
| `COHAISE_DB_PORT` | port MariaDB | `3407` |
|
||||
| `CLOUD_DB_USER` / `CLOUD_DB_PASSWORD` | identifiants base | — |
|
||||
| `CLOUD_DB_ROOT_PASSWORD` | root, pour la sauvegarde | — |
|
||||
| `SESSION_SECRET` | signature des sessions, obligatoire | — |
|
||||
| `SESSION_SECRET` | poivre HMAC des sessions, obligatoire | — |
|
||||
|
||||
Le démarrage échoue avec la liste exacte des variables manquantes ou mal formées,
|
||||
avant l'ouverture d'aucun port. C'est voulu.
|
||||
|
||||
@@ -25,13 +25,13 @@ void startService({
|
||||
registerAuthRoutes(app, db, config);
|
||||
registerAccountRoutes(app, db, config);
|
||||
registerChatRoutes(app, db, config);
|
||||
registerDirectoryRoutes(app, db);
|
||||
registerDirectoryRoutes(app, db, config);
|
||||
registerFolderRoutes(app, db, config);
|
||||
registerFileRoutes(app, db, config);
|
||||
registerUploadRoutes(app, db, config);
|
||||
registerMediaRoutes(app, db);
|
||||
registerMediaRoutes(app, db, config);
|
||||
registerTrashRoutes(app, db, config);
|
||||
registerSearchRoutes(app, db);
|
||||
registerSearchRoutes(app, db, config);
|
||||
registerAdminRoutes(app, db, config);
|
||||
},
|
||||
onReady: async ({ db, config, logger }) => {
|
||||
@@ -48,5 +48,18 @@ void startService({
|
||||
logger.error("purge des envois inacheves", { error: String(error) }),
|
||||
);
|
||||
}, 60 * 60 * 1000).unref();
|
||||
|
||||
// Sessions expirees et corbeille hors retention : sans ce balayage, elles
|
||||
// ne disparaissent qu'au redemarrage. Les jetons expires sont deja refuses
|
||||
// a chaque requete ; il s'agit ici d'eviter une table qui grossit sans fin
|
||||
// et de faire respecter la retention de la corbeille sans redemarrage.
|
||||
setInterval(() => {
|
||||
void purgeExpiredSessions(db).catch((error: unknown) =>
|
||||
logger.error("purge des sessions expirees", { error: String(error) }),
|
||||
);
|
||||
void purgeExpiredTrash(db, config).catch((error: unknown) =>
|
||||
logger.error("purge de la corbeille", { error: String(error) }),
|
||||
);
|
||||
}, 60 * 60 * 1000).unref();
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
import { createHash, randomBytes, randomUUID, scrypt as scryptCallback, timingSafeEqual } from "node:crypto";
|
||||
import {
|
||||
createHash,
|
||||
createHmac,
|
||||
randomBytes,
|
||||
randomUUID,
|
||||
scrypt as scryptCallback,
|
||||
timingSafeEqual,
|
||||
} from "node:crypto";
|
||||
import { promisify } from "node:util";
|
||||
import type { Context, Next } from "hono";
|
||||
import { getCookie, setCookie, deleteCookie } from "hono/cookie";
|
||||
@@ -48,6 +55,17 @@ export const verifyPassword = async (password: string, stored: string): Promise<
|
||||
|
||||
export const sha256 = (value: string): string => createHash("sha256").update(value).digest("hex");
|
||||
|
||||
/**
|
||||
* Empreinte du jeton de session : SHA-256 poivre par SESSION_SECRET.
|
||||
*
|
||||
* Sans ce poivre, une ecriture frauduleuse dans `user_sessions` suffirait a
|
||||
* forger une session : l'attaquant connaitrait le hachage a poser. Le secret
|
||||
* vit hors de la base, donc une fuite de la base seule ne donne aucune session
|
||||
* ouvrable.
|
||||
*/
|
||||
export const sessionTokenHash = (token: string, secret: string): string =>
|
||||
createHmac("sha256", secret).update(token).digest("hex");
|
||||
|
||||
/**
|
||||
* Portrait de l'utilisateur porte par la session.
|
||||
*
|
||||
@@ -74,15 +92,17 @@ export interface SessionMeta {
|
||||
export const SESSION_COOKIE = "cohaise_session";
|
||||
|
||||
/**
|
||||
* Le jeton brut part dans le cookie, son empreinte SHA-256 dans la base.
|
||||
* Une copie de la base ne donne donc aucune session ouvrable : il faudrait
|
||||
* en plus la table des cookies, qui n'existe pas.
|
||||
* Le jeton brut part dans le cookie, son empreinte HMAC-SHA-256 (poivree par
|
||||
* SESSION_SECRET) dans la base. Une copie de la base ne donne donc aucune
|
||||
* session ouvrable : il faudrait en plus la table des cookies, qui n'existe pas,
|
||||
* et le secret, qui vit hors de la base.
|
||||
*/
|
||||
export const createSession = async (
|
||||
db: Db,
|
||||
userId: string,
|
||||
meta: SessionMeta,
|
||||
ttlHours: number,
|
||||
secret: string,
|
||||
): Promise<{ token: string; expiresAt: Date }> => {
|
||||
const token = randomBytes(32).toString("base64url");
|
||||
const expiresAt = new Date(Date.now() + ttlHours * 3600_000);
|
||||
@@ -93,7 +113,7 @@ export const createSession = async (
|
||||
[
|
||||
randomUUID(),
|
||||
userId,
|
||||
sha256(token),
|
||||
sessionTokenHash(token, secret),
|
||||
meta.ipAddress ?? null,
|
||||
meta.userAgent?.slice(0, 255) ?? null,
|
||||
expiresAt,
|
||||
@@ -102,7 +122,11 @@ export const createSession = async (
|
||||
return { token, expiresAt };
|
||||
};
|
||||
|
||||
export const resolveSession = async (db: Db, token: string): Promise<SessionUser | null> => {
|
||||
export const resolveSession = async (
|
||||
db: Db,
|
||||
token: string,
|
||||
secret: string,
|
||||
): Promise<SessionUser | null> => {
|
||||
const row = await db.one<SessionUser & { last_seen_at: string }>(
|
||||
`SELECT u.id, u.email, u.first_name, u.last_name,
|
||||
r.slug AS role_slug, r.name AS role_name,
|
||||
@@ -116,20 +140,20 @@ export const resolveSession = async (db: Db, token: string): Promise<SessionUser
|
||||
AND s.expires_at > UTC_TIMESTAMP()
|
||||
AND u.deleted_at IS NULL
|
||||
AND u.is_active = 1`,
|
||||
[sha256(token)],
|
||||
[sessionTokenHash(token, secret)],
|
||||
);
|
||||
if (!row) return null;
|
||||
// Etat vu, avec un decalage de 60 s pour ne pas ecrire a chaque requete.
|
||||
await db.exec(
|
||||
"UPDATE user_sessions SET last_seen_at = UTC_TIMESTAMP() WHERE token_hash = ? AND last_seen_at < UTC_TIMESTAMP(3) - INTERVAL 60 SECOND",
|
||||
[sha256(token)],
|
||||
[sessionTokenHash(token, secret)],
|
||||
);
|
||||
return row;
|
||||
};
|
||||
|
||||
export const revokeSession = async (db: Db, token: string): Promise<void> => {
|
||||
export const revokeSession = async (db: Db, token: string, secret: string): Promise<void> => {
|
||||
await db.exec("UPDATE user_sessions SET revoked_at = UTC_TIMESTAMP() WHERE token_hash = ?", [
|
||||
sha256(token),
|
||||
sessionTokenHash(token, secret),
|
||||
]);
|
||||
};
|
||||
|
||||
@@ -183,11 +207,11 @@ export interface AuthState {
|
||||
|
||||
/** Lit le cookie et attache l'utilisateur, sans exiger qu'il existe. */
|
||||
export const attachUser =
|
||||
(db: Db) =>
|
||||
(db: Db, secret: string) =>
|
||||
async (context: Context, next: Next): Promise<void> => {
|
||||
const token = getCookie(context, SESSION_COOKIE);
|
||||
if (token) {
|
||||
const user = await resolveSession(db, token);
|
||||
const user = await resolveSession(db, token, secret);
|
||||
if (user) {
|
||||
context.set("user", user);
|
||||
context.set("token", token);
|
||||
@@ -198,9 +222,23 @@ export const attachUser =
|
||||
await next();
|
||||
};
|
||||
|
||||
/**
|
||||
* Routes encore accessibles lorsqu'un changement de mot de passe est impose :
|
||||
* lire son profil, changer le mot de passe, se deconnecter. Tout le reste est
|
||||
* refuse cote serveur, et pas seulement par la redirection du client.
|
||||
*/
|
||||
const PASSWORD_CHANGE_ALLOWED = new Set([
|
||||
"/api/cloud/auth/me",
|
||||
"/api/cloud/auth/change-password",
|
||||
"/api/cloud/auth/logout",
|
||||
]);
|
||||
|
||||
export const requireAuth = async (context: Context, next: Next): Promise<void> => {
|
||||
const user = context.get("user") as SessionUser | undefined;
|
||||
if (!user) throw AppError.unauthorized();
|
||||
if (user.must_change_password === 1 && !PASSWORD_CHANGE_ALLOWED.has(context.req.path)) {
|
||||
throw AppError.forbidden("Vous devez changer votre mot de passe avant de continuer.");
|
||||
}
|
||||
await next();
|
||||
};
|
||||
|
||||
|
||||
@@ -75,6 +75,62 @@ export const clientIp = (context: Context, trustProxy: boolean): string | null =
|
||||
return address ? address.slice(0, 45) : null;
|
||||
};
|
||||
|
||||
/** Taille maximale d'un corps JSON. Les envois de fichiers ont leur propre flux borne. */
|
||||
export const JSON_BODY_MAX_BYTES = 1024 * 1024;
|
||||
|
||||
/**
|
||||
* Lit le corps de la requete en memoire, avec une borne dure sur les octets
|
||||
* reellement recus. `content-length` est verifie d'abord pour refuser tot, mais
|
||||
* la lecture bornee est la vraie garantie : un client peut mentir sur l'en-tete
|
||||
* et envoyer davantage que ce qu'il annonce.
|
||||
*/
|
||||
export const readBodyCapped = async (context: Context, maxBytes: number): Promise<Buffer> => {
|
||||
const declared = Number(context.req.header("content-length") ?? "");
|
||||
if (Number.isFinite(declared) && declared > maxBytes) {
|
||||
throw AppError.payloadTooLarge("Corps de requete trop volumineux.");
|
||||
}
|
||||
|
||||
const body = context.req.raw.body;
|
||||
if (body === null) return Buffer.alloc(0);
|
||||
|
||||
const chunks: Uint8Array[] = [];
|
||||
let received = 0;
|
||||
const reader = body.getReader();
|
||||
try {
|
||||
for (;;) {
|
||||
const { done, value } = await reader.read();
|
||||
if (done) break;
|
||||
received += value.byteLength;
|
||||
if (received > maxBytes) {
|
||||
await reader.cancel().catch(() => undefined);
|
||||
throw AppError.payloadTooLarge("Corps de requete trop volumineux.");
|
||||
}
|
||||
chunks.push(value);
|
||||
}
|
||||
} finally {
|
||||
reader.releaseLock();
|
||||
}
|
||||
return Buffer.concat(chunks);
|
||||
};
|
||||
|
||||
/**
|
||||
* Parse le corps JSON avec la meme borne. Un corps absent ou illisible rend
|
||||
* `null`, comme l'ancien `req.json().catch(() => null)` : les routes continuent
|
||||
* de repondre par leur validation zod habituelle.
|
||||
*/
|
||||
export const readJson = async (
|
||||
context: Context,
|
||||
maxBytes = JSON_BODY_MAX_BYTES,
|
||||
): Promise<unknown> => {
|
||||
const buffer = await readBodyCapped(context, maxBytes);
|
||||
if (buffer.byteLength === 0) return null;
|
||||
try {
|
||||
return JSON.parse(buffer.toString("utf8")) as unknown;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
/** Dependances remises aux routes metier au montage. */
|
||||
export interface RouteDeps {
|
||||
db: Db;
|
||||
|
||||
@@ -11,6 +11,9 @@ export {
|
||||
createApp,
|
||||
createLogger,
|
||||
clientIp,
|
||||
JSON_BODY_MAX_BYTES,
|
||||
readBodyCapped,
|
||||
readJson,
|
||||
type App,
|
||||
type AppEnv,
|
||||
type AppOptions,
|
||||
@@ -29,6 +32,7 @@ export {
|
||||
purgeExpiredSessions,
|
||||
revokeSession,
|
||||
SESSION_COOKIE,
|
||||
sessionTokenHash,
|
||||
setSessionCookie,
|
||||
sha256,
|
||||
verifyPassword,
|
||||
|
||||
@@ -48,6 +48,17 @@ export const classify = (mime: string | null): MediaKind => {
|
||||
export const isImage = (mime: string | null): boolean =>
|
||||
(mime ?? "").toLowerCase().startsWith("image/");
|
||||
|
||||
/**
|
||||
* Le SVG est une image au sens MIME, mais pas une image sure a decoder :
|
||||
* librsvg peut resolvere des references externes et son moteur est une surface
|
||||
* d'attaque supplementaire. Il est deja exclu de l'apercu en ligne ; on ne le
|
||||
* passe pas non plus a sharp pour la vignette. Le fichier reste telechargeable.
|
||||
*/
|
||||
const isRasterImage = (mime: string | null): boolean => {
|
||||
const value = (mime ?? "").toLowerCase();
|
||||
return value.startsWith("image/") && value !== "image/svg+xml";
|
||||
};
|
||||
|
||||
export const thumbnailRelativePath = (fileId: string): string =>
|
||||
path.posix.join("thumbnails", `${fileId}.webp`);
|
||||
|
||||
@@ -99,7 +110,7 @@ export const indexMedia = async (
|
||||
): Promise<void> => {
|
||||
const kind = classify(mimeType);
|
||||
|
||||
if (!isImage(mimeType)) {
|
||||
if (!isRasterImage(mimeType)) {
|
||||
await db.exec(
|
||||
`INSERT INTO media_metadata (file_id, kind) VALUES (?, ?)
|
||||
ON DUPLICATE KEY UPDATE kind = VALUES(kind)`,
|
||||
|
||||
@@ -15,8 +15,11 @@ import {
|
||||
hashPassword,
|
||||
link,
|
||||
rateLimitKey,
|
||||
readBodyCapped,
|
||||
readJson,
|
||||
renderMail,
|
||||
requireAuth,
|
||||
sessionTokenHash,
|
||||
sha256,
|
||||
verifyPassword,
|
||||
type App,
|
||||
@@ -69,8 +72,8 @@ const emailChangeInput = z.object({
|
||||
});
|
||||
|
||||
export const registerAccountRoutes = (app: App, db: Db, config: Config): void => {
|
||||
app.use("/api/cloud/account/*", attachUser(db));
|
||||
app.use("/api/cloud/account", attachUser(db));
|
||||
app.use("/api/cloud/account/*", attachUser(db, config.SESSION_SECRET));
|
||||
app.use("/api/cloud/account", attachUser(db, config.SESSION_SECRET));
|
||||
const mailer = createMailer(config);
|
||||
const brand = branding(config);
|
||||
const limiter = createRateLimiter(config.RATE_LIMIT_LOGIN_MAX, config.RATE_LIMIT_LOGIN_WINDOW_MS);
|
||||
@@ -85,7 +88,7 @@ export const registerAccountRoutes = (app: App, db: Db, config: Config): void =>
|
||||
|
||||
app.patch("/api/cloud/account/profile", requireAuth, async (context) => {
|
||||
const user = currentUser(context);
|
||||
const data = parse(profileInput, await context.req.json().catch(() => null));
|
||||
const data = parse(profileInput, await readJson(context));
|
||||
await db.exec("UPDATE users SET first_name = ?, last_name = ? WHERE id = ?", [
|
||||
data.first_name,
|
||||
data.last_name,
|
||||
@@ -107,7 +110,7 @@ export const registerAccountRoutes = (app: App, db: Db, config: Config): void =>
|
||||
|
||||
app.patch("/api/cloud/account/preferences", requireAuth, async (context) => {
|
||||
const user = currentUser(context);
|
||||
const data = parse(preferencesInput, await context.req.json().catch(() => null));
|
||||
const data = parse(preferencesInput, await readJson(context));
|
||||
await db.exec("UPDATE users SET theme = ?, language = ? WHERE id = ?", [
|
||||
data.theme,
|
||||
data.language,
|
||||
@@ -118,7 +121,7 @@ export const registerAccountRoutes = (app: App, db: Db, config: Config): void =>
|
||||
|
||||
app.get("/api/cloud/account/sessions", requireAuth, async (context) => {
|
||||
const user = currentUser(context);
|
||||
const current = sha256(context.get("token") ?? "");
|
||||
const current = sessionTokenHash(context.get("token") ?? "", config.SESSION_SECRET);
|
||||
const rows = await db.query<{
|
||||
id: string;
|
||||
token_hash: string;
|
||||
@@ -160,7 +163,7 @@ export const registerAccountRoutes = (app: App, db: Db, config: Config): void =>
|
||||
|
||||
app.delete("/api/cloud/account/sessions", requireAuth, async (context) => {
|
||||
const user = currentUser(context);
|
||||
const current = sha256(context.get("token") ?? "");
|
||||
const current = sessionTokenHash(context.get("token") ?? "", config.SESSION_SECRET);
|
||||
await db.exec(
|
||||
"UPDATE user_sessions SET revoked_at = UTC_TIMESTAMP() WHERE user_id = ? AND token_hash <> ? AND revoked_at IS NULL",
|
||||
[user.id, current],
|
||||
@@ -178,7 +181,7 @@ export const registerAccountRoutes = (app: App, db: Db, config: Config): void =>
|
||||
throw AppError.payloadTooLarge("L'image ne doit pas depasser 8 Mo.");
|
||||
}
|
||||
|
||||
const source = Buffer.from(await context.req.arrayBuffer());
|
||||
const source = await readBodyCapped(context, AVATAR_MAX_BYTES);
|
||||
let processed: Buffer;
|
||||
try {
|
||||
processed = await sharp(source, { failOn: "none" })
|
||||
@@ -274,7 +277,7 @@ export const registerAccountRoutes = (app: App, db: Db, config: Config): void =>
|
||||
});
|
||||
|
||||
app.post("/api/cloud/account/forgot-password", async (context) => {
|
||||
const data = parse(forgotInput, await context.req.json().catch(() => null));
|
||||
const data = parse(forgotInput, await readJson(context));
|
||||
throttle(context, `forgot:${data.email.toLowerCase()}`);
|
||||
|
||||
const user = await db.one<{ id: string; email: string }>(
|
||||
@@ -312,7 +315,7 @@ export const registerAccountRoutes = (app: App, db: Db, config: Config): void =>
|
||||
});
|
||||
|
||||
app.post("/api/cloud/account/reset-password", async (context) => {
|
||||
const data = parse(resetInput, await context.req.json().catch(() => null));
|
||||
const data = parse(resetInput, await readJson(context));
|
||||
throttle(context, "reset");
|
||||
|
||||
const row = await db.one<{ id: string; user_id: string }>(
|
||||
@@ -362,7 +365,7 @@ export const registerAccountRoutes = (app: App, db: Db, config: Config): void =>
|
||||
|
||||
app.post("/api/cloud/account/email-change", requireAuth, async (context) => {
|
||||
const user = currentUser(context);
|
||||
const data = parse(emailChangeInput, await context.req.json().catch(() => null));
|
||||
const data = parse(emailChangeInput, await readJson(context));
|
||||
throttle(context, `email:${user.id}`);
|
||||
|
||||
const row = await db.one<{ password_hash: string }>(
|
||||
@@ -419,7 +422,7 @@ export const registerAccountRoutes = (app: App, db: Db, config: Config): void =>
|
||||
app.post("/api/cloud/account/email-change/confirm", async (context) => {
|
||||
const data = parse(
|
||||
z.object({ token: z.string().min(10).max(400) }),
|
||||
await context.req.json().catch(() => null),
|
||||
await readJson(context),
|
||||
);
|
||||
|
||||
const row = await db.one<{ id: string; user_id: string; new_email: string }>(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { randomUUID } from "node:crypto";
|
||||
import { randomInt, randomUUID } from "node:crypto";
|
||||
import { z } from "zod";
|
||||
import {
|
||||
AppError,
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
link,
|
||||
renderMail,
|
||||
requireAuth,
|
||||
readJson,
|
||||
type App,
|
||||
type Config,
|
||||
type Db,
|
||||
@@ -116,10 +117,10 @@ const humanBytes = (bytes: number): string => {
|
||||
/** Mot de passe aleatoire, lisible a la frappe, sans caractere ambigu. */
|
||||
const generatePasswordValue = (): string => {
|
||||
const alphabet = "abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789";
|
||||
const bytes = new Uint8Array(18);
|
||||
globalThis.crypto.getRandomValues(bytes);
|
||||
// randomInt borne directement l'intervalle : pas de biais modulo, contrairement
|
||||
// a `octet % longueur` qui favorise les premiers caracteres de l'alphabet.
|
||||
let out = "";
|
||||
for (const byte of bytes) out += alphabet[byte % alphabet.length];
|
||||
for (let index = 0; index < 18; index += 1) out += alphabet[randomInt(alphabet.length)];
|
||||
return out;
|
||||
};
|
||||
|
||||
@@ -208,8 +209,8 @@ const rehomeUserFolders = async (db: Db, userId: string): Promise<{ kept: number
|
||||
};
|
||||
|
||||
export const registerAdminRoutes = (app: App, db: Db, config: Config): void => {
|
||||
app.use("/api/cloud/admin/*", attachUser(db));
|
||||
app.use("/api/cloud/admin", attachUser(db));
|
||||
app.use("/api/cloud/admin/*", attachUser(db, config.SESSION_SECRET));
|
||||
app.use("/api/cloud/admin", attachUser(db, config.SESSION_SECRET));
|
||||
const mailer = createMailer(config);
|
||||
const brand = branding(config);
|
||||
|
||||
@@ -285,7 +286,7 @@ export const registerAdminRoutes = (app: App, db: Db, config: Config): void => {
|
||||
|
||||
app.post("/api/cloud/admin/users", requireAuth, async (context) => {
|
||||
requireAdmin(context);
|
||||
const data = parse(createUserSchema, await context.req.json().catch(() => null));
|
||||
const data = parse(createUserSchema, await readJson(context));
|
||||
|
||||
const role = await db.one<{ id: number }>("SELECT id FROM roles WHERE slug = ?", [data.role_slug]);
|
||||
if (!role) throw AppError.badRequest("Role inconnu.");
|
||||
@@ -339,7 +340,7 @@ export const registerAdminRoutes = (app: App, db: Db, config: Config): void => {
|
||||
const existing = await db.one<AdminUserRow>(`${SELECT_USER} WHERE u.id = ? AND u.deleted_at IS NULL`, [id]);
|
||||
if (!existing) throw AppError.notFound("Compte introuvable.");
|
||||
|
||||
const data = parse(updateUserSchema, await context.req.json().catch(() => null));
|
||||
const data = parse(updateUserSchema, await readJson(context));
|
||||
|
||||
if (data.role_slug !== undefined && data.role_slug !== existing.role_slug) {
|
||||
const role = await db.one<{ id: number }>("SELECT id FROM roles WHERE slug = ?", [data.role_slug]);
|
||||
@@ -465,7 +466,7 @@ export const registerAdminRoutes = (app: App, db: Db, config: Config): void => {
|
||||
|
||||
app.post("/api/cloud/admin/storage-locations", requireAuth, async (context) => {
|
||||
requireAdmin(context);
|
||||
const data = parse(createLocationSchema, await context.req.json().catch(() => null));
|
||||
const data = parse(createLocationSchema, await readJson(context));
|
||||
if (data.quota_bytes !== undefined && data.quota_bytes !== null) {
|
||||
await assertQuotaFits(data.quota_bytes);
|
||||
}
|
||||
@@ -488,7 +489,7 @@ export const registerAdminRoutes = (app: App, db: Db, config: Config): void => {
|
||||
requireAdmin(context);
|
||||
const id = Number(context.req.param("id"));
|
||||
if (!Number.isInteger(id) || id <= 0) throw AppError.notFound("Emplacement introuvable.");
|
||||
const data = parse(updateLocationSchema, await context.req.json().catch(() => null));
|
||||
const data = parse(updateLocationSchema, await readJson(context));
|
||||
|
||||
const row = await db.one<{ used_bytes: number }>(
|
||||
"SELECT used_bytes FROM storage_locations WHERE id = ? AND deleted_at IS NULL",
|
||||
|
||||
@@ -10,10 +10,11 @@ import {
|
||||
hashPassword,
|
||||
isHttpsRequest,
|
||||
rateLimitKey,
|
||||
readJson,
|
||||
requireAuth,
|
||||
revokeSession,
|
||||
sessionTokenHash,
|
||||
setSessionCookie,
|
||||
sha256,
|
||||
verifyPassword,
|
||||
type App,
|
||||
type Config,
|
||||
@@ -87,7 +88,7 @@ export const registerAuthRoutes = (app: App, db: Db, config: Config): void => {
|
||||
context.header("cache-control", "no-store");
|
||||
});
|
||||
|
||||
app.use("/api/cloud/*", attachUser(db));
|
||||
app.use("/api/cloud/*", attachUser(db, config.SESSION_SECRET));
|
||||
const limiter = createRateLimiter(config.RATE_LIMIT_LOGIN_MAX, config.RATE_LIMIT_LOGIN_WINDOW_MS);
|
||||
|
||||
app.post("/api/cloud/auth/login", async (context) => {
|
||||
@@ -98,7 +99,7 @@ export const registerAuthRoutes = (app: App, db: Db, config: Config): void => {
|
||||
throw AppError.unprocessable("Trop de tentatives de connexion. Reessayez dans une minute.");
|
||||
}
|
||||
|
||||
const parsed = credentials.safeParse(await context.req.json().catch(() => null));
|
||||
const parsed = credentials.safeParse(await readJson(context));
|
||||
if (!parsed.success) throw AppError.badRequest("Identifiants invalides.");
|
||||
|
||||
const { email, password } = parsed.data;
|
||||
@@ -120,6 +121,7 @@ export const registerAuthRoutes = (app: App, db: Db, config: Config): void => {
|
||||
userAgent: context.req.header("user-agent"),
|
||||
},
|
||||
config.SESSION_TTL_HOURS,
|
||||
config.SESSION_SECRET,
|
||||
);
|
||||
|
||||
await db.exec("UPDATE users SET last_login_at = UTC_TIMESTAMP() WHERE id = ?", [row.id]);
|
||||
@@ -135,7 +137,7 @@ export const registerAuthRoutes = (app: App, db: Db, config: Config): void => {
|
||||
|
||||
app.post("/api/cloud/auth/logout", requireAuth, async (context) => {
|
||||
const token = context.get("token");
|
||||
if (token) await revokeSession(db, token);
|
||||
if (token) await revokeSession(db, token, config.SESSION_SECRET);
|
||||
clearSessionCookie(context);
|
||||
return context.json({ ok: true });
|
||||
});
|
||||
@@ -159,7 +161,7 @@ export const registerAuthRoutes = (app: App, db: Db, config: Config): void => {
|
||||
*/
|
||||
app.post("/api/cloud/auth/change-password", requireAuth, async (context) => {
|
||||
const session = currentUser(context);
|
||||
const parsed = changePassword.safeParse(await context.req.json().catch(() => null));
|
||||
const parsed = changePassword.safeParse(await readJson(context));
|
||||
if (!parsed.success) {
|
||||
throw AppError.badRequest("Le nouveau mot de passe doit contenir au moins 8 caracteres.");
|
||||
}
|
||||
@@ -189,7 +191,7 @@ export const registerAuthRoutes = (app: App, db: Db, config: Config): void => {
|
||||
`UPDATE user_sessions
|
||||
SET revoked_at = UTC_TIMESTAMP()
|
||||
WHERE user_id = ? AND revoked_at IS NULL AND token_hash <> ?`,
|
||||
[session.id, sha256(context.get("token") ?? "")],
|
||||
[session.id, sessionTokenHash(context.get("token") ?? "", config.SESSION_SECRET)],
|
||||
);
|
||||
|
||||
return context.json({ ok: true });
|
||||
|
||||
@@ -3,6 +3,7 @@ import {
|
||||
AppError,
|
||||
createRateLimiter,
|
||||
currentUser,
|
||||
readJson,
|
||||
requireAuth,
|
||||
type App,
|
||||
type Config,
|
||||
@@ -258,7 +259,7 @@ export const registerChatRoutes = (app: App, db: Db, config: Config): void => {
|
||||
if (!limiter.allow(user.id)) {
|
||||
throw AppError.unprocessable("Vous envoyez des messages trop rapidement.");
|
||||
}
|
||||
const parsed = sendInput.safeParse(await context.req.json().catch(() => null));
|
||||
const parsed = sendInput.safeParse(await readJson(context));
|
||||
if (!parsed.success) {
|
||||
throw AppError.badRequest(parsed.error.issues[0]?.message ?? "Message invalide.");
|
||||
}
|
||||
@@ -292,7 +293,7 @@ export const registerChatRoutes = (app: App, db: Db, config: Config): void => {
|
||||
throw AppError.unprocessable("Vous envoyez des messages trop rapidement.");
|
||||
}
|
||||
|
||||
const parsed = editInput.safeParse(await context.req.json().catch(() => null));
|
||||
const parsed = editInput.safeParse(await readJson(context));
|
||||
if (!parsed.success) {
|
||||
throw AppError.badRequest(parsed.error.issues[0]?.message ?? "Message invalide.");
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import {
|
||||
currentUser,
|
||||
requireAuth,
|
||||
type App,
|
||||
type Config,
|
||||
type Db,
|
||||
} from "../lib/index.js";
|
||||
|
||||
@@ -11,8 +12,8 @@ import {
|
||||
* destinataire lors d'un partage. La session courante est exclue : on ne se
|
||||
* partage pas un dossier a soi-meme. Aucune donnee sensible n'est exposee.
|
||||
*/
|
||||
export const registerDirectoryRoutes = (app: App, db: Db): void => {
|
||||
app.use("/api/cloud/directory", attachUser(db));
|
||||
export const registerDirectoryRoutes = (app: App, db: Db, config: Config): void => {
|
||||
app.use("/api/cloud/directory", attachUser(db, config.SESSION_SECRET));
|
||||
|
||||
app.get("/api/cloud/directory", requireAuth, async (context) => {
|
||||
const user = currentUser(context);
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
currentUser,
|
||||
requireAuth,
|
||||
requireRole,
|
||||
readJson,
|
||||
type App,
|
||||
type Config,
|
||||
type Db,
|
||||
@@ -206,8 +207,8 @@ const serveFile = ({ absolute, size, mime, disposition, range }: ServeOptions):
|
||||
};
|
||||
|
||||
export const registerFileRoutes = (app: App, db: Db, config: Config): void => {
|
||||
app.use("/api/cloud/files/*", attachUser(db));
|
||||
app.use("/api/cloud/files", attachUser(db));
|
||||
app.use("/api/cloud/files/*", attachUser(db, config.SESSION_SECRET));
|
||||
app.use("/api/cloud/files", attachUser(db, config.SESSION_SECRET));
|
||||
|
||||
/**
|
||||
* Depot en un seul passage. Le corps n'est pas un formulaire multipart mais
|
||||
@@ -589,7 +590,7 @@ export const registerFileRoutes = (app: App, db: Db, config: Config): void => {
|
||||
(row.folder_id !== null && (await canWriteExplicit(db, user, row.folder_id)));
|
||||
if (!permitted) throw AppError.notFound("Fichier introuvable.");
|
||||
|
||||
const { name: rawName } = parse(renameInput, await context.req.json().catch(() => null));
|
||||
const { name: rawName } = parse(renameInput, await readJson(context));
|
||||
const name = assertName(rawName);
|
||||
|
||||
try {
|
||||
@@ -624,7 +625,7 @@ export const registerFileRoutes = (app: App, db: Db, config: Config): void => {
|
||||
(row.folder_id !== null && (await canWriteExplicit(db, user, row.folder_id)));
|
||||
if (!canLeave) throw AppError.notFound("Fichier introuvable.");
|
||||
|
||||
const { folderId } = parse(moveInput, await context.req.json().catch(() => null));
|
||||
const { folderId } = parse(moveInput, await readJson(context));
|
||||
const destination = folderId ?? null;
|
||||
|
||||
if (destination !== null && !(await canWrite(db, user, destination))) {
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
currentUser,
|
||||
requireAuth,
|
||||
requireRole,
|
||||
readJson,
|
||||
type App,
|
||||
type Config,
|
||||
type Db,
|
||||
@@ -102,8 +103,8 @@ const subtreeIds = async (db: Db, rootId: string): Promise<string[]> => {
|
||||
};
|
||||
|
||||
export const registerFolderRoutes = (app: App, db: Db, config: Config): void => {
|
||||
app.use("/api/cloud/folders/*", attachUser(db));
|
||||
app.use("/api/cloud/folders", attachUser(db));
|
||||
app.use("/api/cloud/folders/*", attachUser(db, config.SESSION_SECRET));
|
||||
app.use("/api/cloud/folders", attachUser(db, config.SESSION_SECRET));
|
||||
|
||||
app.get("/api/cloud/folders", requireAuth, async (context) => {
|
||||
const user = currentUser(context);
|
||||
@@ -149,7 +150,7 @@ export const registerFolderRoutes = (app: App, db: Db, config: Config): void =>
|
||||
const user = currentUser(context);
|
||||
const { name: rawName, parentId } = parse(
|
||||
createFolder,
|
||||
await context.req.json().catch(() => null),
|
||||
await readJson(context),
|
||||
);
|
||||
const name = assertName(rawName);
|
||||
|
||||
@@ -222,7 +223,7 @@ export const registerFolderRoutes = (app: App, db: Db, config: Config): void =>
|
||||
if (!existing) throw AppError.notFound("Dossier introuvable.");
|
||||
if (!(await canManageFolder(db, user, id))) throw AppError.notFound("Dossier introuvable.");
|
||||
|
||||
const data = parse(updateFolder, await context.req.json().catch(() => null));
|
||||
const data = parse(updateFolder, await readJson(context));
|
||||
const name = assertName(data.name);
|
||||
|
||||
try {
|
||||
@@ -249,7 +250,7 @@ export const registerFolderRoutes = (app: App, db: Db, config: Config): void =>
|
||||
if (existing.is_system === 1) throw AppError.forbidden("Le dossier public ne peut pas etre deplace.");
|
||||
if (!(await canManageFolder(db, user, id))) throw AppError.notFound("Dossier introuvable.");
|
||||
|
||||
const { parentId } = parse(moveFolder, await context.req.json().catch(() => null));
|
||||
const { parentId } = parse(moveFolder, await readJson(context));
|
||||
|
||||
if (parentId !== null && parentId !== undefined) {
|
||||
if (!(await canWrite(db, user, parentId))) {
|
||||
@@ -350,7 +351,7 @@ export const registerFolderRoutes = (app: App, db: Db, config: Config): void =>
|
||||
|
||||
const { email, level, expiresAt } = parse(
|
||||
permissionInput,
|
||||
await context.req.json().catch(() => null),
|
||||
await readJson(context),
|
||||
);
|
||||
|
||||
const target = await db.one<{ id: string }>(
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
currentUser,
|
||||
requireAuth,
|
||||
type App,
|
||||
type Config,
|
||||
type Db,
|
||||
} from "../lib/index.js";
|
||||
|
||||
@@ -15,8 +16,8 @@ import {
|
||||
|
||||
const KINDS = ["image", "video", "audio", "document", "archive", "other"] as const;
|
||||
|
||||
export const registerMediaRoutes = (app: App, db: Db): void => {
|
||||
app.use("/api/cloud/media", attachUser(db));
|
||||
export const registerMediaRoutes = (app: App, db: Db, config: Config): void => {
|
||||
app.use("/api/cloud/media", attachUser(db, config.SESSION_SECRET));
|
||||
|
||||
app.get("/api/cloud/media", requireAuth, async (context) => {
|
||||
const user = currentUser(context);
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
currentUser,
|
||||
requireAuth,
|
||||
type App,
|
||||
type Config,
|
||||
type Db,
|
||||
} from "../lib/index.js";
|
||||
|
||||
@@ -19,8 +20,8 @@ const escapeLike = (value: string): string =>
|
||||
|
||||
const LIMIT = 100;
|
||||
|
||||
export const registerSearchRoutes = (app: App, db: Db): void => {
|
||||
app.use("/api/cloud/search", attachUser(db));
|
||||
export const registerSearchRoutes = (app: App, db: Db, config: Config): void => {
|
||||
app.use("/api/cloud/search", attachUser(db, config.SESSION_SECRET));
|
||||
|
||||
app.get("/api/cloud/search", requireAuth, async (context) => {
|
||||
const user = currentUser(context);
|
||||
|
||||
@@ -158,8 +158,8 @@ const publicFolder = (row: TrashFolderRow) => ({
|
||||
});
|
||||
|
||||
export const registerTrashRoutes = (app: App, db: Db, config: Config): void => {
|
||||
app.use("/api/cloud/trash/*", attachUser(db));
|
||||
app.use("/api/cloud/trash", attachUser(db));
|
||||
app.use("/api/cloud/trash/*", attachUser(db, config.SESSION_SECRET));
|
||||
app.use("/api/cloud/trash", attachUser(db, config.SESSION_SECRET));
|
||||
|
||||
app.get("/api/cloud/trash", requireAuth, async (context) => {
|
||||
const user = currentUser(context);
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
currentUser,
|
||||
requireAuth,
|
||||
requireRole,
|
||||
readJson,
|
||||
type App,
|
||||
type Config,
|
||||
type Db,
|
||||
@@ -143,8 +144,8 @@ const assertNameFree = async (
|
||||
};
|
||||
|
||||
export const registerUploadRoutes = (app: App, db: Db, config: Config): void => {
|
||||
app.use("/api/cloud/uploads/*", attachUser(db));
|
||||
app.use("/api/cloud/uploads", attachUser(db));
|
||||
app.use("/api/cloud/uploads/*", attachUser(db, config.SESSION_SECRET));
|
||||
app.use("/api/cloud/uploads", attachUser(db, config.SESSION_SECRET));
|
||||
|
||||
app.post(
|
||||
"/api/cloud/uploads",
|
||||
@@ -152,7 +153,7 @@ export const registerUploadRoutes = (app: App, db: Db, config: Config): void =>
|
||||
requireRole("admin", "user"),
|
||||
async (context) => {
|
||||
const user = currentUser(context);
|
||||
const data = parse(createInput, await context.req.json().catch(() => null));
|
||||
const data = parse(createInput, await readJson(context));
|
||||
const name = assertName(data.name);
|
||||
const folderId = data.folderId ?? null;
|
||||
const size = data.size;
|
||||
|
||||
@@ -24,9 +24,6 @@ x-app: &app
|
||||
x-migrate-build: &migrate-build
|
||||
context: .
|
||||
dockerfile: docker/Dockerfile.api
|
||||
# Le build utilise le reseau de l'hote : le demon Docker resout parfois un
|
||||
# DNS mort (routeur), ce qui casse `npm ci` dans le conteneur.
|
||||
network: host
|
||||
args:
|
||||
APP_DIR: backend
|
||||
|
||||
@@ -37,7 +34,6 @@ services:
|
||||
context: .
|
||||
dockerfile: docker/Dockerfile.app
|
||||
target: export
|
||||
network: host
|
||||
args:
|
||||
APP_DIR: frontend
|
||||
volumes:
|
||||
@@ -117,7 +113,6 @@ services:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: docker/Dockerfile.api
|
||||
network: host
|
||||
args:
|
||||
APP_DIR: backend
|
||||
image: cohaise-cloud-api
|
||||
|
||||
@@ -63,6 +63,8 @@ server {
|
||||
}
|
||||
|
||||
location @spa {
|
||||
include /etc/nginx/snippets/security-headers.conf;
|
||||
include /etc/nginx/snippets/cache-no-cache.conf;
|
||||
try_files /index.html =404;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,8 +68,10 @@ Le design system vit dans `frontend/src/ui`.
|
||||
|
||||
- **`.env` ≠ `.env.example`** : comparer avant de conclure à un bug de port.
|
||||
- **README de paquet périmés** — utiliser ce dossier `docs/`.
|
||||
- **Build Docker et DNS** : les `build:` passent par `network: host` ; si `npm ci`
|
||||
échoue par `EAI_AGAIN`, le résolveur du démon est en cause.
|
||||
- **Build Docker et DNS** : les `build:` utilisent le réseau Docker par défaut.
|
||||
`network: host` est évité : Compose 5.6 / Buildx 0.38 refuse alors le build
|
||||
(`additional privileges requested`), sans transmettre `--allow=network.host`.
|
||||
Si `npm ci` échoue par `EAI_AGAIN`, corriger le DNS du démon Docker.
|
||||
- **Limitation de débit active** (applicatif + nginx) : un test en rafale peut
|
||||
recevoir `419`/`503` côté API ou `503` nginx — ce n'est pas un bug.
|
||||
- Après `make up`, vérifier l'ordre : `migrate` doit être `exited (0)` avant que
|
||||
|
||||
@@ -44,7 +44,8 @@ app-build (publish.sh, terminé avant nginx)
|
||||
|
||||
- `migrate` monte `./backend/migrations:/migrations:ro`.
|
||||
- `api` refuse de démarrer si une migration appliquée a été modifiée (dérive de
|
||||
checksum). `onReady` purge les sessions et la corbeille expirées.
|
||||
checksum). `onReady` purge les sessions, la corbeille et les envois inachevés,
|
||||
puis un balayage horaire reprend ces purges sans redémarrage.
|
||||
- stockage : `app_data` (volume Docker, HTML), `$CLOUD_DB_DIR` (MariaDB) et
|
||||
`$CLOUD_MEDIA_DIR` (fichiers) en bind mounts hôte.
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ pose problème (`backend/src/lib/config.ts`).
|
||||
| `CLOUD_DB_DIR` | dossier hôte des données MariaDB | `../db` |
|
||||
| `CLOUD_MEDIA_DIR` | dossier hôte des médias | `../media` |
|
||||
| `CLOUD_DB_CONNECTION_LIMIT` | taille du pool | `8` |
|
||||
| `SESSION_SECRET` | **obligatoire**, ≥ 32 car. | — |
|
||||
| `SESSION_SECRET` | **obligatoire**, ≥ 32 car., poivre HMAC des jetons de session | — |
|
||||
| `SESSION_TTL_HOURS` | durée de session | `336` |
|
||||
| `PUBLIC_ORIGIN` | **obligatoire**, URL absolue servant aux liens courriel | — |
|
||||
| `CLOUD_CORS_ORIGIN` | origines CORS (vide = CORS off) | vide |
|
||||
|
||||
@@ -7,10 +7,11 @@
|
||||
| Mesure | Détail |
|
||||
| --- | --- |
|
||||
| Mots de passe | `scrypt` natif `node:crypto` (`N=16384, r=8, p=1`, keylen 64, sel 16 o.), comparaison `timingSafeEqual` |
|
||||
| Stockage session | jeton aléatoire 32 o. côté client, **SHA-256** en base |
|
||||
| Stockage session | jeton aléatoire 32 o. côté client, **HMAC-SHA-256 poivré par `SESSION_SECRET`** en base |
|
||||
| Cookie | `cohaise_session`, `httpOnly`, `SameSite=Lax`, `path=/`, `secure` selon le schéma réel |
|
||||
| Expiration | `SESSION_TTL_HOURS` (336 h) ; `revoked_at`, `is_active`, `deleted_at` vérifiés à chaque résolution |
|
||||
| Révocation | logout, purge au démarrage, **toutes les autres sessions** au changement de mot de passe, gestion des sessions ouvertes depuis le compte |
|
||||
| Révocation | logout, purge au démarrage et **toutes les heures**, **toutes les autres sessions** au changement de mot de passe, gestion des sessions ouvertes depuis le compte |
|
||||
| Changement imposé | `must_change_password` vérifié dans `requireAuth` : seules `auth/me`, `auth/change-password` et `auth/logout` restent accessibles, la redirection du front n'est qu'un confort |
|
||||
| Anti-énumération | hash factice pour une adresse inconnue ; les flux « mot de passe oublié » répondent toujours `{ ok: true }` sans révéler l'existence du compte |
|
||||
| Jetons à usage unique | réinitialisation de mot de passe et changement d'adresse stockés **hachés**, avec expiration |
|
||||
| Changement d'adresse | mot de passe actuel exigé, confirmation **à la nouvelle adresse** avant application |
|
||||
@@ -24,6 +25,14 @@
|
||||
- **Edge nginx** : zones `limit_req` `login` (15 r/min, burst 5) et `api`
|
||||
(60 r/s, burst élevé) — voir `docker/nginx/cloud.conf`.
|
||||
|
||||
### Limites d'entrée
|
||||
|
||||
- Les corps JSON passent par `readJson` : **1 Mio** maximum, lecture bornée
|
||||
même si `content-length` ment (le flux est coupé au-delà).
|
||||
- L'avatar passe par `readBodyCapped` : **8 Mio** maximum, même garantie.
|
||||
- Les envois de fichiers ont leur propre flux borné (`storage.ts`), indépendant
|
||||
de `client_max_body_size` de nginx.
|
||||
|
||||
### Droits d'accès
|
||||
|
||||
Calculés **en base à chaque requête**, depuis la session — jamais depuis un
|
||||
@@ -84,6 +93,8 @@ aucun HTML utilisateur n'est injecté dans les messages.
|
||||
une **liste blanche** de types (`image/*` hors `image/svg+xml`, `video/*`,
|
||||
`audio/*`, `application/pdf`, `text/plain`) — jamais de HTML/SVG qui
|
||||
s'exécuterait dans l'origine. Les deux routes gèrent `Range` (206 / 416).
|
||||
- Vignettes : le SVG est aussi exclu du passage à `sharp`/librsvg ; il reste
|
||||
téléchargeable, mais n'est jamais décodé côté serveur.
|
||||
|
||||
## Hors périmètre (assumé)
|
||||
|
||||
|
||||
@@ -14,12 +14,14 @@
|
||||
"react": "^19.3.0",
|
||||
"react-dom": "^19.3.0",
|
||||
"react-router-dom": "^7.18.4",
|
||||
"tailwind-merge": "^3.7.0"
|
||||
"tailwind-merge": "^3.7.0",
|
||||
"three": "^0.187.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tailwindcss/vite": "^4.3.3",
|
||||
"@types/react": "^19.3.0",
|
||||
"@types/react-dom": "^19.3.0",
|
||||
"@types/three": "^0.187.0",
|
||||
"@vitejs/plugin-react": "^6.1.1",
|
||||
"tailwindcss": "^4.3.3",
|
||||
"typescript": "^7.0.2",
|
||||
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 625 B |
|
After Width: | Height: | Size: 929 B |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 803 B |
|
After Width: | Height: | Size: 915 B |
|
After Width: | Height: | Size: 775 B |
|
After Width: | Height: | Size: 952 B |
|
After Width: | Height: | Size: 684 B |
|
After Width: | Height: | Size: 634 B |
|
After Width: | Height: | Size: 907 B |
|
After Width: | Height: | Size: 648 B |
|
After Width: | Height: | Size: 869 B |
|
After Width: | Height: | Size: 783 B |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 824 B |
|
After Width: | Height: | Size: 919 B |
|
After Width: | Height: | Size: 994 B |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 932 B |
|
After Width: | Height: | Size: 831 B |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 795 B |
|
After Width: | Height: | Size: 909 B |
@@ -2,6 +2,7 @@ import { Navigate, Outlet, Route, Routes } from "react-router-dom";
|
||||
import { Spinner } from "./ui/index.js";
|
||||
import { useSession } from "./lib/session.js";
|
||||
import { AppShell } from "./components/AppShell.js";
|
||||
import { AuthLayout } from "./components/AuthLayout.js";
|
||||
import { Login } from "./pages/Login.js";
|
||||
import { ForgotPassword } from "./pages/ForgotPassword.js";
|
||||
import { ResetPassword } from "./pages/ResetPassword.js";
|
||||
@@ -42,13 +43,17 @@ const RequireAdmin = () => {
|
||||
|
||||
export const App = () => (
|
||||
<Routes>
|
||||
<Route path="/login" element={<Login />} />
|
||||
<Route path="/forgot-password" element={<ForgotPassword />} />
|
||||
<Route path="/reset-password" element={<ResetPassword />} />
|
||||
<Route path="/confirm-email" element={<ConfirmEmail />} />
|
||||
<Route element={<AuthLayout />}>
|
||||
<Route path="/login" element={<Login />} />
|
||||
<Route path="/forgot-password" element={<ForgotPassword />} />
|
||||
<Route path="/reset-password" element={<ResetPassword />} />
|
||||
<Route path="/confirm-email" element={<ConfirmEmail />} />
|
||||
</Route>
|
||||
|
||||
<Route element={<RequireAuth />}>
|
||||
<Route path="/change-password" element={<ChangePassword />} />
|
||||
<Route element={<AuthLayout />}>
|
||||
<Route path="/change-password" element={<ChangePassword />} />
|
||||
</Route>
|
||||
|
||||
<Route element={<RequireReady />}>
|
||||
<Route element={<AppShell />}>
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { useState } from "react";
|
||||
import { createContext, useContext, useEffect, useState, type ReactNode } from "react";
|
||||
import { NavLink, Outlet } from "react-router-dom";
|
||||
import { Button, cn } from "../ui/index.js";
|
||||
import { cn } from "../ui/index.js";
|
||||
import { useSession } from "../lib/session.js";
|
||||
import { useI18n } from "../lib/i18n.js";
|
||||
import { Avatar } from "./Avatar.js";
|
||||
import { ColorBendsBackdrop } from "./ColorBendsBackdrop.js";
|
||||
import {
|
||||
ActivityIcon,
|
||||
CloseIcon,
|
||||
@@ -18,6 +19,7 @@ import {
|
||||
StarIcon,
|
||||
TrashIcon,
|
||||
} from "./icons.js";
|
||||
import { IconAction } from "./IconAction.js";
|
||||
|
||||
interface NavItem {
|
||||
to: string;
|
||||
@@ -49,10 +51,27 @@ const navClass = ({ isActive }: { isActive: boolean }) =>
|
||||
: "text-muted-foreground hover:bg-surface-hover hover:text-foreground",
|
||||
);
|
||||
|
||||
type PageHeaderContextValue = {
|
||||
header: ReactNode | null;
|
||||
setHeader: (header: ReactNode | null) => void;
|
||||
};
|
||||
|
||||
const PageHeaderContext = createContext<PageHeaderContextValue | null>(null);
|
||||
|
||||
export const usePageHeader = (header: ReactNode | null) => {
|
||||
const ctx = useContext(PageHeaderContext);
|
||||
useEffect(() => {
|
||||
if (!ctx) return;
|
||||
ctx.setHeader(header);
|
||||
return () => ctx.setHeader(null);
|
||||
}, [ctx, header]);
|
||||
};
|
||||
|
||||
export const AppShell = () => {
|
||||
const { user, logout } = useSession();
|
||||
const { t } = useI18n();
|
||||
const [menuOpen, setMenuOpen] = useState(false);
|
||||
const [pageHeader, setPageHeader] = useState<ReactNode | null>(null);
|
||||
if (!user) return null;
|
||||
|
||||
const isAdmin = user.role_slug === "admin";
|
||||
@@ -88,24 +107,12 @@ export const AppShell = () => {
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex h-dvh overflow-hidden bg-background">
|
||||
<aside className="hidden w-60 shrink-0 flex-col gap-1 overflow-y-auto border-r border-border bg-surface p-3 lg:flex">
|
||||
<div className="px-1 py-2">{brand}</div>
|
||||
{NAV.map(renderLink)}
|
||||
{isAdmin ? (
|
||||
<>
|
||||
<p className="mt-3 px-3 py-1 font-display text-[0.6875rem] font-semibold uppercase tracking-label text-subtle-foreground">
|
||||
{t("Administration")}
|
||||
</p>
|
||||
{ADMIN_NAV.map(renderLink)}
|
||||
</>
|
||||
) : null}
|
||||
<div className="mt-auto pt-3">{renderLink(ACCOUNT_NAV)}</div>
|
||||
</aside>
|
||||
<PageHeaderContext.Provider value={{ header: pageHeader, setHeader: setPageHeader }}>
|
||||
<div className="relative grid h-dvh grid-cols-[auto_1fr] grid-rows-[auto_1fr] overflow-hidden bg-background">
|
||||
<ColorBendsBackdrop variant="shell" />
|
||||
|
||||
<div className="flex min-w-0 flex-1 flex-col">
|
||||
<header className="z-20 shrink-0 border-b border-border bg-surface">
|
||||
<div className="mx-auto flex w-full max-w-5xl items-center justify-between gap-4 px-4 py-3">
|
||||
<header className="relative z-50 col-span-2 row-start-1 border-b border-border/50 bg-surface/70 backdrop-blur-md">
|
||||
<div className="flex w-full items-center justify-between gap-4 px-4 py-3">
|
||||
<div className="flex items-center gap-3">
|
||||
<button
|
||||
type="button"
|
||||
@@ -116,7 +123,7 @@ export const AppShell = () => {
|
||||
>
|
||||
{menuOpen ? <CloseIcon className="h-5 w-5" /> : <MenuIcon className="h-5 w-5" />}
|
||||
</button>
|
||||
<span className="lg:hidden">{brand}</span>
|
||||
{brand}
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-3">
|
||||
@@ -135,30 +142,62 @@ export const AppShell = () => {
|
||||
hasAvatar={user.has_avatar}
|
||||
avatarUpdatedAt={user.avatar_updated_at}
|
||||
/>
|
||||
<Button
|
||||
variant="secondary"
|
||||
size="sm"
|
||||
iconLeading={<LogoutIcon className="h-3.5 w-3.5" />}
|
||||
<IconAction
|
||||
label={t("Déconnexion")}
|
||||
icon={<LogoutIcon className="h-4 w-4" />}
|
||||
onClick={() => void logout()}
|
||||
>
|
||||
<span className="hidden sm:inline">{t("Déconnexion")}</span>
|
||||
</Button>
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{menuOpen ? (
|
||||
<nav className="flex flex-col gap-1 border-t border-border px-3 py-2 lg:hidden">
|
||||
{allNav.map(renderLink)}
|
||||
</nav>
|
||||
) : null}
|
||||
</header>
|
||||
|
||||
<div className="min-h-0 flex-1 overflow-y-auto">
|
||||
<main className="mx-auto w-full max-w-5xl px-4 py-6">
|
||||
<Outlet />
|
||||
</main>
|
||||
<aside className="relative z-40 col-start-1 row-start-2 hidden w-60 flex-col gap-1 overflow-y-auto border-r border-border/50 bg-surface/70 p-3 backdrop-blur-md lg:flex">
|
||||
{NAV.map(renderLink)}
|
||||
{isAdmin ? (
|
||||
<>
|
||||
<p className="mt-3 px-3 py-1 font-display text-[0.6875rem] font-semibold uppercase tracking-label text-subtle-foreground">
|
||||
{t("Administration")}
|
||||
</p>
|
||||
{ADMIN_NAV.map(renderLink)}
|
||||
</>
|
||||
) : null}
|
||||
<div className="mt-auto pt-3">{renderLink(ACCOUNT_NAV)}</div>
|
||||
</aside>
|
||||
|
||||
{menuOpen ? (
|
||||
<div className="lg:hidden">
|
||||
<div className="fixed inset-0 z-40 bg-black/50 backdrop-blur-sm" onClick={() => setMenuOpen(false)} aria-hidden="true" />
|
||||
<nav className="fixed inset-0 z-50 flex flex-col bg-background/95 backdrop-blur-lg transition-transform duration-300 sm:absolute sm:inset-y-0 sm:left-0 sm:w-72 sm:inset-x-auto">
|
||||
<div className="flex items-center justify-between border-b border-border/50 px-4 py-3">
|
||||
{brand}
|
||||
<button
|
||||
type="button"
|
||||
className="text-muted-foreground"
|
||||
aria-label={t("Fermer le menu")}
|
||||
onClick={() => setMenuOpen(false)}
|
||||
>
|
||||
<CloseIcon className="h-5 w-5" />
|
||||
</button>
|
||||
</div>
|
||||
<div className="flex flex-1 flex-col gap-1 overflow-y-auto p-3">
|
||||
{allNav.map(renderLink)}
|
||||
</div>
|
||||
</nav>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
<div className="relative z-10 col-start-2 row-start-2 min-h-0 overflow-hidden">
|
||||
<div className="h-full w-full bg-surface/30 backdrop-blur-lg">
|
||||
<div className="flex h-full flex-col">
|
||||
{pageHeader ? <div className="relative z-30 shrink-0">{pageHeader}</div> : null}
|
||||
<main className="min-h-0 flex-1 overflow-y-auto overflow-x-hidden px-4 pb-6 pt-4 [scrollbar-gutter:stable]">
|
||||
<Outlet />
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</PageHeaderContext.Provider>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
import { Outlet } from "react-router-dom";
|
||||
import { ColorBendsBackdrop } from "./ColorBendsBackdrop.js";
|
||||
|
||||
/**
|
||||
* Coque des ecrans d'authentification : fond carmin animé, puis une colonne
|
||||
* centree qui contient la page courante. Le degrade garantit la lisibilite des
|
||||
* cartes et des champs par-dessus le shader, dans les deux themes.
|
||||
*/
|
||||
export const AuthLayout = () => (
|
||||
<main className="relative flex min-h-dvh items-center justify-center overflow-hidden bg-background px-4 py-10">
|
||||
<ColorBendsBackdrop variant="auth" />
|
||||
<div
|
||||
aria-hidden="true"
|
||||
className="pointer-events-none absolute inset-0 bg-gradient-to-b from-background/10 via-background/40 to-background/80 dark:from-background/25 dark:via-background/50 dark:to-background/85"
|
||||
/>
|
||||
<div className="relative z-10 flex w-full justify-center">
|
||||
<Outlet />
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
@@ -0,0 +1,12 @@
|
||||
.color-bends-container {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.color-bends-container canvas {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
@@ -0,0 +1,438 @@
|
||||
import { useEffect, useRef, type CSSProperties } from "react";
|
||||
import {
|
||||
Clock,
|
||||
Mesh,
|
||||
OrthographicCamera,
|
||||
PlaneGeometry,
|
||||
Scene,
|
||||
ShaderMaterial,
|
||||
SRGBColorSpace,
|
||||
Vector2,
|
||||
Vector3,
|
||||
WebGLRenderer,
|
||||
type IUniform,
|
||||
} from "three";
|
||||
import "./ColorBends.css";
|
||||
|
||||
/**
|
||||
* Fond anime "ColorBends" (React Bits), porte en TypeScript pour le projet.
|
||||
*
|
||||
* Le rendu est un shader plein ecran : aucune image, aucun appel reseau. Le
|
||||
* composant respecte `prefers-reduced-motion` en figeant le shader apres une
|
||||
* premiere image, et libere le contexte WebGL au demontage.
|
||||
*/
|
||||
|
||||
const MAX_COLORS = 8;
|
||||
|
||||
const frag = `
|
||||
#define MAX_COLORS ${MAX_COLORS}
|
||||
uniform vec2 uCanvas;
|
||||
uniform float uTime;
|
||||
uniform float uSpeed;
|
||||
uniform vec2 uRot;
|
||||
uniform int uColorCount;
|
||||
uniform vec3 uColors[MAX_COLORS];
|
||||
uniform int uTransparent;
|
||||
uniform float uScale;
|
||||
uniform float uFrequency;
|
||||
uniform float uWarpStrength;
|
||||
uniform vec2 uPointer;
|
||||
uniform float uMouseInfluence;
|
||||
uniform float uParallax;
|
||||
uniform float uNoise;
|
||||
uniform int uIterations;
|
||||
uniform float uIntensity;
|
||||
uniform float uBandWidth;
|
||||
varying vec2 vUv;
|
||||
|
||||
void main() {
|
||||
float t = uTime * uSpeed;
|
||||
vec2 p = vUv * 2.0 - 1.0;
|
||||
p += uPointer * uParallax * 0.1;
|
||||
vec2 rp = vec2(p.x * uRot.x - p.y * uRot.y, p.x * uRot.y + p.y * uRot.x);
|
||||
vec2 q = vec2(rp.x * (uCanvas.x / uCanvas.y), rp.y);
|
||||
q /= max(uScale, 0.0001);
|
||||
q /= 0.5 + 0.2 * dot(q, q);
|
||||
q += 0.2 * cos(t) - 7.56;
|
||||
vec2 toward = (uPointer - rp);
|
||||
q += toward * uMouseInfluence * 0.2;
|
||||
|
||||
for (int j = 0; j < 5; j++) {
|
||||
if (j >= uIterations - 1) break;
|
||||
vec2 rr = sin(1.5 * (q.yx * uFrequency) + 2.0 * cos(q * uFrequency));
|
||||
q += (rr - q) * 0.15;
|
||||
}
|
||||
|
||||
vec3 col = vec3(0.0);
|
||||
float a = 1.0;
|
||||
|
||||
if (uColorCount > 0) {
|
||||
vec2 s = q;
|
||||
vec3 sumCol = vec3(0.0);
|
||||
float cover = 0.0;
|
||||
for (int i = 0; i < MAX_COLORS; ++i) {
|
||||
if (i >= uColorCount) break;
|
||||
s -= 0.01;
|
||||
vec2 r = sin(1.5 * (s.yx * uFrequency) + 2.0 * cos(s * uFrequency));
|
||||
float m0 = length(r + sin(5.0 * r.y * uFrequency - 3.0 * t + float(i)) / 4.0);
|
||||
float kBelow = clamp(uWarpStrength, 0.0, 1.0);
|
||||
float kMix = pow(kBelow, 0.3);
|
||||
float gain = 1.0 + max(uWarpStrength - 1.0, 0.0);
|
||||
vec2 disp = (r - s) * kBelow;
|
||||
vec2 warped = s + disp * gain;
|
||||
float m1 = length(warped + sin(5.0 * warped.y * uFrequency - 3.0 * t + float(i)) / 4.0);
|
||||
float m = mix(m0, m1, kMix);
|
||||
float w = 1.0 - exp(-uBandWidth / exp(uBandWidth * m));
|
||||
sumCol += uColors[i] * w;
|
||||
cover = max(cover, w);
|
||||
}
|
||||
col = clamp(sumCol, 0.0, 1.0);
|
||||
a = uTransparent > 0 ? cover : 1.0;
|
||||
} else {
|
||||
vec2 s = q;
|
||||
for (int k = 0; k < 3; ++k) {
|
||||
s -= 0.01;
|
||||
vec2 r = sin(1.5 * (s.yx * uFrequency) + 2.0 * cos(s * uFrequency));
|
||||
float m0 = length(r + sin(5.0 * r.y * uFrequency - 3.0 * t + float(k)) / 4.0);
|
||||
float kBelow = clamp(uWarpStrength, 0.0, 1.0);
|
||||
float kMix = pow(kBelow, 0.3);
|
||||
float gain = 1.0 + max(uWarpStrength - 1.0, 0.0);
|
||||
vec2 disp = (r - s) * kBelow;
|
||||
vec2 warped = s + disp * gain;
|
||||
float m1 = length(warped + sin(5.0 * warped.y * uFrequency - 3.0 * t + float(k)) / 4.0);
|
||||
float m = mix(m0, m1, kMix);
|
||||
col[k] = 1.0 - exp(-uBandWidth / exp(uBandWidth * m));
|
||||
}
|
||||
a = uTransparent > 0 ? max(max(col.r, col.g), col.b) : 1.0;
|
||||
}
|
||||
|
||||
col *= uIntensity;
|
||||
|
||||
if (uNoise > 0.0001) {
|
||||
float n = fract(sin(dot(gl_FragCoord.xy + vec2(uTime), vec2(12.9898, 78.233))) * 43758.5453123);
|
||||
col += (n - 0.5) * uNoise;
|
||||
col = clamp(col, 0.0, 1.0);
|
||||
}
|
||||
|
||||
vec3 rgb = (uTransparent > 0) ? col * a : col;
|
||||
gl_FragColor = vec4(rgb, a);
|
||||
}
|
||||
`;
|
||||
|
||||
const vert = `
|
||||
varying vec2 vUv;
|
||||
void main() {
|
||||
vUv = uv;
|
||||
gl_Position = vec4(position, 1.0);
|
||||
}
|
||||
`;
|
||||
|
||||
export interface ColorBendsProps {
|
||||
className?: string;
|
||||
style?: CSSProperties;
|
||||
rotation?: number;
|
||||
speed?: number;
|
||||
colors?: string[];
|
||||
transparent?: boolean;
|
||||
autoRotate?: number;
|
||||
scale?: number;
|
||||
frequency?: number;
|
||||
warpStrength?: number;
|
||||
mouseInfluence?: number;
|
||||
parallax?: number;
|
||||
noise?: number;
|
||||
iterations?: number;
|
||||
intensity?: number;
|
||||
bandWidth?: number;
|
||||
}
|
||||
|
||||
interface ColorBendsUniforms {
|
||||
uCanvas: IUniform<Vector2>;
|
||||
uTime: IUniform<number>;
|
||||
uSpeed: IUniform<number>;
|
||||
uRot: IUniform<Vector2>;
|
||||
uColorCount: IUniform<number>;
|
||||
uColors: IUniform<Vector3[]>;
|
||||
uTransparent: IUniform<number>;
|
||||
uScale: IUniform<number>;
|
||||
uFrequency: IUniform<number>;
|
||||
uWarpStrength: IUniform<number>;
|
||||
uPointer: IUniform<Vector2>;
|
||||
uMouseInfluence: IUniform<number>;
|
||||
uParallax: IUniform<number>;
|
||||
uNoise: IUniform<number>;
|
||||
uIterations: IUniform<number>;
|
||||
uIntensity: IUniform<number>;
|
||||
uBandWidth: IUniform<number>;
|
||||
}
|
||||
|
||||
const toVec3 = (hex: string): Vector3 => {
|
||||
const value = hex.replace("#", "").trim();
|
||||
const channels =
|
||||
value.length === 3
|
||||
? [
|
||||
parseInt(value.slice(0, 1).repeat(2), 16),
|
||||
parseInt(value.slice(1, 2).repeat(2), 16),
|
||||
parseInt(value.slice(2, 3).repeat(2), 16),
|
||||
]
|
||||
: [
|
||||
parseInt(value.slice(0, 2), 16),
|
||||
parseInt(value.slice(2, 4), 16),
|
||||
parseInt(value.slice(4, 6), 16),
|
||||
];
|
||||
return new Vector3(channels[0]! / 255, channels[1]! / 255, channels[2]! / 255);
|
||||
};
|
||||
|
||||
export default function ColorBends({
|
||||
className,
|
||||
style,
|
||||
rotation = 90,
|
||||
speed = 0.2,
|
||||
colors = [],
|
||||
transparent = true,
|
||||
autoRotate = 0,
|
||||
scale = 1,
|
||||
frequency = 1,
|
||||
warpStrength = 1,
|
||||
mouseInfluence = 1,
|
||||
parallax = 0.5,
|
||||
noise = 0.15,
|
||||
iterations = 1,
|
||||
intensity = 1.5,
|
||||
bandWidth = 6,
|
||||
}: ColorBendsProps) {
|
||||
const containerRef = useRef<HTMLDivElement>(null);
|
||||
const rendererRef = useRef<WebGLRenderer | null>(null);
|
||||
const rafRef = useRef<number | null>(null);
|
||||
const renderOnceRef = useRef<(() => void) | null>(null);
|
||||
const materialRef = useRef<ShaderMaterial | null>(null);
|
||||
const resizeObserverRef = useRef<ResizeObserver | null>(null);
|
||||
const rotationRef = useRef(rotation);
|
||||
const autoRotateRef = useRef(autoRotate);
|
||||
const pointerTargetRef = useRef(new Vector2(0, 0));
|
||||
const pointerCurrentRef = useRef(new Vector2(0, 0));
|
||||
const pointerSmoothRef = useRef(8);
|
||||
|
||||
useEffect(() => {
|
||||
const container = containerRef.current;
|
||||
if (!container) return;
|
||||
|
||||
let renderer: WebGLRenderer;
|
||||
try {
|
||||
renderer = new WebGLRenderer({
|
||||
antialias: false,
|
||||
powerPreference: "high-performance",
|
||||
alpha: true,
|
||||
});
|
||||
} catch {
|
||||
// Pas de WebGL (navigateur ancien, materiel bloque) : le fond reste
|
||||
// simplement absent, l'ecran et le formulaire continuent de fonctionner.
|
||||
return;
|
||||
}
|
||||
|
||||
const scene = new Scene();
|
||||
const camera = new OrthographicCamera(-1, 1, 1, -1, 0, 1);
|
||||
const geometry = new PlaneGeometry(2, 2);
|
||||
const uColors = Array.from({ length: MAX_COLORS }, () => new Vector3(0, 0, 0));
|
||||
const material = new ShaderMaterial({
|
||||
vertexShader: vert,
|
||||
fragmentShader: frag,
|
||||
uniforms: {
|
||||
uCanvas: { value: new Vector2(1, 1) },
|
||||
uTime: { value: 0 },
|
||||
uSpeed: { value: speed },
|
||||
uRot: { value: new Vector2(1, 0) },
|
||||
uColorCount: { value: 0 },
|
||||
uColors: { value: uColors },
|
||||
uTransparent: { value: transparent ? 1 : 0 },
|
||||
uScale: { value: scale },
|
||||
uFrequency: { value: frequency },
|
||||
uWarpStrength: { value: warpStrength },
|
||||
uPointer: { value: new Vector2(0, 0) },
|
||||
uMouseInfluence: { value: mouseInfluence },
|
||||
uParallax: { value: parallax },
|
||||
uNoise: { value: noise },
|
||||
uIterations: { value: iterations },
|
||||
uIntensity: { value: intensity },
|
||||
uBandWidth: { value: bandWidth },
|
||||
} satisfies ColorBendsUniforms,
|
||||
premultipliedAlpha: true,
|
||||
transparent: true,
|
||||
});
|
||||
materialRef.current = material;
|
||||
|
||||
const mesh = new Mesh(geometry, material);
|
||||
scene.add(mesh);
|
||||
|
||||
rendererRef.current = renderer;
|
||||
renderer.outputColorSpace = SRGBColorSpace;
|
||||
renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2));
|
||||
renderer.setClearColor(0x000000, transparent ? 0 : 1);
|
||||
renderer.domElement.style.width = "100%";
|
||||
renderer.domElement.style.height = "100%";
|
||||
renderer.domElement.style.display = "block";
|
||||
container.appendChild(renderer.domElement);
|
||||
|
||||
const clock = new Clock();
|
||||
const motion = window.matchMedia("(prefers-reduced-motion: reduce)");
|
||||
let reducedMotion = motion.matches;
|
||||
|
||||
const handleResize = () => {
|
||||
const width = container.clientWidth || 1;
|
||||
const height = container.clientHeight || 1;
|
||||
renderer.setSize(width, height, false);
|
||||
material.uniforms.uCanvas!.value.set(width, height);
|
||||
if (reducedMotion) renderer.render(scene, camera);
|
||||
};
|
||||
|
||||
const renderFrame = () => {
|
||||
const delta = clock.getDelta();
|
||||
const elapsed = clock.elapsedTime;
|
||||
material.uniforms.uTime!.value = elapsed;
|
||||
|
||||
const degrees = (rotationRef.current % 360) + autoRotateRef.current * elapsed;
|
||||
const radians = (degrees * Math.PI) / 180;
|
||||
material.uniforms.uRot!.value.set(Math.cos(radians), Math.sin(radians));
|
||||
|
||||
const current = pointerCurrentRef.current;
|
||||
current.lerp(pointerTargetRef.current, Math.min(1, delta * pointerSmoothRef.current));
|
||||
material.uniforms.uPointer!.value.copy(current);
|
||||
renderer.render(scene, camera);
|
||||
};
|
||||
renderOnceRef.current = renderFrame;
|
||||
|
||||
const stop = () => {
|
||||
if (rafRef.current !== null) {
|
||||
cancelAnimationFrame(rafRef.current);
|
||||
rafRef.current = null;
|
||||
}
|
||||
};
|
||||
|
||||
const loop = () => {
|
||||
renderFrame();
|
||||
rafRef.current = requestAnimationFrame(loop);
|
||||
};
|
||||
|
||||
const start = () => {
|
||||
if (!reducedMotion && rafRef.current === null) {
|
||||
clock.start();
|
||||
rafRef.current = requestAnimationFrame(loop);
|
||||
}
|
||||
};
|
||||
|
||||
handleResize();
|
||||
|
||||
if (typeof ResizeObserver !== "undefined") {
|
||||
const observer = new ResizeObserver(handleResize);
|
||||
observer.observe(container);
|
||||
resizeObserverRef.current = observer;
|
||||
} else {
|
||||
window.addEventListener("resize", handleResize);
|
||||
}
|
||||
|
||||
const handleMotionChange = () => {
|
||||
reducedMotion = motion.matches;
|
||||
if (reducedMotion) {
|
||||
stop();
|
||||
renderFrame();
|
||||
} else {
|
||||
start();
|
||||
}
|
||||
};
|
||||
motion.addEventListener("change", handleMotionChange);
|
||||
|
||||
if (reducedMotion) renderFrame();
|
||||
else start();
|
||||
|
||||
return () => {
|
||||
stop();
|
||||
motion.removeEventListener("change", handleMotionChange);
|
||||
if (resizeObserverRef.current) resizeObserverRef.current.disconnect();
|
||||
else window.removeEventListener("resize", handleResize);
|
||||
geometry.dispose();
|
||||
material.dispose();
|
||||
renderer.dispose();
|
||||
renderer.forceContextLoss();
|
||||
if (renderer.domElement.parentElement === container) {
|
||||
container.removeChild(renderer.domElement);
|
||||
}
|
||||
materialRef.current = null;
|
||||
rendererRef.current = null;
|
||||
renderOnceRef.current = null;
|
||||
resizeObserverRef.current = null;
|
||||
};
|
||||
// Les uniformes sont mis a jour par l'effet suivant ; ce premier montage ne
|
||||
// depend donc que du conteneur et ne recree jamais le contexte WebGL.
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const material = materialRef.current;
|
||||
if (!material) return;
|
||||
|
||||
rotationRef.current = rotation;
|
||||
autoRotateRef.current = autoRotate;
|
||||
material.uniforms.uSpeed!.value = speed;
|
||||
material.uniforms.uScale!.value = scale;
|
||||
material.uniforms.uFrequency!.value = frequency;
|
||||
material.uniforms.uWarpStrength!.value = warpStrength;
|
||||
material.uniforms.uMouseInfluence!.value = mouseInfluence;
|
||||
material.uniforms.uParallax!.value = parallax;
|
||||
material.uniforms.uNoise!.value = noise;
|
||||
material.uniforms.uIterations!.value = iterations;
|
||||
material.uniforms.uIntensity!.value = intensity;
|
||||
material.uniforms.uBandWidth!.value = bandWidth;
|
||||
|
||||
const parsed = colors.filter(Boolean).slice(0, MAX_COLORS).map(toVec3);
|
||||
const target = material.uniforms.uColors!.value as Vector3[];
|
||||
for (let index = 0; index < MAX_COLORS; index += 1) {
|
||||
const vector = target[index]!;
|
||||
if (index < parsed.length) vector.copy(parsed[index]!);
|
||||
else vector.set(0, 0, 0);
|
||||
}
|
||||
material.uniforms.uColorCount!.value = parsed.length;
|
||||
|
||||
material.uniforms.uTransparent!.value = transparent ? 1 : 0;
|
||||
if (rendererRef.current) rendererRef.current.setClearColor(0x000000, transparent ? 0 : 1);
|
||||
|
||||
// Sans boucle (prefers-reduced-motion), les uniformes viennent de changer :
|
||||
// il faut une image de plus pour que la palette soit réellement appliquée.
|
||||
if (rafRef.current === null) renderOnceRef.current?.();
|
||||
}, [
|
||||
rotation,
|
||||
autoRotate,
|
||||
speed,
|
||||
scale,
|
||||
frequency,
|
||||
warpStrength,
|
||||
mouseInfluence,
|
||||
parallax,
|
||||
noise,
|
||||
iterations,
|
||||
intensity,
|
||||
bandWidth,
|
||||
colors,
|
||||
transparent,
|
||||
]);
|
||||
|
||||
useEffect(() => {
|
||||
const container = containerRef.current;
|
||||
if (!container) return;
|
||||
|
||||
const handlePointerMove = (event: PointerEvent) => {
|
||||
const rect = container.getBoundingClientRect();
|
||||
const x = ((event.clientX - rect.left) / (rect.width || 1)) * 2 - 1;
|
||||
const y = -(((event.clientY - rect.top) / (rect.height || 1)) * 2 - 1);
|
||||
pointerTargetRef.current.set(x, y);
|
||||
};
|
||||
|
||||
// Ecoute au niveau de la fenetre : le fond peut etre recouvert par la
|
||||
// coque ou par une carte, et doit reagir quand meme au mouvement.
|
||||
window.addEventListener("pointermove", handlePointerMove, { passive: true });
|
||||
return () => {
|
||||
window.removeEventListener("pointermove", handlePointerMove);
|
||||
};
|
||||
}, []);
|
||||
|
||||
return <div ref={containerRef} className={`color-bends-container ${className ?? ""}`} style={style} />;
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
import { lazy, Suspense } from "react";
|
||||
import { COHAISE_BENDS } from "./colorBendsPalette.js";
|
||||
import type { ColorBendsProps } from "./ColorBends.js";
|
||||
|
||||
const ColorBends = lazy(() => import("./ColorBends.js"));
|
||||
|
||||
type BackdropVariant = "auth" | "shell" | "chat";
|
||||
|
||||
type BackdropPreset = Omit<ColorBendsProps, "colors" | "transparent" | "className"> & {
|
||||
className: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Fond carmin partage par les ecrans d'authentification, la coque connectee
|
||||
* et le salon de discussion. Le composant WebGL reste charge a la demande :
|
||||
* seuls les presets sont dans le bundle initial.
|
||||
*/
|
||||
const PRESETS: Record<BackdropVariant, BackdropPreset> = {
|
||||
auth: {
|
||||
className: "opacity-[0.55] dark:opacity-[0.7]",
|
||||
rotation: 90,
|
||||
speed: 0.18,
|
||||
scale: 1,
|
||||
frequency: 1,
|
||||
warpStrength: 1,
|
||||
mouseInfluence: 0.6,
|
||||
parallax: 0.4,
|
||||
noise: 0.08,
|
||||
iterations: 2,
|
||||
intensity: 1.15,
|
||||
bandWidth: 5,
|
||||
},
|
||||
shell: {
|
||||
className: "opacity-[0.85] dark:opacity-[0.9]",
|
||||
rotation: 90,
|
||||
speed: 0.18,
|
||||
scale: 1,
|
||||
frequency: 1,
|
||||
warpStrength: 1,
|
||||
mouseInfluence: 0.6,
|
||||
parallax: 0.4,
|
||||
noise: 0.08,
|
||||
iterations: 2,
|
||||
intensity: 1.3,
|
||||
bandWidth: 5,
|
||||
},
|
||||
chat: {
|
||||
className: "opacity-[0.3] dark:opacity-[0.42]",
|
||||
rotation: 90,
|
||||
speed: 0.1,
|
||||
scale: 1.05,
|
||||
frequency: 0.95,
|
||||
warpStrength: 0.9,
|
||||
mouseInfluence: 0.3,
|
||||
parallax: 0.25,
|
||||
noise: 0.05,
|
||||
iterations: 1,
|
||||
intensity: 0.8,
|
||||
bandWidth: 4.5,
|
||||
},
|
||||
};
|
||||
|
||||
export const ColorBendsBackdrop = ({
|
||||
variant,
|
||||
className,
|
||||
}: {
|
||||
variant: BackdropVariant;
|
||||
className?: string;
|
||||
}) => {
|
||||
const { className: presetClassName, ...preset } = PRESETS[variant];
|
||||
return (
|
||||
<div
|
||||
aria-hidden="true"
|
||||
className={`pointer-events-none absolute inset-0 z-0 ${className ?? ""}`}
|
||||
>
|
||||
<Suspense fallback={null}>
|
||||
<ColorBends
|
||||
{...preset}
|
||||
colors={COHAISE_BENDS}
|
||||
transparent
|
||||
className={presetClassName}
|
||||
/>
|
||||
</Suspense>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -21,6 +21,7 @@ import { getLocale } from "../lib/locale.js";
|
||||
import { useSession } from "../lib/session.js";
|
||||
import { useConfirm } from "./confirm.js";
|
||||
import { Avatar } from "./Avatar.js";
|
||||
import { ColorBendsBackdrop } from "./ColorBendsBackdrop.js";
|
||||
import { IconAction } from "./IconAction.js";
|
||||
import { Alert, Badge, EmptyState } from "./feedback.js";
|
||||
import {
|
||||
@@ -359,8 +360,9 @@ export const FolderChat = ({ folder, onClose }: { folder: ChatFolder; onClose: (
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="fixed inset-0 z-40 flex flex-col bg-background">
|
||||
<div className="relative flex h-full min-h-0">
|
||||
<div className="fixed inset-0 z-40 flex flex-col overflow-hidden bg-background">
|
||||
<ColorBendsBackdrop variant="chat" />
|
||||
<div className="relative z-10 flex h-full min-h-0">
|
||||
<aside
|
||||
className={cn(
|
||||
"absolute inset-y-0 left-0 z-20 flex w-64 flex-col border-r border-border bg-surface transition-transform md:static md:z-auto md:translate-x-0",
|
||||
@@ -437,7 +439,7 @@ export const FolderChat = ({ folder, onClose }: { folder: ChatFolder; onClose: (
|
||||
type="button"
|
||||
onClick={onClose}
|
||||
aria-label={t("Fermer la discussion")}
|
||||
className="rounded-sm text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-ring focus-visible:ring-2 focus-visible:outline-none"
|
||||
className="rounded-md p-1 text-muted-foreground transition-all hover:-translate-y-0.5 hover:bg-surface/60 hover:text-foreground hover:shadow-sm focus-visible:ring-ring focus-visible:ring-2 focus-visible:outline-none"
|
||||
>
|
||||
<CloseIcon className="h-5 w-5" />
|
||||
</button>
|
||||
@@ -672,15 +674,15 @@ export const FolderChat = ({ folder, onClose }: { folder: ChatFolder; onClose: (
|
||||
aria-label={t("Votre message")}
|
||||
className="max-h-40 min-h-[2.5rem] flex-1 resize-y rounded-sm border border-border-control bg-surface px-3 py-2 text-sm text-foreground placeholder:text-subtle-foreground focus-visible:border-border-strong focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background focus-visible:outline-none"
|
||||
/>
|
||||
<Button
|
||||
type="submit"
|
||||
size="md"
|
||||
<IconAction
|
||||
label={t("Envoyer")}
|
||||
icon={<SendIcon className="h-4 w-4" />}
|
||||
isLoading={sending}
|
||||
disabled={draft.trim().length === 0}
|
||||
iconLeading={<SendIcon className="h-4 w-4" />}
|
||||
>
|
||||
<span className="hidden sm:inline">{t("Envoyer")}</span>
|
||||
</Button>
|
||||
onClick={(event) => {
|
||||
event.preventDefault();
|
||||
void send(event as any);
|
||||
}}
|
||||
/>
|
||||
</form>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
@@ -23,8 +23,8 @@ export const IconAction = ({
|
||||
disabled={isLoading}
|
||||
onClick={onClick}
|
||||
className={cn(
|
||||
"relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-sm text-muted-foreground transition-colors",
|
||||
"hover:bg-surface-hover hover:text-foreground disabled:pointer-events-none disabled:opacity-50",
|
||||
"group relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-all",
|
||||
"hover:-translate-y-0.5 hover:bg-surface/60 hover:text-foreground hover:shadow-sm backdrop-blur-sm disabled:pointer-events-none disabled:opacity-50",
|
||||
tone === "danger" && "hover:text-destructive",
|
||||
)}
|
||||
>
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
/** Palette carmin de la marque, alignee sur `tokens.css`. */
|
||||
export const COHAISE_BENDS = ["#b71c1c", "#c92a2a", "#8f1116", "#5e0a14"];
|
||||
@@ -10,7 +10,8 @@ import {
|
||||
} from "../lib/api.js";
|
||||
import { useI18n } from "../lib/i18n.js";
|
||||
import { Alert, Modal } from "./feedback.js";
|
||||
import { TrashIcon } from "./icons.js";
|
||||
import { PlusIcon, TrashIcon } from "./icons.js";
|
||||
import { IconAction } from "./IconAction.js";
|
||||
|
||||
const LEVELS = ["read", "write", "admin"] as const;
|
||||
const LEVEL_LABEL: Record<string, string> = {
|
||||
@@ -69,13 +70,21 @@ export const CreateFolderDialog = ({
|
||||
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}>
|
||||
{t("Annuler")}
|
||||
</Button>
|
||||
<Button type="submit" size="md" isLoading={busy}>
|
||||
{t("Créer")}
|
||||
</Button>
|
||||
<div className="flex justify-end gap-1">
|
||||
<IconAction
|
||||
label={t("Annuler")}
|
||||
icon={<img src="/icons/close.png" alt="" className="h-4 w-4 object-contain" />}
|
||||
onClick={onClose}
|
||||
/>
|
||||
<IconAction
|
||||
label={t("Créer")}
|
||||
icon={<PlusIcon className="h-4 w-4" />}
|
||||
isLoading={busy}
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
void submit(e as any);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</form>
|
||||
</Modal>
|
||||
@@ -234,13 +243,21 @@ export const MoveDialog = ({
|
||||
</label>
|
||||
)}
|
||||
{error ? <Alert>{error}</Alert> : null}
|
||||
<div className="flex justify-end gap-2">
|
||||
<Button variant="ghost" size="md" onClick={onClose}>
|
||||
{t("Annuler")}
|
||||
</Button>
|
||||
<Button type="submit" size="md" isLoading={busy} disabled={entries === null}>
|
||||
{t("Déplacer")}
|
||||
</Button>
|
||||
<div className="flex justify-end gap-1">
|
||||
<IconAction
|
||||
label={t("Annuler")}
|
||||
icon={<img src="/icons/close.png" alt="" className="h-4 w-4 object-contain" />}
|
||||
onClick={onClose}
|
||||
/>
|
||||
<IconAction
|
||||
label={t("Déplacer")}
|
||||
icon={<img src="/icons/move.png" alt="" className="h-4 w-4 object-contain" />}
|
||||
isLoading={busy}
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
void submit(e as any);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</form>
|
||||
</Modal>
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { useEffect, type ReactNode } from "react";
|
||||
import { useEffect, useMemo, type ReactNode } from "react";
|
||||
import { cn } from "../ui/index.js";
|
||||
import { useI18n } from "../lib/i18n.js";
|
||||
import { CloseIcon } from "./icons.js";
|
||||
import { usePageHeader } from "./AppShell.js";
|
||||
|
||||
export const Modal = ({
|
||||
open,
|
||||
@@ -52,7 +53,7 @@ export const Modal = ({
|
||||
type="button"
|
||||
onClick={onClose}
|
||||
aria-label={t("Fermer")}
|
||||
className="rounded-sm text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-ring focus-visible:ring-2 focus-visible:outline-none"
|
||||
className="rounded-md p-1 text-muted-foreground transition-all hover:-translate-y-0.5 hover:bg-surface/60 hover:text-foreground hover:shadow-sm focus-visible:ring-ring focus-visible:ring-2 focus-visible:outline-none"
|
||||
>
|
||||
<CloseIcon className="h-5 w-5" />
|
||||
</button>
|
||||
@@ -97,22 +98,29 @@ export const PageHeader = ({
|
||||
description?: string;
|
||||
actions?: ReactNode;
|
||||
toolbar?: ReactNode;
|
||||
}) => (
|
||||
<header className="sticky top-0 z-10 -mx-4 flex flex-col gap-3 border-b border-border bg-background px-4 py-4">
|
||||
<div className="flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between">
|
||||
<div>
|
||||
<h1 className="font-display text-base font-semibold uppercase tracking-label text-foreground">
|
||||
{title}
|
||||
</h1>
|
||||
{description ? (
|
||||
<p className="mt-1 max-w-2xl text-sm leading-relaxed text-muted-foreground">{description}</p>
|
||||
) : null}
|
||||
</div>
|
||||
{actions ? <div className="flex flex-wrap items-center gap-2">{actions}</div> : null}
|
||||
</div>
|
||||
{toolbar ? <div className="flex flex-col gap-3">{toolbar}</div> : null}
|
||||
</header>
|
||||
);
|
||||
}) => {
|
||||
const header = useMemo(
|
||||
() => (
|
||||
<header className="flex flex-col gap-3 border-b border-border/50 bg-surface/70 px-4 py-4 backdrop-blur-md">
|
||||
<div className="flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between">
|
||||
<div>
|
||||
<h1 className="font-display text-base font-semibold uppercase tracking-label text-foreground">
|
||||
{title}
|
||||
</h1>
|
||||
{description ? (
|
||||
<p className="mt-1 max-w-2xl text-sm leading-relaxed text-muted-foreground">{description}</p>
|
||||
) : null}
|
||||
</div>
|
||||
{actions ? <div className="flex flex-wrap items-center gap-2">{actions}</div> : null}
|
||||
</div>
|
||||
{toolbar ? <div className="flex flex-col gap-3">{toolbar}</div> : null}
|
||||
</header>
|
||||
),
|
||||
[title, description, actions, toolbar],
|
||||
);
|
||||
usePageHeader(header);
|
||||
return null;
|
||||
};
|
||||
|
||||
export const EmptyState = ({
|
||||
icon,
|
||||
|
||||
@@ -1,221 +1,148 @@
|
||||
import type { SVGProps } from "react";
|
||||
import type { ImgHTMLAttributes } from "react";
|
||||
|
||||
type IconProps = SVGProps<SVGSVGElement>;
|
||||
type IconProps = Omit<ImgHTMLAttributes<HTMLImageElement>, "src" | "alt"> & {
|
||||
filled?: boolean;
|
||||
};
|
||||
|
||||
const base = (props: IconProps) => ({
|
||||
viewBox: "0 0 24 24",
|
||||
fill: "none",
|
||||
stroke: "currentColor",
|
||||
strokeWidth: 1.6,
|
||||
strokeLinecap: "round" as const,
|
||||
strokeLinejoin: "round" as const,
|
||||
"aria-hidden": true,
|
||||
...props,
|
||||
});
|
||||
const ImgIcon = ({
|
||||
src,
|
||||
className = "",
|
||||
...props
|
||||
}: { src: string } & IconProps) => (
|
||||
<img
|
||||
src={src}
|
||||
alt=""
|
||||
aria-hidden="true"
|
||||
className={`inline-block h-4 w-4 object-contain ${className}`}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
|
||||
export const FolderIcon = (props: IconProps) => (
|
||||
<svg {...base(props)}>
|
||||
<path d="M3 7.5A1.5 1.5 0 0 1 4.5 6h4l2 2.5h7A1.5 1.5 0 0 1 19 10v7.5A1.5 1.5 0 0 1 17.5 19h-13A1.5 1.5 0 0 1 3 17.5Z" />
|
||||
</svg>
|
||||
<ImgIcon src="/icons/folder.png" {...props} />
|
||||
);
|
||||
|
||||
export const FileIcon = (props: IconProps) => (
|
||||
<svg {...base(props)}>
|
||||
<path d="M6 3.5h7l5 5v12A1.5 1.5 0 0 1 16.5 22h-10A1.5 1.5 0 0 1 5 20.5v-16A1.5 1.5 0 0 1 6 3Z" />
|
||||
<path d="M13 3.5v5h5" />
|
||||
</svg>
|
||||
<ImgIcon src="/icons/document.png" {...props} />
|
||||
);
|
||||
|
||||
export const ImageIcon = (props: IconProps) => (
|
||||
<svg {...base(props)}>
|
||||
<rect x="3" y="4" width="18" height="16" rx="2" />
|
||||
<circle cx="8.5" cy="9.5" r="1.5" />
|
||||
<path d="m4 17 4.5-4.5a1.5 1.5 0 0 1 2.1 0L15 17m1.5-2 1.2-1.2a1.5 1.5 0 0 1 2.1 0L21 15" />
|
||||
</svg>
|
||||
<ImgIcon src="/icons/picture.png" {...props} />
|
||||
);
|
||||
|
||||
export const PlayIcon = (props: IconProps) => (
|
||||
<svg {...base(props)}>
|
||||
<path d="M8 5.5v13l11-6.5Z" fill="currentColor" stroke="none" />
|
||||
</svg>
|
||||
<ImgIcon src="/icons/file.png" {...props} />
|
||||
);
|
||||
|
||||
export const AudioIcon = (props: IconProps) => (
|
||||
<svg {...base(props)}>
|
||||
<path d="M9 17V5l10-2v12" />
|
||||
<circle cx="6.5" cy="17.5" r="2.5" />
|
||||
<circle cx="16.5" cy="15.5" r="2.5" />
|
||||
</svg>
|
||||
<ImgIcon src="/icons/file.png" {...props} />
|
||||
);
|
||||
|
||||
export const ArchiveIcon = (props: IconProps) => (
|
||||
<svg {...base(props)}>
|
||||
<path d="M3 7.5A1.5 1.5 0 0 1 4.5 6h4l2 2.5h7A1.5 1.5 0 0 1 19 10v7.5A1.5 1.5 0 0 1 17.5 19h-13A1.5 1.5 0 0 1 3 17.5Z" />
|
||||
<path d="M11 11.5h2m-2 3h2m-2 3h2" />
|
||||
</svg>
|
||||
<ImgIcon src="/icons/folder.png" {...props} />
|
||||
);
|
||||
|
||||
export const UploadIcon = (props: IconProps) => (
|
||||
<svg {...base(props)}>
|
||||
<path d="M12 16V4m0 0L7.5 8.5M12 4l4.5 4.5M4 17v1.5A1.5 1.5 0 0 0 5.5 20h13a1.5 1.5 0 0 0 1.5-1.5V17" />
|
||||
</svg>
|
||||
<ImgIcon src="/icons/upload.png" {...props} />
|
||||
);
|
||||
|
||||
export const DownloadIcon = (props: IconProps) => (
|
||||
<svg {...base(props)}>
|
||||
<path d="M12 4v12m0 0-4.5-4.5M12 16l4.5-4.5M4 17v1.5A1.5 1.5 0 0 0 5.5 20h13a1.5 1.5 0 0 0 1.5-1.5V17" />
|
||||
</svg>
|
||||
<ImgIcon src="/icons/download.png" {...props} />
|
||||
);
|
||||
|
||||
export const PlusIcon = (props: IconProps) => (
|
||||
<svg {...base(props)}>
|
||||
<path d="M12 5v14M5 12h14" />
|
||||
</svg>
|
||||
<ImgIcon src="/icons/plus.png" {...props} />
|
||||
);
|
||||
|
||||
export const TrashIcon = (props: IconProps) => (
|
||||
<svg {...base(props)}>
|
||||
<path d="M4 7h16M9 7V5.5A1.5 1.5 0 0 1 10.5 4h3A1.5 1.5 0 0 1 15 5.5V7m-8 0 .7 11.1A1.5 1.5 0 0 0 9.2 19.6h5.6a1.5 1.5 0 0 0 1.5-1.5L17 7" />
|
||||
</svg>
|
||||
<ImgIcon src="/icons/trash-can.png" {...props} />
|
||||
);
|
||||
|
||||
export const RestoreIcon = (props: IconProps) => (
|
||||
<svg {...base(props)}>
|
||||
<path d="M4 12a8 8 0 1 0 2.3-5.6M4 4v4h4" />
|
||||
</svg>
|
||||
<ImgIcon src="/icons/synchronize.png" {...props} />
|
||||
);
|
||||
|
||||
export const RefreshIcon = (props: IconProps) => (
|
||||
<svg {...base(props)}>
|
||||
<path d="M20 12a8 8 0 1 1-2.3-5.6M20 4v4h-4" />
|
||||
</svg>
|
||||
<ImgIcon src="/icons/synchronize.png" {...props} />
|
||||
);
|
||||
|
||||
export const StarIcon = ({ filled, ...props }: IconProps & { filled?: boolean }) => (
|
||||
<svg {...base(props)} fill={filled ? "currentColor" : "none"}>
|
||||
<path d="m12 3.5 2.6 5.3 5.9.9-4.2 4.1 1 5.8L12 20.8l-5.3 2.8 1-5.8L3.5 14l5.9-.9Z" />
|
||||
</svg>
|
||||
export const StarIcon = (props: IconProps) => (
|
||||
<ImgIcon src="/icons/favorite.png" {...props} />
|
||||
);
|
||||
|
||||
export const SearchIcon = (props: IconProps) => (
|
||||
<svg {...base(props)}>
|
||||
<circle cx="11" cy="11" r="7" />
|
||||
<path d="m20 20-3.5-3.5" />
|
||||
</svg>
|
||||
<ImgIcon src="/icons/search.png" {...props} />
|
||||
);
|
||||
|
||||
export const UsersIcon = (props: IconProps) => (
|
||||
<svg {...base(props)}>
|
||||
<circle cx="9" cy="8" r="3.5" />
|
||||
<path d="M3.5 20a5.5 5.5 0 0 1 11 0M16 5.5a3 3 0 0 1 0 6M16.5 20a5.5 1.5 0 0 0-2.2-4.3" />
|
||||
</svg>
|
||||
<ImgIcon src="/icons/accounts.png" {...props} />
|
||||
);
|
||||
|
||||
export const SettingsIcon = (props: IconProps) => (
|
||||
<svg {...base(props)}>
|
||||
<circle cx="12" cy="12" r="3" />
|
||||
<path d="M19.4 15a1.7 1.7 0 0 0 .3 1.9l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-2.9 1.2 2 2 0 1 1-4 0 1.7 1.7 0 0 0-2.9-1.2l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1A1.7 1.7 0 0 0 2.6 15a2 2 0 1 1 0-4 1.7 1.7 0 0 0 1.2-2.9l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1A1.7 1.7 0 0 0 9 4.6a2 2 0 1 1 4 0 1.7 1.7 0 0 0 2.9 1.2l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0 1.2 2.9 2 2 0 1 1 0 4 1.7 1.7 0 0 0-1.5 1Z" />
|
||||
</svg>
|
||||
<ImgIcon src="/icons/personal-settings.png" {...props} />
|
||||
);
|
||||
|
||||
export const LogoutIcon = (props: IconProps) => (
|
||||
<svg {...base(props)}>
|
||||
<path d="M15 4h2.5A1.5 1.5 0 0 1 19 5.5v13a1.5 1.5 0 0 1-1.5 1.5H15M10 8l-4 4 4 4M6 12h9" />
|
||||
</svg>
|
||||
<ImgIcon src="/icons/sign-out.png" {...props} />
|
||||
);
|
||||
|
||||
export const ShieldIcon = (props: IconProps) => (
|
||||
<svg {...base(props)}>
|
||||
<path d="M12 3 5 6v5c0 4.3 3 8.2 7 9.5 4-1.3 7-5.2 7-9.5V6Z" />
|
||||
<path d="m9 12 2 2 4-4" />
|
||||
</svg>
|
||||
<ImgIcon src="/icons/accounts.png" {...props} />
|
||||
);
|
||||
|
||||
export const HardDriveIcon = (props: IconProps) => (
|
||||
<svg {...base(props)}>
|
||||
<rect x="3" y="4" width="18" height="16" rx="2" />
|
||||
<path d="M3 14h18M7 17h.01M11 17h.01" />
|
||||
</svg>
|
||||
<ImgIcon src="/icons/storage.png" {...props} />
|
||||
);
|
||||
|
||||
export const ActivityIcon = (props: IconProps) => (
|
||||
<svg {...base(props)}>
|
||||
<path d="M3 12h4l3 8 4-16 3 8h4" />
|
||||
</svg>
|
||||
<ImgIcon src="/icons/activity.png" {...props} />
|
||||
);
|
||||
|
||||
export const SearchNavIcon = (props: IconProps) => (
|
||||
<svg {...base(props)}>
|
||||
<circle cx="11" cy="11" r="7" />
|
||||
<path d="m20 20-3.5-3.5" />
|
||||
</svg>
|
||||
<ImgIcon src="/icons/search.png" {...props} />
|
||||
);
|
||||
|
||||
export const ShareIcon = (props: IconProps) => (
|
||||
<svg {...base(props)}>
|
||||
<circle cx="18" cy="5" r="2.5" />
|
||||
<circle cx="6" cy="12" r="2.5" />
|
||||
<circle cx="18" cy="19" r="2.5" />
|
||||
<path d="m8.2 10.8 7.6-4.6M8.2 13.2l7.6 4.6" />
|
||||
</svg>
|
||||
<ImgIcon src="/icons/share.png" {...props} />
|
||||
);
|
||||
|
||||
export const MenuIcon = (props: IconProps) => (
|
||||
<svg {...base(props)}>
|
||||
<path d="M4 7h16M4 12h16M4 17h16" />
|
||||
</svg>
|
||||
<ImgIcon src="/icons/menu.png" {...props} />
|
||||
);
|
||||
|
||||
export const CloseIcon = (props: IconProps) => (
|
||||
<svg {...base(props)}>
|
||||
<path d="M6 6l12 12M18 6 6 18" />
|
||||
</svg>
|
||||
<ImgIcon src="/icons/close.png" {...props} />
|
||||
);
|
||||
|
||||
export const ArrowLeftIcon = (props: IconProps) => (
|
||||
<svg {...base(props)}>
|
||||
<path d="M19 12H5M11 18l-6-6 6-6" />
|
||||
</svg>
|
||||
<ImgIcon src="/icons/back.png" {...props} />
|
||||
);
|
||||
|
||||
export const ArrowRightIcon = (props: IconProps) => (
|
||||
<svg {...base(props)}>
|
||||
<path d="M5 12h14M13 6l6 6-6 6" />
|
||||
</svg>
|
||||
<ImgIcon
|
||||
src="/icons/back.png"
|
||||
{...props}
|
||||
style={{ transform: "rotate(180deg)", ...((props.style as any) || {}) }}
|
||||
/>
|
||||
);
|
||||
|
||||
export const PenIcon = (props: IconProps) => (
|
||||
<svg {...base(props)}>
|
||||
<path d="M4 20h4L18.5 9.5a2.1 2.1 0 0 0-3-3L5 17v3Z" />
|
||||
<path d="m13.5 6.5 3 3" />
|
||||
</svg>
|
||||
<ImgIcon src="/icons/edit-pencil.png" {...props} />
|
||||
);
|
||||
|
||||
/** Epingle : tete du pushpin en haut, pointe en bas. */
|
||||
export const PinIcon = (props: IconProps) => (
|
||||
<svg {...base(props)}>
|
||||
<path d="M9 3.5h6l-.8 5.2 3.3 3.1H6.5l3.3-3.1Z" />
|
||||
<path d="M12 11.8V20.5" />
|
||||
</svg>
|
||||
<ImgIcon src="/icons/file.png" {...props} />
|
||||
);
|
||||
|
||||
export const MoveIcon = (props: IconProps) => (
|
||||
<svg {...base(props)}>
|
||||
<path d="M12 4v16M4 12h16" />
|
||||
<path d="m9 7 3-3 3 3M9 17l3 3 3-3M7 9l-3 3 3 3M17 9l3 3-3 3" />
|
||||
</svg>
|
||||
<ImgIcon src="/icons/synchronize.png" {...props} />
|
||||
);
|
||||
|
||||
export const ChatIcon = (props: IconProps) => (
|
||||
<svg {...base(props)}>
|
||||
<path d="M20 15.5a1.5 1.5 0 0 1-1.5 1.5H8l-4 3.5V6.5A1.5 1.5 0 0 1 5.5 5h13A1.5 1.5 0 0 1 20 6.5Z" />
|
||||
<path d="M8 9.5h8M8 13h5" />
|
||||
</svg>
|
||||
<ImgIcon src="/icons/speech-bubble.png" {...props} />
|
||||
);
|
||||
|
||||
export const SendIcon = (props: IconProps) => (
|
||||
<svg {...base(props)}>
|
||||
<path d="M4.5 12 20 4.5 15 20l-3.5-6.5L4.5 12Z" />
|
||||
<path d="m11.5 13.5 4-4" />
|
||||
</svg>
|
||||
<ImgIcon src="/icons/send.png" {...props} />
|
||||
);
|
||||
|
||||
@@ -129,13 +129,11 @@ export const AdminUsers = () => {
|
||||
title={t("Comptes")}
|
||||
description={t("Créer des membres, ajustez leurs quotas et gérez les accès.")}
|
||||
actions={
|
||||
<Button
|
||||
size="sm"
|
||||
iconLeading={<PlusIcon className="h-3.5 w-3.5" />}
|
||||
<IconAction
|
||||
label={t("Nouveau membre")}
|
||||
icon={<PlusIcon className="h-4 w-4" />}
|
||||
onClick={() => setCreateOpen(true)}
|
||||
>
|
||||
{t("Nouveau membre")}
|
||||
</Button>
|
||||
/>
|
||||
}
|
||||
toolbar={
|
||||
<>
|
||||
@@ -210,18 +208,20 @@ export const AdminUsers = () => {
|
||||
</span>
|
||||
|
||||
<div className="flex items-center gap-1">
|
||||
<Button variant="ghost" size="sm" onClick={() => setEdit(user)}>
|
||||
{t("Modifier")}
|
||||
</Button>
|
||||
<IconAction
|
||||
label={t("Modifier")}
|
||||
icon={<img src="/icons/edit-pencil.png" alt="" className="h-4 w-4 object-contain" />}
|
||||
onClick={() => setEdit(user)}
|
||||
/>
|
||||
<IconAction
|
||||
label={user.is_active ? t("Désactiver") : t("Réactiver")}
|
||||
icon={<HardDriveIcon className="h-4 w-4" />}
|
||||
icon={<img src="/icons/deactivate.png" alt="" className="h-4 w-4 object-contain" />}
|
||||
isLoading={busy === user.id}
|
||||
onClick={() => void toggleActive(user)}
|
||||
/>
|
||||
<IconAction
|
||||
label={t("Réinitialiser le mot de passe")}
|
||||
icon={<ActivityIcon className="h-4 w-4" />}
|
||||
icon={<img src="/icons/password-reset.png" alt="" className="h-4 w-4 object-contain" />}
|
||||
isLoading={busy === user.id}
|
||||
onClick={() => void resetPassword(user)}
|
||||
/>
|
||||
@@ -505,13 +505,11 @@ export const AdminStorage = () => {
|
||||
title={t("Emplacements de stockage")}
|
||||
description={t("Volumes montés utilisés pour stocker les fichiers.")}
|
||||
actions={
|
||||
<Button
|
||||
size="sm"
|
||||
iconLeading={<PlusIcon className="h-3.5 w-3.5" />}
|
||||
<IconAction
|
||||
label={t("Nouvel emplacement")}
|
||||
icon={<PlusIcon className="h-4 w-4" />}
|
||||
onClick={() => setCreateOpen(true)}
|
||||
>
|
||||
{t("Nouvel emplacement")}
|
||||
</Button>
|
||||
/>
|
||||
}
|
||||
/>
|
||||
|
||||
@@ -544,9 +542,11 @@ export const AdminStorage = () => {
|
||||
: t("{used} Go utilisés", { used: toGb(location.used_bytes) })}
|
||||
</span>
|
||||
</span>
|
||||
<Button variant="ghost" size="sm" onClick={() => void toggle(location)}>
|
||||
{location.is_active ? t("Désactiver") : t("Réactiver")}
|
||||
</Button>
|
||||
<IconAction
|
||||
label={location.is_active ? t("Désactiver") : t("Réactiver")}
|
||||
icon={<img src={location.is_active ? "/icons/close.png" : "/icons/synchronize.png"} alt="" className="h-4 w-4 object-contain" />}
|
||||
onClick={() => void toggle(location)}
|
||||
/>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
useState,
|
||||
type DragEvent,
|
||||
} from "react";
|
||||
import { Button, Card, Spinner, cn } from "../ui/index.js";
|
||||
import { Card, Spinner, cn } from "../ui/index.js";
|
||||
import {
|
||||
ApiError,
|
||||
api,
|
||||
@@ -17,7 +17,7 @@ import { useSession } from "../lib/session.js";
|
||||
import { useI18n } from "../lib/i18n.js";
|
||||
import { getLocale } from "../lib/locale.js";
|
||||
import { mediaKind } from "../lib/media.js";
|
||||
import { Badge, EmptyState, PageHeader } from "../components/feedback.js";
|
||||
import { EmptyState, PageHeader } from "../components/feedback.js";
|
||||
import { useConfirm } from "../components/confirm.js";
|
||||
import { MediaViewer } from "../components/MediaViewer.js";
|
||||
import { MediaThumb } from "../components/MediaThumb.js";
|
||||
@@ -33,8 +33,8 @@ import {
|
||||
import {
|
||||
ArrowLeftIcon,
|
||||
ChatIcon,
|
||||
CloseIcon,
|
||||
DownloadIcon,
|
||||
FolderIcon,
|
||||
PenIcon,
|
||||
PlusIcon,
|
||||
RefreshIcon,
|
||||
@@ -538,32 +538,22 @@ export const Browser = () => {
|
||||
</ol>
|
||||
</nav>
|
||||
|
||||
<Button
|
||||
variant="secondary"
|
||||
size="sm"
|
||||
iconLeading={<RefreshIcon className="h-3.5 w-3.5" />}
|
||||
<IconAction
|
||||
label={t("Rafraîchir")}
|
||||
icon={<RefreshIcon className="h-4 w-4" />}
|
||||
isLoading={refreshing}
|
||||
onClick={() => void manualRefresh()}
|
||||
>
|
||||
{t("Rafraîchir")}
|
||||
</Button>
|
||||
/>
|
||||
|
||||
{current.id ? (
|
||||
<Button
|
||||
variant="secondary"
|
||||
size="sm"
|
||||
iconLeading={<ChatIcon className="h-3.5 w-3.5" />}
|
||||
<IconAction
|
||||
label={t("Discussion")}
|
||||
icon={<ChatIcon className="h-4 w-4" />}
|
||||
badge={currentUnread}
|
||||
onClick={() =>
|
||||
setChat({ id: current.id as string, name: current.name })
|
||||
}
|
||||
>
|
||||
<span className="inline-flex items-center gap-2">
|
||||
{t("Discussion")}
|
||||
{currentUnread > 0 ? (
|
||||
<Badge tone="accent">{currentUnread}</Badge>
|
||||
) : null}
|
||||
</span>
|
||||
</Button>
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
}
|
||||
@@ -619,7 +609,7 @@ export const Browser = () => {
|
||||
) : null}
|
||||
|
||||
{canWrite ? (
|
||||
<div className="flex gap-2">
|
||||
<div className="flex gap-1">
|
||||
<input
|
||||
ref={fileInputRef}
|
||||
type="file"
|
||||
@@ -627,25 +617,17 @@ export const Browser = () => {
|
||||
className="sr-only"
|
||||
onChange={(event) => void upload(event.target.files)}
|
||||
/>
|
||||
<Button
|
||||
variant="secondary"
|
||||
size="sm"
|
||||
iconLeading={<UploadIcon className="h-3.5 w-3.5" />}
|
||||
<IconAction
|
||||
label={uploading && uploadProgress ? t("Envoi {current}/{total}…", uploadProgress) : t("Envoyer")}
|
||||
icon={<UploadIcon className="h-4 w-4" />}
|
||||
isLoading={uploading}
|
||||
onClick={() => fileInputRef.current?.click()}
|
||||
>
|
||||
{uploading && uploadProgress
|
||||
? t("Envoi {current}/{total}…", uploadProgress)
|
||||
: t("Envoyer")}
|
||||
</Button>
|
||||
<Button
|
||||
variant="secondary"
|
||||
size="sm"
|
||||
iconLeading={<PlusIcon className="h-3.5 w-3.5" />}
|
||||
/>
|
||||
<IconAction
|
||||
label={t("Nouveau dossier")}
|
||||
icon={<PlusIcon className="h-4 w-4" />}
|
||||
onClick={() => setDialog({ kind: "create" })}
|
||||
>
|
||||
{t("Nouveau dossier")}
|
||||
</Button>
|
||||
/>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
@@ -681,25 +663,21 @@ export const Browser = () => {
|
||||
|
||||
{canWrite && selectedItems.length > 0 ? (
|
||||
<div className="fixed bottom-3 left-1/2 z-40 w-[calc(100%-1rem)] max-w-xl -translate-x-1/2 px-1 sm:bottom-4 sm:w-auto">
|
||||
<div className="flex flex-col items-center justify-center gap-2 rounded-lg border border-border-strong bg-surface px-3 py-2 shadow-lg sm:flex-row sm:flex-wrap sm:items-center sm:justify-center">
|
||||
<div className="flex flex-col items-center justify-center gap-2 rounded-lg border border-border-strong bg-surface/80 px-3 py-2 shadow-lg backdrop-blur-md sm:flex-row sm:flex-wrap sm:items-center sm:justify-center">
|
||||
<p className="text-center text-sm font-medium text-foreground">
|
||||
{t("{count} élément(s) sélectionné(s).", {
|
||||
count: selectedItems.length,
|
||||
})}
|
||||
</p>
|
||||
<div className="flex flex-wrap items-center justify-center gap-2">
|
||||
<Button
|
||||
size="sm"
|
||||
variant="secondary"
|
||||
onClick={() =>
|
||||
setDialog({ kind: "moveMany", targets: selectedItems })
|
||||
}
|
||||
>
|
||||
{t("Déplacer")}
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="secondary"
|
||||
<div className="flex flex-wrap items-center justify-center gap-1">
|
||||
<IconAction
|
||||
label={t("Déplacer")}
|
||||
icon={<img src="/icons/move.png" alt="" className="h-4 w-4 object-contain" />}
|
||||
onClick={() => setDialog({ kind: "moveMany", targets: selectedItems })}
|
||||
/>
|
||||
<IconAction
|
||||
label={t("Télécharger")}
|
||||
icon={<DownloadIcon className="h-4 w-4" />}
|
||||
onClick={() => {
|
||||
const files = selectedItems.filter((t) => t.type === "file");
|
||||
if (files.length === 0) {
|
||||
@@ -716,19 +694,18 @@ export const Browser = () => {
|
||||
toast.info(t("Les dossiers n'ont pas été téléchargés."));
|
||||
}
|
||||
}}
|
||||
>
|
||||
{t("Télécharger")}
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="destructive"
|
||||
/>
|
||||
<IconAction
|
||||
label={t("Supprimer")}
|
||||
icon={<TrashIcon className="h-4 w-4" />}
|
||||
tone="danger"
|
||||
onClick={() => void removeSelected()}
|
||||
>
|
||||
{t("Supprimer")}
|
||||
</Button>
|
||||
<Button size="sm" variant="ghost" onClick={clearSelection}>
|
||||
{t("Annuler la sélection")}
|
||||
</Button>
|
||||
/>
|
||||
<IconAction
|
||||
label={t("Annuler la sélection")}
|
||||
icon={<CloseIcon className="h-4 w-4" />}
|
||||
onClick={clearSelection}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -740,7 +717,7 @@ export const Browser = () => {
|
||||
</div>
|
||||
) : empty ? (
|
||||
<EmptyState
|
||||
icon={<FolderIcon className="h-8 w-8" />}
|
||||
icon={<img src="/icons/opened-folder.png" alt="" className="h-8 w-8 object-contain" />}
|
||||
title={t("Emplacement vide")}
|
||||
description={t(
|
||||
"Créez un sous-dossier ou envoyez un fichier pour commencer.",
|
||||
@@ -762,7 +739,7 @@ export const Browser = () => {
|
||||
onDrop={(event) => onFolderDrop(event, folder)}
|
||||
onClick={() => toggleSelection(`f:${folder.id}`)}
|
||||
className={cn(
|
||||
"group relative flex items-center gap-1 rounded-lg border border-border bg-surface p-2 transition-colors hover:border-border-strong hover:bg-surface-hover cursor-pointer",
|
||||
"group relative flex items-center gap-1 rounded-xl border border-border/50 bg-surface/60 p-2 backdrop-blur-md transition-all hover:-translate-y-1 hover:border-border-strong hover:bg-surface/80 hover:shadow-lg cursor-pointer",
|
||||
dropTargetId === folder.id &&
|
||||
"border-accent bg-accent/10 ring-1 ring-accent/50",
|
||||
selected.has(`f:${folder.id}`) &&
|
||||
@@ -798,7 +775,7 @@ export const Browser = () => {
|
||||
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"
|
||||
>
|
||||
<span className="shrink-0 text-accent">
|
||||
<FolderIcon className="h-5 w-5" />
|
||||
<img src="/icons/opened-folder.png" alt="" className="h-5 w-5 object-contain" />
|
||||
</span>
|
||||
<span className="min-w-0 flex-1">
|
||||
<span className="block truncate text-sm font-medium text-foreground">
|
||||
@@ -879,7 +856,7 @@ export const Browser = () => {
|
||||
{t("Rien à afficher pour ce filtre.")}
|
||||
</p>
|
||||
) : (
|
||||
<ul className="flex flex-col divide-y divide-border rounded-lg border border-border bg-surface">
|
||||
<ul className="flex flex-col divide-y divide-border rounded-xl border border-border/50 bg-surface/60 backdrop-blur-md">
|
||||
{visibleFiles.map((file, index) => (
|
||||
<li
|
||||
key={file.id}
|
||||
@@ -943,8 +920,7 @@ export const Browser = () => {
|
||||
}
|
||||
icon={
|
||||
<StarIcon
|
||||
className="h-4 w-4"
|
||||
{...(file.is_starred ? { filled: true } : {})}
|
||||
className={`h-4 w-4 ${file.is_starred ? "text-accent" : "opacity-60"}`}
|
||||
/>
|
||||
}
|
||||
onClick={(event) => {
|
||||
@@ -956,13 +932,12 @@ export const Browser = () => {
|
||||
<a
|
||||
href={api.downloadUrl(file.id)}
|
||||
download={file.name}
|
||||
className="inline-flex h-8 items-center gap-1.5 rounded-sm border border-border-strong bg-surface px-3 font-display text-[0.6875rem] font-semibold uppercase tracking-label text-foreground transition-colors hover:bg-surface-hover"
|
||||
aria-label={t("Télécharger {name}", { name: file.name })}
|
||||
title={t("Télécharger {name}", { name: file.name })}
|
||||
className="inline-flex h-8 w-8 items-center justify-center rounded-md border border-border/50 bg-surface/60 text-muted-foreground backdrop-blur-sm transition-all hover:-translate-y-0.5 hover:bg-surface/80 hover:text-foreground hover:shadow-sm"
|
||||
onClick={(event) => event.stopPropagation()}
|
||||
>
|
||||
<DownloadIcon className="h-3.5 w-3.5" />
|
||||
<span className="hidden sm:inline">
|
||||
{t("Télécharger")}
|
||||
</span>
|
||||
<DownloadIcon className="h-4 w-4" />
|
||||
</a>
|
||||
|
||||
{canWrite ? (
|
||||
|
||||
@@ -36,83 +36,81 @@ export const ChangePassword = () => {
|
||||
};
|
||||
|
||||
return (
|
||||
<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">
|
||||
<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">
|
||||
{t("Nouveau mot de passe")}
|
||||
</h1>
|
||||
</div>
|
||||
<div className="w-full max-w-sm">
|
||||
<header className="mb-6 text-center">
|
||||
<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">
|
||||
{t("Nouveau mot de passe")}
|
||||
</h1>
|
||||
</div>
|
||||
<p className="mt-2 text-sm leading-relaxed text-muted-foreground">
|
||||
{t("Bienvenue {name}. Ce mot de passe a été défini par un administrateur : choisissez le vôtre.", { name: user?.first_name ?? "" })}
|
||||
</p>
|
||||
</header>
|
||||
</div>
|
||||
<p className="mt-2 text-sm leading-relaxed text-muted-foreground">
|
||||
{t("Bienvenue {name}. Ce mot de passe a été défini par un administrateur : choisissez le vôtre.", { name: user?.first_name ?? "" })}
|
||||
</p>
|
||||
</header>
|
||||
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>{t("Changement requis")}</CardTitle>
|
||||
<CardDescription>
|
||||
{t("Les autres sessions ouvertes sur ce compte seront fermées.")}
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<form className="flex flex-col gap-4" onSubmit={(event) => void submit(event)}>
|
||||
<Input
|
||||
label={t("Mot de passe actuel")}
|
||||
type="password"
|
||||
autoComplete="current-password"
|
||||
required
|
||||
autoFocus
|
||||
value={current}
|
||||
onChange={(event) => setCurrent(event.target.value)}
|
||||
/>
|
||||
<Input
|
||||
label={t("Nouveau mot de passe")}
|
||||
type="password"
|
||||
autoComplete="new-password"
|
||||
required
|
||||
minLength={8}
|
||||
hint={t("8 caractères minimum.")}
|
||||
value={next}
|
||||
onChange={(event) => setNext(event.target.value)}
|
||||
/>
|
||||
<Input
|
||||
label={t("Confirmation")}
|
||||
type="password"
|
||||
autoComplete="new-password"
|
||||
required
|
||||
minLength={8}
|
||||
value={confirm}
|
||||
onChange={(event) => setConfirm(event.target.value)}
|
||||
/>
|
||||
{error ? <Alert>{error}</Alert> : null}
|
||||
<Button type="submit" size="lg" fullWidth isLoading={busy}>
|
||||
{t("Enregistrer")}
|
||||
</Button>
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="md"
|
||||
fullWidth
|
||||
onClick={() => void logout()}
|
||||
>
|
||||
{t("Se déconnecter")}
|
||||
</Button>
|
||||
</form>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
</main>
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>{t("Changement requis")}</CardTitle>
|
||||
<CardDescription>
|
||||
{t("Les autres sessions ouvertes sur ce compte seront fermées.")}
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<form className="flex flex-col gap-4" onSubmit={(event) => void submit(event)}>
|
||||
<Input
|
||||
label={t("Mot de passe actuel")}
|
||||
type="password"
|
||||
autoComplete="current-password"
|
||||
required
|
||||
autoFocus
|
||||
value={current}
|
||||
onChange={(event) => setCurrent(event.target.value)}
|
||||
/>
|
||||
<Input
|
||||
label={t("Nouveau mot de passe")}
|
||||
type="password"
|
||||
autoComplete="new-password"
|
||||
required
|
||||
minLength={8}
|
||||
hint={t("8 caractères minimum.")}
|
||||
value={next}
|
||||
onChange={(event) => setNext(event.target.value)}
|
||||
/>
|
||||
<Input
|
||||
label={t("Confirmation")}
|
||||
type="password"
|
||||
autoComplete="new-password"
|
||||
required
|
||||
minLength={8}
|
||||
value={confirm}
|
||||
onChange={(event) => setConfirm(event.target.value)}
|
||||
/>
|
||||
{error ? <Alert>{error}</Alert> : null}
|
||||
<Button type="submit" size="lg" fullWidth isLoading={busy}>
|
||||
{t("Enregistrer")}
|
||||
</Button>
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="md"
|
||||
fullWidth
|
||||
onClick={() => void logout()}
|
||||
>
|
||||
{t("Se déconnecter")}
|
||||
</Button>
|
||||
</form>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -36,57 +36,55 @@ export const ConfirmEmail = () => {
|
||||
}, [token, refresh]);
|
||||
|
||||
return (
|
||||
<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">
|
||||
<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">
|
||||
{t("Changement d'adresse")}
|
||||
</h1>
|
||||
</div>
|
||||
<div className="w-full max-w-sm">
|
||||
<header className="mb-6 text-center">
|
||||
<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">
|
||||
{t("Changement d'adresse")}
|
||||
</h1>
|
||||
</div>
|
||||
</header>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>{t("Confirmation")}</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="flex flex-col gap-4">
|
||||
{state === "loading" ? (
|
||||
<div className="flex justify-center py-4">
|
||||
<Spinner size="md" />
|
||||
</div>
|
||||
) : state === "success" ? (
|
||||
<>
|
||||
<Alert tone="success">{t("Votre adresse e-mail a été mise à jour.")}</Alert>
|
||||
<Link to="/files">
|
||||
<Button size="lg" fullWidth>
|
||||
{t("Accéder à mes fichiers")}
|
||||
</Button>
|
||||
</Link>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Alert>{error}</Alert>
|
||||
<Link to="/profile">
|
||||
<Button size="lg" fullWidth>
|
||||
{t("Mon compte")}
|
||||
</Button>
|
||||
</Link>
|
||||
</>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
</main>
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>{t("Confirmation")}</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="flex flex-col gap-4">
|
||||
{state === "loading" ? (
|
||||
<div className="flex justify-center py-4">
|
||||
<Spinner size="md" />
|
||||
</div>
|
||||
) : state === "success" ? (
|
||||
<>
|
||||
<Alert tone="success">{t("Votre adresse e-mail a été mise à jour.")}</Alert>
|
||||
<Link to="/files">
|
||||
<Button size="lg" fullWidth>
|
||||
{t("Accéder à mes fichiers")}
|
||||
</Button>
|
||||
</Link>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Alert>{error}</Alert>
|
||||
<Link to="/profile">
|
||||
<Button size="lg" fullWidth>
|
||||
{t("Mon compte")}
|
||||
</Button>
|
||||
</Link>
|
||||
</>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -60,7 +60,7 @@ export const Favorites = () => {
|
||||
description={t("Étoilez un fichier dans l'explorateur pour le retrouver ici.")}
|
||||
/>
|
||||
) : (
|
||||
<ul className="flex flex-col divide-y divide-border rounded-lg border border-border bg-surface">
|
||||
<ul className="flex flex-col divide-y divide-border rounded-xl border border-border/50 bg-surface/60 backdrop-blur-md">
|
||||
{files.map((file, index) => (
|
||||
<li key={file.id} className="flex items-center gap-2 px-3 py-2.5">
|
||||
<button
|
||||
@@ -85,17 +85,18 @@ export const Favorites = () => {
|
||||
|
||||
<IconAction
|
||||
label={t("Retirer l'étoile de {name}", { name: file.name })}
|
||||
icon={<StarIcon className="h-4 w-4" filled />}
|
||||
icon={<StarIcon className="h-4 w-4" />}
|
||||
onClick={() => void unstar(file)}
|
||||
/>
|
||||
|
||||
<a
|
||||
href={api.downloadUrl(file.id)}
|
||||
download={file.name}
|
||||
className="inline-flex h-8 items-center gap-1.5 rounded-sm border border-border-strong bg-surface px-3 font-display text-[0.6875rem] font-semibold uppercase tracking-label text-foreground transition-colors hover:bg-surface-hover"
|
||||
aria-label={t("Télécharger {name}", { name: file.name })}
|
||||
title={t("Télécharger {name}", { name: file.name })}
|
||||
className="inline-flex h-8 w-8 items-center justify-center rounded-md border border-border/50 bg-surface/60 text-muted-foreground backdrop-blur-sm transition-all hover:-translate-y-0.5 hover:bg-surface/80 hover:text-foreground hover:shadow-sm"
|
||||
>
|
||||
<DownloadIcon className="h-3.5 w-3.5" />
|
||||
<span className="hidden sm:inline">{t("Télécharger")}</span>
|
||||
<DownloadIcon className="h-4 w-4" />
|
||||
</a>
|
||||
</li>
|
||||
))}
|
||||
|
||||
@@ -27,75 +27,73 @@ export const ForgotPassword = () => {
|
||||
};
|
||||
|
||||
return (
|
||||
<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">
|
||||
<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">
|
||||
{t("Mot de passe oublié")}
|
||||
</h1>
|
||||
</div>
|
||||
<div className="w-full max-w-sm">
|
||||
<header className="mb-6 text-center">
|
||||
<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">
|
||||
{t("Mot de passe oublié")}
|
||||
</h1>
|
||||
</div>
|
||||
</header>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>{t("Réinitialisation")}</CardTitle>
|
||||
<CardDescription>
|
||||
{t("Nous vous enverrons un lien valable une heure.")}
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
{sent ? (
|
||||
<div className="flex flex-col gap-4">
|
||||
<Alert tone="success">
|
||||
{t("Si cette adresse correspond à un compte, un message contenant le lien de réinitialisation vient d'être envoyé.")}
|
||||
</Alert>
|
||||
<Link
|
||||
to="/login"
|
||||
className="text-center text-xs text-muted-foreground underline-offset-2 hover:text-foreground hover:underline"
|
||||
>
|
||||
{t("Retour à la connexion")}
|
||||
</Link>
|
||||
</div>
|
||||
) : (
|
||||
<form
|
||||
className="flex flex-col gap-4"
|
||||
onSubmit={(event) => void submit(event)}
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>{t("Réinitialisation")}</CardTitle>
|
||||
<CardDescription>
|
||||
{t("Nous vous enverrons un lien valable une heure.")}
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
{sent ? (
|
||||
<div className="flex flex-col gap-4">
|
||||
<Alert tone="success">
|
||||
{t("Si cette adresse correspond à un compte, un message contenant le lien de réinitialisation vient d'être envoyé.")}
|
||||
</Alert>
|
||||
<Link
|
||||
to="/login"
|
||||
className="text-center text-xs text-muted-foreground underline-offset-2 hover:text-foreground hover:underline"
|
||||
>
|
||||
<Input
|
||||
label={t("Adresse e-mail")}
|
||||
type="email"
|
||||
autoComplete="email"
|
||||
required
|
||||
autoFocus
|
||||
value={email}
|
||||
onChange={(event) => setEmail(event.target.value)}
|
||||
/>
|
||||
{error ? <Alert>{error}</Alert> : null}
|
||||
<Button type="submit" size="lg" fullWidth isLoading={busy}>
|
||||
{t("Envoyer le lien")}
|
||||
</Button>
|
||||
<Link
|
||||
to="/login"
|
||||
className="text-center text-xs text-muted-foreground underline-offset-2 hover:text-foreground hover:underline"
|
||||
>
|
||||
{t("Retour à la connexion")}
|
||||
</Link>
|
||||
</form>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
</main>
|
||||
{t("Retour à la connexion")}
|
||||
</Link>
|
||||
</div>
|
||||
) : (
|
||||
<form
|
||||
className="flex flex-col gap-4"
|
||||
onSubmit={(event) => void submit(event)}
|
||||
>
|
||||
<Input
|
||||
label={t("Adresse e-mail")}
|
||||
type="email"
|
||||
autoComplete="email"
|
||||
required
|
||||
autoFocus
|
||||
value={email}
|
||||
onChange={(event) => setEmail(event.target.value)}
|
||||
/>
|
||||
{error ? <Alert>{error}</Alert> : null}
|
||||
<Button type="submit" size="lg" fullWidth isLoading={busy}>
|
||||
{t("Envoyer le lien")}
|
||||
</Button>
|
||||
<Link
|
||||
to="/login"
|
||||
className="text-center text-xs text-muted-foreground underline-offset-2 hover:text-foreground hover:underline"
|
||||
>
|
||||
{t("Retour à la connexion")}
|
||||
</Link>
|
||||
</form>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -32,71 +32,69 @@ export const Login = () => {
|
||||
};
|
||||
|
||||
return (
|
||||
<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">
|
||||
<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 className="w-full max-w-sm">
|
||||
<header className="mb-6 text-center">
|
||||
<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>
|
||||
<p className="mt-2 text-sm leading-relaxed text-muted-foreground">
|
||||
{t("Connectez-vous pour accéder à vos fichiers.")}
|
||||
</p>
|
||||
</header>
|
||||
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>{t("Connexion")}</CardTitle>
|
||||
<CardDescription>{t("Votre session reste ouverte 14 jours.")}</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<form className="flex flex-col gap-4" onSubmit={(event) => void submit(event)}>
|
||||
<Input
|
||||
label={t("Adresse e-mail")}
|
||||
type="email"
|
||||
autoComplete="username"
|
||||
required
|
||||
autoFocus
|
||||
value={email}
|
||||
onChange={(event) => setEmail(event.target.value)}
|
||||
/>
|
||||
<Input
|
||||
label={t("Mot de passe")}
|
||||
type="password"
|
||||
autoComplete="current-password"
|
||||
required
|
||||
value={password}
|
||||
onChange={(event) => setPassword(event.target.value)}
|
||||
{...(error ? { error } : {})}
|
||||
/>
|
||||
|
||||
<Button type="submit" size="lg" fullWidth isLoading={busy}>
|
||||
{t("Se connecter")}
|
||||
</Button>
|
||||
</form>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<p className="mt-4 text-center text-xs text-muted-foreground">
|
||||
<Link
|
||||
to="/forgot-password"
|
||||
className="underline-offset-2 hover:text-foreground hover:underline"
|
||||
>
|
||||
{t("Mot de passe oublié ?")}
|
||||
</Link>
|
||||
</div>
|
||||
<p className="mt-2 text-sm leading-relaxed text-muted-foreground">
|
||||
{t("Connectez-vous pour accéder à vos fichiers.")}
|
||||
</p>
|
||||
</div>
|
||||
</main>
|
||||
</header>
|
||||
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>{t("Connexion")}</CardTitle>
|
||||
<CardDescription>{t("Votre session reste ouverte 14 jours.")}</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<form className="flex flex-col gap-4" onSubmit={(event) => void submit(event)}>
|
||||
<Input
|
||||
label={t("Adresse e-mail")}
|
||||
type="email"
|
||||
autoComplete="username"
|
||||
required
|
||||
autoFocus
|
||||
value={email}
|
||||
onChange={(event) => setEmail(event.target.value)}
|
||||
/>
|
||||
<Input
|
||||
label={t("Mot de passe")}
|
||||
type="password"
|
||||
autoComplete="current-password"
|
||||
required
|
||||
value={password}
|
||||
onChange={(event) => setPassword(event.target.value)}
|
||||
{...(error ? { error } : {})}
|
||||
/>
|
||||
|
||||
<Button type="submit" size="lg" fullWidth isLoading={busy}>
|
||||
{t("Se connecter")}
|
||||
</Button>
|
||||
</form>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<p className="mt-4 text-center text-xs text-muted-foreground">
|
||||
<Link
|
||||
to="/forgot-password"
|
||||
className="underline-offset-2 hover:text-foreground hover:underline"
|
||||
>
|
||||
{t("Mot de passe oublié ?")}
|
||||
</Link>
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -34,84 +34,82 @@ export const ResetPassword = () => {
|
||||
};
|
||||
|
||||
return (
|
||||
<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">
|
||||
<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">
|
||||
{t("Nouveau mot de passe")}
|
||||
</h1>
|
||||
</div>
|
||||
<div className="w-full max-w-sm">
|
||||
<header className="mb-6 text-center">
|
||||
<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">
|
||||
{t("Nouveau mot de passe")}
|
||||
</h1>
|
||||
</div>
|
||||
</header>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>{t("Réinitialisation")}</CardTitle>
|
||||
<CardDescription>{t("Choisissez un mot de passe robuste.")}</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
{!token ? (
|
||||
<div className="flex flex-col gap-4">
|
||||
<Alert>{t("Ce lien est incomplet ou invalide.")}</Alert>
|
||||
<Link
|
||||
to="/forgot-password"
|
||||
className="text-center text-xs text-muted-foreground underline-offset-2 hover:text-foreground hover:underline"
|
||||
>
|
||||
{t("Demander un nouveau lien")}
|
||||
</Link>
|
||||
</div>
|
||||
) : done ? (
|
||||
<div className="flex flex-col gap-4">
|
||||
<Alert tone="success">
|
||||
{t("Votre mot de passe a été réinitialisé. Vous pouvez vous connecter.")}
|
||||
</Alert>
|
||||
<Link to="/login">
|
||||
<Button size="lg" fullWidth>
|
||||
{t("Se connecter")}
|
||||
</Button>
|
||||
</Link>
|
||||
</div>
|
||||
) : (
|
||||
<form className="flex flex-col gap-4" onSubmit={(event) => void submit(event)}>
|
||||
<Input
|
||||
label={t("Nouveau mot de passe")}
|
||||
type="password"
|
||||
autoComplete="new-password"
|
||||
required
|
||||
minLength={8}
|
||||
autoFocus
|
||||
hint={t("8 caractères minimum.")}
|
||||
value={password}
|
||||
onChange={(event) => setPassword(event.target.value)}
|
||||
/>
|
||||
<Input
|
||||
label={t("Confirmation")}
|
||||
type="password"
|
||||
autoComplete="new-password"
|
||||
required
|
||||
minLength={8}
|
||||
value={confirm}
|
||||
onChange={(event) => setConfirm(event.target.value)}
|
||||
/>
|
||||
{error ? <Alert>{error}</Alert> : null}
|
||||
<Button type="submit" size="lg" fullWidth isLoading={busy}>
|
||||
{t("Réinitialiser")}
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>{t("Réinitialisation")}</CardTitle>
|
||||
<CardDescription>{t("Choisissez un mot de passe robuste.")}</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
{!token ? (
|
||||
<div className="flex flex-col gap-4">
|
||||
<Alert>{t("Ce lien est incomplet ou invalide.")}</Alert>
|
||||
<Link
|
||||
to="/forgot-password"
|
||||
className="text-center text-xs text-muted-foreground underline-offset-2 hover:text-foreground hover:underline"
|
||||
>
|
||||
{t("Demander un nouveau lien")}
|
||||
</Link>
|
||||
</div>
|
||||
) : done ? (
|
||||
<div className="flex flex-col gap-4">
|
||||
<Alert tone="success">
|
||||
{t("Votre mot de passe a été réinitialisé. Vous pouvez vous connecter.")}
|
||||
</Alert>
|
||||
<Link to="/login">
|
||||
<Button size="lg" fullWidth>
|
||||
{t("Se connecter")}
|
||||
</Button>
|
||||
</form>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
</main>
|
||||
</Link>
|
||||
</div>
|
||||
) : (
|
||||
<form className="flex flex-col gap-4" onSubmit={(event) => void submit(event)}>
|
||||
<Input
|
||||
label={t("Nouveau mot de passe")}
|
||||
type="password"
|
||||
autoComplete="new-password"
|
||||
required
|
||||
minLength={8}
|
||||
autoFocus
|
||||
hint={t("8 caractères minimum.")}
|
||||
value={password}
|
||||
onChange={(event) => setPassword(event.target.value)}
|
||||
/>
|
||||
<Input
|
||||
label={t("Confirmation")}
|
||||
type="password"
|
||||
autoComplete="new-password"
|
||||
required
|
||||
minLength={8}
|
||||
value={confirm}
|
||||
onChange={(event) => setConfirm(event.target.value)}
|
||||
/>
|
||||
{error ? <Alert>{error}</Alert> : null}
|
||||
<Button type="submit" size="lg" fullWidth isLoading={busy}>
|
||||
{t("Réinitialiser")}
|
||||
</Button>
|
||||
</form>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { useState, type FormEvent } from "react";
|
||||
import { Button, Input, Spinner } from "../ui/index.js";
|
||||
import { Input, Spinner } from "../ui/index.js";
|
||||
import { ApiError, api, formatBytes, type Folder, type UploadedFile } from "../lib/api.js";
|
||||
import { Alert, EmptyState, PageHeader } from "../components/feedback.js";
|
||||
import { IconAction } from "../components/IconAction.js";
|
||||
import { DownloadIcon, FileIcon, FolderIcon, SearchIcon } from "../components/icons.js";
|
||||
import { useI18n } from "../lib/i18n.js";
|
||||
|
||||
@@ -56,14 +57,16 @@ export const Search = () => {
|
||||
onChange={(event) => setQ(event.target.value)}
|
||||
/>
|
||||
</div>
|
||||
<Button
|
||||
type="submit"
|
||||
size="md"
|
||||
<IconAction
|
||||
label={t("Rechercher")}
|
||||
icon={<SearchIcon className="h-4 w-4" />}
|
||||
isLoading={loading}
|
||||
iconLeading={<SearchIcon className="h-3.5 w-3.5" />}
|
||||
>
|
||||
{t("Rechercher")}
|
||||
</Button>
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
const form = e.currentTarget.closest('form');
|
||||
form?.requestSubmit();
|
||||
}}
|
||||
/>
|
||||
</form>
|
||||
}
|
||||
/>
|
||||
@@ -87,7 +90,7 @@ export const Search = () => {
|
||||
<h2 className="mb-2 font-display text-[0.6875rem] font-semibold uppercase tracking-label text-subtle-foreground">
|
||||
{t("Dossiers")}
|
||||
</h2>
|
||||
<ul className="flex flex-col divide-y divide-border rounded-lg border border-border bg-surface">
|
||||
<ul className="flex flex-col divide-y divide-border rounded-xl border border-border/50 bg-surface/60 backdrop-blur-md">
|
||||
{results.folders.map((folder) => (
|
||||
<li key={folder.id} className="flex items-center gap-3 px-3 py-2.5">
|
||||
<span className="shrink-0 text-accent">
|
||||
@@ -107,7 +110,7 @@ export const Search = () => {
|
||||
<h2 className="mb-2 font-display text-[0.6875rem] font-semibold uppercase tracking-label text-subtle-foreground">
|
||||
{t("Fichiers")}
|
||||
</h2>
|
||||
<ul className="flex flex-col divide-y divide-border rounded-lg border border-border bg-surface">
|
||||
<ul className="flex flex-col divide-y divide-border rounded-xl border border-border/50 bg-surface/60 backdrop-blur-md">
|
||||
{results.files.map((file) => (
|
||||
<li key={file.id} className="flex items-center gap-3 px-3 py-2.5">
|
||||
<span className="shrink-0 text-muted-foreground">
|
||||
|
||||
@@ -121,7 +121,7 @@ export const Trash = () => {
|
||||
<h2 className="mb-2 font-display text-[0.6875rem] font-semibold uppercase tracking-label text-subtle-foreground">
|
||||
{t("Dossiers")}
|
||||
</h2>
|
||||
<ul className="flex flex-col divide-y divide-border rounded-lg border border-border bg-surface">
|
||||
<ul className="flex flex-col divide-y divide-border rounded-xl border border-border/50 bg-surface/60 backdrop-blur-md">
|
||||
{data.folders.map((folder) => (
|
||||
<li key={folder.id} className="flex items-center gap-3 px-3 py-2.5">
|
||||
<span className="shrink-0 text-accent">
|
||||
@@ -165,7 +165,7 @@ export const Trash = () => {
|
||||
<h2 className="mb-2 font-display text-[0.6875rem] font-semibold uppercase tracking-label text-subtle-foreground">
|
||||
{t("Fichiers")}
|
||||
</h2>
|
||||
<ul className="flex flex-col divide-y divide-border rounded-lg border border-border bg-surface">
|
||||
<ul className="flex flex-col divide-y divide-border rounded-xl border border-border/50 bg-surface/60 backdrop-blur-md">
|
||||
{data.files.map((file) => (
|
||||
<li key={file.id} className="flex items-center gap-3 px-3 py-2.5">
|
||||
<span className="shrink-0 text-muted-foreground">
|
||||
|
||||
@@ -5,8 +5,8 @@ import type { SpinnerSize } from "./Spinner.js";
|
||||
|
||||
const variantClasses = {
|
||||
primary: "bg-primary text-primary-foreground hover:bg-primary-hover",
|
||||
secondary: "border border-border-strong bg-surface text-foreground hover:bg-surface-hover",
|
||||
ghost: "text-foreground hover:bg-surface-hover",
|
||||
secondary: "rounded-lg border border-border-strong bg-surface/60 text-foreground backdrop-blur-sm transition-all hover:-translate-y-0.5 hover:bg-surface/80 hover:shadow-md",
|
||||
ghost: "rounded-lg text-foreground transition-all hover:-translate-y-0.5 hover:bg-surface/50 hover:shadow-sm",
|
||||
destructive: "bg-destructive text-destructive-foreground hover:bg-destructive-hover",
|
||||
} as const;
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@ import { cn } from "../lib/cn.js";
|
||||
export const Card = ({ className, ...props }: HTMLAttributes<HTMLDivElement>) => (
|
||||
<div
|
||||
className={cn(
|
||||
"relative overflow-hidden rounded-lg border border-border bg-surface text-foreground shadow-sm",
|
||||
"transition-colors duration-base ease-out-soft",
|
||||
"relative overflow-hidden rounded-xl border border-border/50 bg-surface/60 text-foreground shadow-sm backdrop-blur-md",
|
||||
"transition-all duration-base ease-out-soft hover:-translate-y-1 hover:shadow-lg",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
|
||||
@@ -47,7 +47,7 @@ export const Input = ({
|
||||
aria-invalid={isInvalid}
|
||||
aria-describedby={isInvalid || hint ? messageId : undefined}
|
||||
className={cn(
|
||||
"w-full rounded-sm border bg-surface text-foreground placeholder:text-subtle-foreground",
|
||||
"w-full rounded-lg border bg-surface/60 text-foreground placeholder:text-subtle-foreground backdrop-blur-sm",
|
||||
"transition-[background-color,border-color,box-shadow] duration-fast ease-out-soft",
|
||||
"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",
|
||||
"disabled:cursor-not-allowed disabled:bg-surface-muted disabled:opacity-60",
|
||||
|
||||
@@ -47,12 +47,14 @@
|
||||
"react": "^19.3.0",
|
||||
"react-dom": "^19.3.0",
|
||||
"react-router-dom": "^7.18.4",
|
||||
"tailwind-merge": "^3.7.0"
|
||||
"tailwind-merge": "^3.7.0",
|
||||
"three": "^0.187.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tailwindcss/vite": "^4.3.3",
|
||||
"@types/react": "^19.3.0",
|
||||
"@types/react-dom": "^19.3.0",
|
||||
"@types/three": "^0.187.0",
|
||||
"@vitejs/plugin-react": "^6.1.1",
|
||||
"tailwindcss": "^4.3.3",
|
||||
"typescript": "^7.0.2",
|
||||
@@ -67,6 +69,13 @@
|
||||
"resolved": "frontend",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@dimforge/rapier3d-compat": {
|
||||
"version": "0.12.0",
|
||||
"resolved": "https://registry.npmjs.org/@dimforge/rapier3d-compat/-/rapier3d-compat-0.12.0.tgz",
|
||||
"integrity": "sha512-uekIGetywIgopfD97oDL5PfeezkFpNhwlzlaEYNOA0N6ghdsOvh/HYjSMek5Q2O1PYvRSDFcqFVJl4r4ZBwOow==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0"
|
||||
},
|
||||
"node_modules/@emnapi/runtime": {
|
||||
"version": "1.11.3",
|
||||
"resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.11.3.tgz",
|
||||
@@ -1183,6 +1192,13 @@
|
||||
"vite": "^5.2.0 || ^6 || ^7 || ^8"
|
||||
}
|
||||
},
|
||||
"node_modules/@tweenjs/tween.js": {
|
||||
"version": "23.1.3",
|
||||
"resolved": "https://registry.npmjs.org/@tweenjs/tween.js/-/tween.js-23.1.3.tgz",
|
||||
"integrity": "sha512-vJmvvwFxYuGnF2axRtPYocag6Clbb5YS7kLL+SO/TeVFzHqDIWrNKYtcsPMibjDx9O+bu+psAy9NKfWklassUA==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "24.19.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.19.2.tgz",
|
||||
@@ -1222,6 +1238,35 @@
|
||||
"@types/react": "^19.3.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/stats.js": {
|
||||
"version": "0.17.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/stats.js/-/stats.js-0.17.4.tgz",
|
||||
"integrity": "sha512-jIBvWWShCvlBqBNIZt0KAshWpvSjhkwkEu4ZUcASoAvhmrgAUI2t1dXrjSL4xXVLB4FznPrIsX3nKXFl/Dt4vA==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/three": {
|
||||
"version": "0.187.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/three/-/three-0.187.0.tgz",
|
||||
"integrity": "sha512-v+vKNarUtk4n2QRZ4+CN5ygMM0ARUjXjIQl0R/unMUfmStFeVqGbgqarbrpoGTXRZoulSH16ePrVJVxPJEbMUA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@dimforge/rapier3d-compat": "~0.12.0",
|
||||
"@tweenjs/tween.js": "~23.1.3",
|
||||
"@types/stats.js": "*",
|
||||
"@types/webxr": ">=0.5.17",
|
||||
"fflate": "~0.8.3",
|
||||
"meshoptimizer": "~1.1.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/webxr": {
|
||||
"version": "0.5.24",
|
||||
"resolved": "https://registry.npmjs.org/@types/webxr/-/webxr-0.5.24.tgz",
|
||||
"integrity": "sha512-h8fgEd/DpoS9CBrjEQXR+dIDraopAEfu4wYVNY2tEPwk60stPWhvZMf4Foo5FakuQ7HFZoa8WceaWFervK2Ovg==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@typescript/typescript-aix-ppc64": {
|
||||
"version": "7.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@typescript/typescript-aix-ppc64/-/typescript-aix-ppc64-7.0.2.tgz",
|
||||
@@ -1671,6 +1716,13 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/fflate": {
|
||||
"version": "0.8.3",
|
||||
"resolved": "https://registry.npmjs.org/fflate/-/fflate-0.8.3.tgz",
|
||||
"integrity": "sha512-tbZNuJrLwGUp3zshBtdy4W+ORxZuIh8a5ilyIEQDC5rY1f3U20JMry0Ll3WBzU58EZKsEuJFXhb5gwv8CsPvgA==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/fsevents": {
|
||||
"version": "2.3.3",
|
||||
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
|
||||
@@ -2035,6 +2087,13 @@
|
||||
"@jridgewell/sourcemap-codec": "^1.5.5"
|
||||
}
|
||||
},
|
||||
"node_modules/meshoptimizer": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/meshoptimizer/-/meshoptimizer-1.1.1.tgz",
|
||||
"integrity": "sha512-oRFNWJRDA/WTrVj7NWvqa5HqE1t9MYDj2VaWirQCzCCrAd2GHrqR/sQezCxiWATPNlKTcRaPRHPJwIRoPBAp5g==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/mysql2": {
|
||||
"version": "3.24.6",
|
||||
"resolved": "https://registry.npmjs.org/mysql2/-/mysql2-3.24.6.tgz",
|
||||
@@ -2373,6 +2432,12 @@
|
||||
"url": "https://opencollective.com/webpack"
|
||||
}
|
||||
},
|
||||
"node_modules/three": {
|
||||
"version": "0.187.0",
|
||||
"resolved": "https://registry.npmjs.org/three/-/three-0.187.0.tgz",
|
||||
"integrity": "sha512-Qiu7R+Cmh8CstZsY1uJOSWnVlfo7ZtNLV7mF8Jltk3LB3AtDu9cRZlcnRKkAk8Y4z6KKw35z7Y7Urd7jWY8etA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/tinyglobby": {
|
||||
"version": "0.2.17",
|
||||
"resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz",
|
||||
|
||||