The database moved to a container of our own; the platform is gone. This takes out what was left of it — and, where the leftovers were load bearing, moves rather than deletes. Moved, not deleted: supabase/migrations/ -> db/migrations/ the schema's source of truth supabase/build-org.ts -> scripts/build-org.ts lib/supabase/types.ts -> lib/types.ts 52 import sites repointed The bookkeeping needed care. It lived in `supabase_migrations.schema_migrations`, and simply renaming the schema would have left the runner facing an empty table: it would have called all 67 migrations pending and replayed them against a database that is long since current. So the runner now creates `migrationen.schema_migrations` and, once, copies the old rows across — guarded so a second run does nothing and a fresh database skips it entirely. Only then does migration 20260907100000 drop the old schema. Deleted: the CLI config, the seed, the historical schema/function dumps (nothing read them), scripts/umzug-von-supabase.sh (the move is done), and both Supabase packages plus the CLI. Nothing in the application imported them — the build now succeeds with no environment variables at all, which is the proof. Integration tests: six of them signed in through Supabase Auth and asserted against the anon key and the service role. That model is gone, so the tests were not portable — they are deleted. session-context and employee-status-filter already ran on pg and are untouched; om-reporting is ported to a direct connection because it guards a real risk (the reporting line rule exists twice, once in SQL and once in TypeScript). CI: the integration job started a Supabase stack. It now runs a postgres service, applies deploy/db-init and every migration to an empty database — that was the valuable part, and it still holds — then checks that a second run is a no-op, which is what proves the bookkeeping works. Docs: security-review.md audited a service-role key, a cookie adapter and auth.users, none of which exist. Restating findings about removed components would suggest today's system had been reviewed; it has not. It now records what was removed and says a fresh review is due. data-model.md was already marked obsolete and described the pre-OM schema; azure-migration.md was a plan for a route not taken. Both deleted. Verified: npm ci, typecheck, lint, 445 tests, build — all clean without the packages. Integration tests skip cleanly with no database. Migration SQL and the runner are reviewed but NOT executed: no Docker here, and the old instance no longer resolves. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
113 lines
4.1 KiB
TypeScript
113 lines
4.1 KiB
TypeScript
"use client";
|
||
|
||
import Link from "next/link";
|
||
import { useState } from "react";
|
||
import { AenderungsTabelle } from "@/components/ui/AenderungsTabelle";
|
||
import { SlideOver } from "@/components/ui/SlideOver";
|
||
import { actionBadgeStyle } from "@/lib/colors";
|
||
import type { AuditChange } from "@/lib/types";
|
||
|
||
// Eine Protokollzeile zum Aufklappen.
|
||
//
|
||
// Die Liste zeigt, *dass* etwas geändert wurde; hier steht, *was*. Beides in
|
||
// der Tabelle unterzubringen ginge nicht — bei sieben geänderten Feldern
|
||
// wäre die Zeile höher als der Bildschirm.
|
||
|
||
export type AuditEintrag = {
|
||
id: string;
|
||
occurred_at: string;
|
||
actor_name: string;
|
||
action: string;
|
||
target_label: string;
|
||
target_employee_id: string | null;
|
||
details: string | null;
|
||
changes: AuditChange[] | null;
|
||
};
|
||
|
||
const zeitFormat = new Intl.DateTimeFormat("de-AT", {
|
||
day: "2-digit",
|
||
month: "2-digit",
|
||
year: "numeric",
|
||
hour: "2-digit",
|
||
minute: "2-digit",
|
||
second: "2-digit",
|
||
timeZone: "Europe/Vienna",
|
||
});
|
||
|
||
export function AuditDetail({ eintrag }: { eintrag: AuditEintrag }) {
|
||
const [offen, setOffen] = useState(false);
|
||
const anzahl = eintrag.changes?.length ?? 0;
|
||
|
||
return (
|
||
<>
|
||
<button
|
||
type="button"
|
||
onClick={() => setOffen(true)}
|
||
aria-haspopup="dialog"
|
||
className="w-full rounded px-2 py-1 text-left text-ink-muted hover:bg-brand-50 hover:text-ink
|
||
focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand-500"
|
||
>
|
||
<span>{eintrag.details ?? "–"}</span>
|
||
{anzahl > 0 && (
|
||
<span className="ml-2 whitespace-nowrap rounded-full bg-brand-50 px-2 py-0.5 text-[11px] font-semibold text-brand-700">
|
||
{anzahl} {anzahl === 1 ? "Feld" : "Felder"}
|
||
</span>
|
||
)}
|
||
</button>
|
||
|
||
<SlideOver
|
||
open={offen}
|
||
onClose={() => setOffen(false)}
|
||
title={eintrag.target_label}
|
||
subtitle={`${eintrag.action} · ${zeitFormat.format(new Date(eintrag.occurred_at))}`}
|
||
>
|
||
<dl className="grid grid-cols-[auto_1fr] gap-x-6 gap-y-2 text-sm">
|
||
<dt className="font-semibold text-ink-muted">Aktion</dt>
|
||
<dd>
|
||
<span className={`rounded-full px-2 py-0.5 text-[11px] font-semibold ${actionBadgeStyle(eintrag.action)}`}>
|
||
{eintrag.action}
|
||
</span>
|
||
</dd>
|
||
<dt className="font-semibold text-ink-muted">Benutzer:in</dt>
|
||
<dd className="text-ink">{eintrag.actor_name}</dd>
|
||
<dt className="font-semibold text-ink-muted">Zeitpunkt</dt>
|
||
<dd className="tabular-nums text-ink">{zeitFormat.format(new Date(eintrag.occurred_at))}</dd>
|
||
{eintrag.target_employee_id && (
|
||
<>
|
||
<dt className="font-semibold text-ink-muted">Objekt</dt>
|
||
<dd>
|
||
<Link
|
||
href={`/employees/${eintrag.target_employee_id}`}
|
||
className="rounded font-semibold text-brand-700 hover:underline
|
||
focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand-500"
|
||
>
|
||
{eintrag.target_label}
|
||
</Link>
|
||
</dd>
|
||
</>
|
||
)}
|
||
</dl>
|
||
|
||
{eintrag.details && (
|
||
<p className="mt-5 rounded-md bg-surface px-3 py-2 text-sm text-ink-body">{eintrag.details}</p>
|
||
)}
|
||
|
||
<h3 className="mt-6 text-sm font-bold text-ink">Geänderte Felder</h3>
|
||
{anzahl > 0 ? (
|
||
<div className="mt-2">
|
||
<AenderungsTabelle changes={eintrag.changes!} />
|
||
</div>
|
||
) : (
|
||
// Kein Aufzählungszeichen für „nichts da“: der Grund ist wichtig,
|
||
// damit niemand einen Fehler vermutet.
|
||
<p className="mt-2 max-w-prose text-sm text-ink-muted">
|
||
Für diesen Eintrag liegen keine Feldwerte vor. Vorgänge wie Eintritt, Austritt oder Import erfassen keine
|
||
Einzelfelder — und Einträge von vor der Erweiterung des Protokolls haben nur die Feldnamen behalten, nicht
|
||
die Werte. Nachliefern lässt sich das nicht.
|
||
</p>
|
||
)}
|
||
</SlideOver>
|
||
</>
|
||
);
|
||
}
|