Files
immich-redaktions-plugin/src/app/admin/redaktionen/[id]/auto-regeln/page.tsx
T
Leon TonhäuserandClaude Opus 5.5 9e938e4d07 feat: redesign portal UI with Sakani UI and add release notes
Replace the hand-rolled Tailwind/shadcn look with Sakani UI across the
editorial area, the admin area and all signed-out pages.

- AppShell (Sakani Sidebar + TopBar) for /redaktion and /admin, with a
  mobile drawer, theme toggle, sign-out, legal links and a "Was ist neu"
  button; PublicShell for login, registration, password, 2FA and errors.
- Shared primitives (Button, Card, Input, PageHeader) now render Sakani;
  components/ui/sakani.tsx is the client boundary for Server Components
  (Sakani ships no "use client") and adds FormSelect (native form value)
  and DataTable (element cells from the server).
- Legacy CSS variables map onto Sakani tokens; globals.css shrinks from
  ~2200 to ~700 lines. Geist replaces Inter. recharts/lucide-react dropped
  (charts via Sakani BarChart).
- Release notes popup per area, shown once per version (localStorage) and
  reopenable from the sidebar; native <dialog> for focus trapping.
- Fixes found while testing: TOTP field reused the typed password in
  clear text, modal dialogs sat top-left, invisible unchecked checkboxes
  in dark mode.
- Parallel run: compose.parallel.yaml, AUTO_RULE_SYNC_DISABLED switch and
  docs/operations.md §8 (start, rollback, cutover).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 18:24:05 +01:00

109 lines
4.3 KiB
TypeScript

import Link from "next/link";
import { IconPlayerPlay, IconPlus, IconTrash } from "@sakaniui/react/icons";
import { notFound } from "next/navigation";
import { autoRuleService } from "@/modules/albums/auto-rules";
import { db } from "@/db/client";
import { editorialAccounts } from "@/db/schema";
import { eq } from "drizzle-orm";
import { Button } from "@/components/ui/button";
import { EmptyState, Input } from "@/components/ui/sakani";
import { Card, CardContent, CardHeader, CardTitle, CardDescription } from "@/components/ui/card";
import { PageHeader } from "@/components/ui/page-header";
import { requireAdminPage } from "../../../access";
import { applyAutoRulesAction, createAutoRuleAction, deleteAutoRuleAction } from "./actions";
type AutoRulesPageProps = Readonly<{
params: Promise<{ id: string }>;
}>;
export default async function AutoRulesPage({ params }: AutoRulesPageProps) {
await requireAdminPage();
const { id } = await params;
const [editorial] = await db
.select()
.from(editorialAccounts)
.where(eq(editorialAccounts.id, id));
if (!editorial) {
notFound();
}
const rules = await autoRuleService.listRules(id);
return (
<section className="flex max-w-4xl flex-col gap-6">
<PageHeader kicker="Redaktion · Auto-Zuweisungsregeln" title={`Auto-Regeln für ${editorial.name}`}>
<Button asChild variant="outline">
<Link href={`/admin/redaktionen/${editorial.id}/alben`}>Zurück zur Album-Verwaltung</Link>
</Button>
</PageHeader>
<div className="grid gap-6">
<Card>
<CardHeader>
<CardTitle>Neue Regel hinzufügen</CardTitle>
<CardDescription>
Alben, deren Name eines der folgenden Schlüsselwörter enthält, werden dieser Redaktion automatisch zugewiesen, sobald sie von Immich synchronisiert werden.
</CardDescription>
</CardHeader>
<CardContent>
<form action={createAutoRuleAction.bind(null, editorial.id)} className="flex flex-col gap-4 sm:flex-row sm:items-end">
<div className="w-full max-w-md">
<Input label="Schlüsselwort" name="keyword" placeholder="z.B. FC Bayern" required type="text" />
</div>
<Button type="submit" leftIcon={<IconPlus size={16} />}>
Regel hinzufügen
</Button>
</form>
</CardContent>
</Card>
<Card>
<CardHeader>
<div className="flex flex-wrap items-start justify-between gap-4">
<div>
<CardTitle>Bestehende Regeln</CardTitle>
<CardDescription>
Alle derzeit aktiven automatischen Zuweisungen.
</CardDescription>
</div>
<form action={applyAutoRulesAction.bind(null, editorial.id)}>
<Button type="submit" variant="secondary" leftIcon={<IconPlayerPlay size={16} />}>
Regeln jetzt anwenden
</Button>
</form>
</div>
</CardHeader>
<CardContent>
{rules.length === 0 ? (
<EmptyState title="Noch keine Auto-Regeln angelegt." description="Legen Sie oben ein Schlüsselwort an." />
) : (
<ul className="divide-y divide-[var(--color-border-subtle)] rounded-[var(--radius-md)] border border-[var(--color-border-subtle)]">
{rules.map((rule) => (
<li key={rule.id} className="flex items-center justify-between p-4">
<div className="flex flex-col">
<span className="font-medium">{rule.keyword}</span>
<span className="mt-1 text-xs text-[var(--color-fg-muted)]">
Erstellt am {new Date(rule.createdAt).toLocaleDateString('de-DE')}
</span>
</div>
<form action={deleteAutoRuleAction.bind(null, editorial.id, rule.id)}>
<Button type="submit" variant="ghost" size="sm" leftIcon={<IconTrash size={16} />}>
Entfernen
</Button>
</form>
</li>
))}
</ul>
)}
</CardContent>
</Card>
</div>
</section>
);
}