Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
+262
@@ -0,0 +1,262 @@
|
||||
// AK-P21 Interim-UI (AD-28) — AVV (data processing agreement) page (D-P21
|
||||
// pending). Current version card + acceptance history table + re-acceptance
|
||||
// dialog (S 560). The PDF download is interim-disabled because no AVV source
|
||||
// PDF ships in the repo yet — the button stays visible with a plain-language
|
||||
// interim hint so David's final D-P21 delta only swaps optics, not flow.
|
||||
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { PrivacyBreadcrumbs } from "./PrivacyBreadcrumbs";
|
||||
import { FeatherDownload, FeatherFileText } from "@subframe/core";
|
||||
import type { AvvVM } from "@hivegrid/view-models";
|
||||
import { useLocaleFormatters } from "~/locale/format";
|
||||
import { Alert } from "~/ui/components/Alert";
|
||||
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { Card } from "~/ui/components/Card";
|
||||
import { PageIntro } from "../shared/PageShell";
|
||||
import { Dialog } from "~/ui/components/Dialog";
|
||||
import { EmptyState } from "~/ui/components/EmptyState";
|
||||
import { Loader } from "~/ui/components/Loader";
|
||||
import { Table } from "~/ui/components/Table";
|
||||
import { TextInput } from "~/ui/components/TextInput";
|
||||
|
||||
export type AvvActions = {
|
||||
readonly onAccept: (fields: { signerName: string; signerRole: string }) => void | Promise<void>;
|
||||
readonly onRetry: () => void;
|
||||
};
|
||||
|
||||
export function AvvPage({
|
||||
vm,
|
||||
actions,
|
||||
hubHref,
|
||||
embedded = false,
|
||||
submitting = false,
|
||||
errorKey = null,
|
||||
}: {
|
||||
vm: AvvVM;
|
||||
actions: AvvActions;
|
||||
hubHref: string;
|
||||
/** Inside the Compliance hub (AK-SET-01) the hub owns breadcrumb and heading. */
|
||||
embedded?: boolean;
|
||||
submitting?: boolean;
|
||||
errorKey?: string | null;
|
||||
}): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
const formatters = useLocaleFormatters();
|
||||
const [acceptOpen, setAcceptOpen] = useState(false);
|
||||
const [signerName, setSignerName] = useState("");
|
||||
const [signerRole, setSignerRole] = useState("");
|
||||
const [accepting, setAccepting] = useState(false);
|
||||
|
||||
if (vm.status === "idle" || vm.status === "loading") {
|
||||
return (
|
||||
<div className="flex w-full flex-col items-start gap-6 px-6 py-6" data-ui-id="ui.settings.privacy.avv.loading">
|
||||
<Card>
|
||||
<div className="flex w-full items-center gap-3">
|
||||
<Loader />
|
||||
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">
|
||||
{t("settings.privacy.states.loadingDescription")}
|
||||
</span>
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (vm.status === "error") {
|
||||
return (
|
||||
<div className="flex w-full flex-col items-start gap-6 px-6 py-6" data-ui-id="ui.settings.privacy.avv.error">
|
||||
<EmptyState
|
||||
outlined
|
||||
variant="error"
|
||||
title={t("settings.privacy.states.errorTitle")}
|
||||
body={t(vm.error.messageKey)}
|
||||
action={
|
||||
<Button variant="tertiary" onClick={actions.onRetry} data-ui-id="ui.settings.privacy.avv.retry">
|
||||
{t("settings.privacy.states.retry")}
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (vm.status === "empty") {
|
||||
return (
|
||||
<div className="flex w-full flex-col items-start gap-6 px-6 py-6" data-ui-id="ui.settings.privacy.avv.empty">
|
||||
<EmptyState outlined title={t("settings.privacy.states.errorTitle")} body={t("settings.privacy.states.loadingDescription")} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const { data } = vm;
|
||||
|
||||
async function confirmAccept(): Promise<void> {
|
||||
setAccepting(true);
|
||||
try {
|
||||
await actions.onAccept({ signerName: signerName.trim(), signerRole: signerRole.trim() });
|
||||
setAcceptOpen(false);
|
||||
setSignerName("");
|
||||
setSignerRole("");
|
||||
} finally {
|
||||
setAccepting(false);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="bg-surface-neutral-primary flex w-full flex-col items-start" data-ui-id="ui.settings.privacy.avv.page">
|
||||
{embedded ? null : (
|
||||
<div className="border-border-default bg-surface-neutral-secondary mobile:px-4 flex w-full flex-col items-start border-b border-solid px-6 py-6">
|
||||
<PrivacyBreadcrumbs hubHref={hubHref} titleKey="settings.privacy.avv.title" />
|
||||
<h1 className="text-heading- font-heading- text-text-neutral-primary">{t("settings.privacy.avv.title")}</h1>
|
||||
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-tertiary">
|
||||
{t("settings.privacy.avv.description")}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Full content width: the cards were capped at 720px, which left the
|
||||
screen looking like a narrow column with two thirds of the page empty. */}
|
||||
<div className="mobile:px-4 flex w-full flex-col items-start gap-6 px-6 py-6">
|
||||
{embedded ? <PageIntro uiId="ui.settings.privacy.avv.intro">{t("settings.privacy.avv.description")}</PageIntro> : null}
|
||||
{data.needsReacceptance ? (
|
||||
<Alert
|
||||
notDismissible
|
||||
variant="warning"
|
||||
title={t("settings.privacy.avv.reaccept.noticeTitle", { version: data.currentVersion })}
|
||||
description={t("settings.privacy.avv.reaccept.noticeDescription")}
|
||||
/>
|
||||
) : null}
|
||||
{errorKey ? <Alert variant="error" title={t(errorKey)} /> : null}
|
||||
|
||||
<Card data-ui-id="ui.settings.privacy.avv.current">
|
||||
<div className="mobile:flex-col mobile:items-stretch flex w-full items-center gap-4">
|
||||
<div className="border-border-default bg-surface-neutral-tertiary flex h-12 w-12 flex-none items-center justify-center rounded-md border border-solid">
|
||||
<FeatherFileText className="text-heading- font-heading- text-icon-neutral-tertiary" />
|
||||
</div>
|
||||
<div className="flex grow shrink-0 basis-0 flex-col items-start gap-1">
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">
|
||||
{t("settings.privacy.avv.current.title", { version: data.currentVersion })}
|
||||
</span>
|
||||
<BadgeFeedback farbe={data.currentAccepted ? "subtle-positive" : "subtle-warning"} size="small">
|
||||
{data.currentAccepted ? t("settings.privacy.avv.current.acceptedBadge") : t("settings.privacy.avv.current.openBadge")}
|
||||
</BadgeFeedback>
|
||||
</div>
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">
|
||||
{data.pdfAvailable ? t("settings.privacy.avv.current.pdfHint") : t("settings.privacy.avv.current.pdfUnavailableHint")}
|
||||
</span>
|
||||
</div>
|
||||
<div className="mobile:w-full mobile:flex-col flex items-center gap-2">
|
||||
<Button
|
||||
className="mobile:w-full"
|
||||
variant="secondary"
|
||||
icon={<FeatherDownload />}
|
||||
disabled={!data.pdfAvailable}
|
||||
data-ui-id="ui.settings.privacy.avv.pdfDownload"
|
||||
>
|
||||
{t("settings.privacy.avv.pdfDownload")}
|
||||
</Button>
|
||||
{!data.currentAccepted ? (
|
||||
<Button className="mobile:w-full" onClick={() => setAcceptOpen(true)} data-ui-id="ui.settings.privacy.avv.accept">
|
||||
{t("settings.privacy.avv.reaccept.cta")}
|
||||
</Button>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
<Card data-ui-id="ui.settings.privacy.avv.history">
|
||||
<div className="flex w-full flex-col items-start">
|
||||
<span className="text-body-large font-body-large text-text-neutral-primary">{t("settings.privacy.avv.history.title")}</span>
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">
|
||||
{t("settings.privacy.avv.history.description")}
|
||||
</span>
|
||||
</div>
|
||||
{data.acceptances.length === 0 ? (
|
||||
<EmptyState title={t("settings.privacy.avv.history.emptyTitle")} body={t("settings.privacy.avv.history.emptyDescription")} />
|
||||
) : (
|
||||
<div className="w-full overflow-x-auto">
|
||||
<Table
|
||||
header={
|
||||
<Table.HeaderRow>
|
||||
<Table.HeaderCell>{t("settings.privacy.avv.columns.version")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("settings.privacy.avv.columns.date")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("settings.privacy.avv.columns.signer")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("settings.privacy.avv.columns.role")}</Table.HeaderCell>
|
||||
</Table.HeaderRow>
|
||||
}
|
||||
>
|
||||
{data.acceptances.map((acceptance) => (
|
||||
<Table.Row key={acceptance.id}>
|
||||
<Table.Cell>
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-primary">{acceptance.avvVersion}</span>
|
||||
{acceptance.isCurrentVersion ? (
|
||||
<BadgeFeedback farbe="subtle-positive" size="small">
|
||||
{t("settings.privacy.avv.currentBadge")}
|
||||
</BadgeFeedback>
|
||||
) : null}
|
||||
</div>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-secondary">
|
||||
{formatters.date(acceptance.createdAt, { dateStyle: "medium", timeStyle: "short" })}
|
||||
</span>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-secondary">{acceptance.signerName}</span>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary">{acceptance.signerRole ?? "—"}</span>
|
||||
</Table.Cell>
|
||||
</Table.Row>
|
||||
))}
|
||||
</Table>
|
||||
</div>
|
||||
)}
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
<Dialog open={acceptOpen} onOpenChange={(open: boolean) => (open ? undefined : setAcceptOpen(false))}>
|
||||
<Dialog.Content
|
||||
className="w-[560px] max-w-[90vw] p-4"
|
||||
aria-label={t("settings.privacy.avv.reaccept.title")}
|
||||
data-ui-id="ui.settings.privacy.avv.acceptDialog"
|
||||
>
|
||||
<div className="flex w-full flex-col items-start gap-2">
|
||||
<span className="text-heading-0 font-heading-0 text-text-neutral-primary">
|
||||
{t("settings.privacy.avv.reaccept.title", { version: data.currentVersion })}
|
||||
</span>
|
||||
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
|
||||
{t("settings.privacy.avv.reaccept.description")}
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex w-full flex-col items-start gap-4 pt-4">
|
||||
<TextInput className="w-full" label={t("settings.privacy.avv.reaccept.signerNameLabel")} showLabel>
|
||||
<TextInput.Input value={signerName} onChange={(event) => setSignerName(event.target.value)} required />
|
||||
</TextInput>
|
||||
<TextInput className="w-full" label={t("settings.privacy.avv.reaccept.signerRoleLabel")} showLabel>
|
||||
<TextInput.Input value={signerRole} onChange={(event) => setSignerRole(event.target.value)} />
|
||||
</TextInput>
|
||||
</div>
|
||||
<div className="flex w-full items-center justify-end gap-2 pt-4">
|
||||
<Button variant="tertiary" disabled={accepting || submitting} onClick={() => setAcceptOpen(false)}>
|
||||
{t("shared.cancel")}
|
||||
</Button>
|
||||
<Button
|
||||
loading={accepting || submitting}
|
||||
disabled={signerName.trim().length === 0}
|
||||
onClick={() => void confirmAccept()}
|
||||
data-ui-id="ui.settings.privacy.avv.acceptConfirm"
|
||||
>
|
||||
{t("settings.privacy.avv.reaccept.confirm")}
|
||||
</Button>
|
||||
</div>
|
||||
</Dialog.Content>
|
||||
</Dialog>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
+319
@@ -0,0 +1,319 @@
|
||||
// AK-P21 Interim-UI (AD-28) — tenant/user GDPR export job list (D-P21 pending).
|
||||
// Composition follows the billing interim canon (SubscriptionOverviewPage):
|
||||
// VMState early returns, header block, Card + Table, real ~/ui Dialog for the
|
||||
// start action. Final Subframe optics land as a tracked design-nachzug.
|
||||
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { PrivacyBreadcrumbs } from "./PrivacyBreadcrumbs";
|
||||
import { FeatherDownload, FeatherPlus } from "@subframe/core";
|
||||
import type { GdprExportJobVM, GdprExportJobsVM, GdprExportScopeVM } from "@hivegrid/view-models";
|
||||
import { useLocaleFormatters } from "~/locale/format";
|
||||
import { Alert } from "~/ui/components/Alert";
|
||||
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { Card } from "~/ui/components/Card";
|
||||
import { Dialog } from "~/ui/components/Dialog";
|
||||
import { EmptyState } from "~/ui/components/EmptyState";
|
||||
import { Loader } from "~/ui/components/Loader";
|
||||
import { Progress } from "~/ui/components/Progress";
|
||||
import { Table } from "~/ui/components/Table";
|
||||
|
||||
export type GdprExportJobsActions = {
|
||||
readonly onStart: (scope: GdprExportScopeVM) => void | Promise<void>;
|
||||
readonly onDownload: (jobId: string) => void;
|
||||
readonly onRetry: () => void;
|
||||
};
|
||||
|
||||
function jobTone(tone: GdprExportJobVM["tone"]): React.ComponentProps<typeof BadgeFeedback>["farbe"] {
|
||||
if (tone === "success") return "subtle-positive";
|
||||
if (tone === "warning") return "subtle-warning";
|
||||
if (tone === "danger") return "subtle-negative";
|
||||
return "subtle-neutral";
|
||||
}
|
||||
|
||||
function formatBytes(bytes: number): string {
|
||||
if (bytes >= 1_073_741_824) return `${(bytes / 1_073_741_824).toFixed(1)} GB`;
|
||||
if (bytes >= 1_048_576) return `${(bytes / 1_048_576).toFixed(1)} MB`;
|
||||
if (bytes >= 1_024) return `${Math.round(bytes / 1_024)} KB`;
|
||||
return `${bytes} B`;
|
||||
}
|
||||
|
||||
type StartDialogState = { open: boolean; scope: GdprExportScopeVM };
|
||||
|
||||
export function GdprExportJobsPage({
|
||||
vm,
|
||||
actions,
|
||||
hubHref,
|
||||
embedded = false,
|
||||
submitting = false,
|
||||
}: {
|
||||
vm: GdprExportJobsVM;
|
||||
actions: GdprExportJobsActions;
|
||||
hubHref: string;
|
||||
/** Inside the Compliance hub (AK-SET-01) the hub owns breadcrumb and heading. */
|
||||
embedded?: boolean;
|
||||
submitting?: boolean;
|
||||
}): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
const formatters = useLocaleFormatters();
|
||||
const [startDialog, setStartDialog] = useState<StartDialogState>({ open: false, scope: "user_self" });
|
||||
const [starting, setStarting] = useState(false);
|
||||
|
||||
if (vm.status === "idle" || vm.status === "loading") {
|
||||
return (
|
||||
<div className="flex w-full flex-col items-start gap-6 px-6 py-6" data-ui-id="ui.settings.privacy.exportJobs.loading">
|
||||
<Card>
|
||||
<div className="flex w-full items-center gap-3">
|
||||
<Loader />
|
||||
<div className="flex flex-col items-start">
|
||||
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">
|
||||
{t("settings.privacy.exportJobs.loading.title")}
|
||||
</span>
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">
|
||||
{t("settings.privacy.states.loadingDescription")}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (vm.status === "error") {
|
||||
return (
|
||||
<div className="flex w-full flex-col items-start gap-6 px-6 py-6" data-ui-id="ui.settings.privacy.exportJobs.error">
|
||||
<EmptyState
|
||||
outlined
|
||||
variant="error"
|
||||
title={t("settings.privacy.states.errorTitle")}
|
||||
body={t(vm.error.messageKey)}
|
||||
action={
|
||||
<Button variant="tertiary" onClick={actions.onRetry} data-ui-id="ui.settings.privacy.exportJobs.retry">
|
||||
{t("settings.privacy.states.retry")}
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
async function startExport(scope: GdprExportScopeVM): Promise<void> {
|
||||
setStarting(true);
|
||||
try {
|
||||
await actions.onStart(scope);
|
||||
setStartDialog((current) => ({ ...current, open: false }));
|
||||
} finally {
|
||||
setStarting(false);
|
||||
}
|
||||
}
|
||||
|
||||
const startDialogElement = (
|
||||
<Dialog open={startDialog.open} onOpenChange={(open: boolean) => (open ? undefined : setStartDialog((current) => ({ ...current, open: false })))}>
|
||||
<Dialog.Content
|
||||
className="w-[560px] max-w-[90vw] p-4"
|
||||
aria-label={t("settings.privacy.exportJobs.startDialog.title")}
|
||||
data-ui-id="ui.settings.privacy.exportJobs.startDialog"
|
||||
>
|
||||
<div className="flex w-full flex-col items-start gap-2">
|
||||
<span className="text-heading-0 font-heading-0 text-text-neutral-primary">{t("settings.privacy.exportJobs.startDialog.title")}</span>
|
||||
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
|
||||
{startDialog.scope === "tenant_full"
|
||||
? t("settings.privacy.exportJobs.startDialog.tenantDescription")
|
||||
: t("settings.privacy.exportJobs.startDialog.userDescription")}
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex w-full flex-col items-start gap-2 pt-4">
|
||||
<Alert
|
||||
notDismissible
|
||||
variant="information"
|
||||
title={t("settings.privacy.exportJobs.startDialog.whatsIncludedTitle")}
|
||||
description={t("settings.privacy.exportJobs.startDialog.whatsIncludedDescription", { hours: 72 })}
|
||||
/>
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">
|
||||
{startDialog.scope === "tenant_full"
|
||||
? t("settings.privacy.exportJobs.startDialog.tenantRateLimitHint")
|
||||
: t("settings.privacy.exportJobs.startDialog.userRateLimitHint", { limit: 3 })}
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex w-full items-center justify-end gap-2 pt-4">
|
||||
<Button variant="tertiary" disabled={starting || submitting} onClick={() => setStartDialog((current) => ({ ...current, open: false }))}>
|
||||
{t("shared.cancel")}
|
||||
</Button>
|
||||
<Button
|
||||
loading={starting || submitting}
|
||||
onClick={() => void startExport(startDialog.scope)}
|
||||
data-ui-id="ui.settings.privacy.exportJobs.startConfirm"
|
||||
>
|
||||
{t("settings.privacy.exportJobs.startDialog.confirm")}
|
||||
</Button>
|
||||
</div>
|
||||
</Dialog.Content>
|
||||
</Dialog>
|
||||
);
|
||||
|
||||
if (vm.status === "empty") {
|
||||
return (
|
||||
<div className="flex w-full flex-col items-start gap-6 px-6 py-6" data-ui-id="ui.settings.privacy.exportJobs.empty">
|
||||
<EmptyState
|
||||
outlined
|
||||
title={t("settings.privacy.exportJobs.empty.title")}
|
||||
body={t("settings.privacy.exportJobs.empty.description")}
|
||||
action={
|
||||
<Button
|
||||
variant="tertiary"
|
||||
icon={<FeatherPlus />}
|
||||
onClick={() => setStartDialog({ open: true, scope: "user_self" })}
|
||||
data-ui-id="ui.settings.privacy.exportJobs.startEmpty"
|
||||
>
|
||||
{t("settings.privacy.exportJobs.startUser")}
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
{startDialogElement}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const { data } = vm;
|
||||
|
||||
return (
|
||||
<div className="bg-surface-neutral-primary flex w-full flex-col items-start" data-ui-id="ui.settings.privacy.exportJobs.page">
|
||||
<div className="border-border-default bg-surface-neutral-secondary mobile:flex-col mobile:px-4 flex w-full items-start justify-between gap-4 border-b border-solid px-6 py-6">
|
||||
<div className="flex flex-col items-start">
|
||||
{embedded ? null : (
|
||||
<>
|
||||
<PrivacyBreadcrumbs hubHref={hubHref} titleKey="settings.privacy.exportJobs.title" />
|
||||
<h1 className="text-heading- font-heading- text-text-neutral-primary">{t("settings.privacy.exportJobs.title")}</h1>
|
||||
</>
|
||||
)}
|
||||
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-tertiary">
|
||||
{t("settings.privacy.exportJobs.description", { hours: data.downloadTtlHours })}
|
||||
</span>
|
||||
</div>
|
||||
<div className="mobile:w-full mobile:flex-col flex items-center gap-2">
|
||||
<Button
|
||||
className="mobile:w-full"
|
||||
variant="secondary"
|
||||
icon={<FeatherPlus />}
|
||||
disabled={!data.canStartUserSelf}
|
||||
onClick={() => setStartDialog({ open: true, scope: "user_self" })}
|
||||
data-ui-id="ui.settings.privacy.exportJobs.startUser"
|
||||
>
|
||||
{t("settings.privacy.exportJobs.startUser")}
|
||||
</Button>
|
||||
{data.tenantExportAllowed ? (
|
||||
<Button
|
||||
className="mobile:w-full"
|
||||
icon={<FeatherPlus />}
|
||||
disabled={!data.canStartTenantFull}
|
||||
onClick={() => setStartDialog({ open: true, scope: "tenant_full" })}
|
||||
data-ui-id="ui.settings.privacy.exportJobs.startTenant"
|
||||
>
|
||||
{t("settings.privacy.exportJobs.startTenant")}
|
||||
</Button>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="mobile:px-4 flex w-full flex-col items-start gap-6 px-6 py-6">
|
||||
{data.tenantFullActive ? (
|
||||
<Alert
|
||||
notDismissible
|
||||
variant="information"
|
||||
title={t("settings.privacy.exportJobs.tenantActive.title")}
|
||||
description={t("settings.privacy.exportJobs.tenantActive.description")}
|
||||
/>
|
||||
) : null}
|
||||
{!data.canStartUserSelf ? (
|
||||
<Alert
|
||||
notDismissible
|
||||
variant="warning"
|
||||
title={t("settings.privacy.exportJobs.rateLimit.title")}
|
||||
description={t("settings.privacy.exportJobs.rateLimit.description", { limit: data.userSelfLimitPer24h })}
|
||||
/>
|
||||
) : null}
|
||||
|
||||
<Card data-ui-id="ui.settings.privacy.exportJobs.list">
|
||||
<div className="flex w-full flex-col items-start">
|
||||
<span className="text-body-large font-body-large text-text-neutral-primary">{t("settings.privacy.exportJobs.list.title")}</span>
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">
|
||||
{t("settings.privacy.exportJobs.list.description")}
|
||||
</span>
|
||||
</div>
|
||||
<div className="w-full overflow-x-auto">
|
||||
<Table
|
||||
header={
|
||||
<Table.HeaderRow>
|
||||
<Table.HeaderCell>{t("settings.privacy.exportJobs.columns.scope")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("settings.privacy.exportJobs.columns.status")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("settings.privacy.exportJobs.columns.progress")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("settings.privacy.exportJobs.columns.created")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("settings.privacy.exportJobs.columns.action")}</Table.HeaderCell>
|
||||
</Table.HeaderRow>
|
||||
}
|
||||
>
|
||||
{data.jobs.map((job) => (
|
||||
<Table.Row key={job.id}>
|
||||
<Table.Cell>
|
||||
<span className="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-primary">
|
||||
{t(`settings.privacy.exportJobs.scope.${job.scope}`)}
|
||||
</span>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<BadgeFeedback farbe={jobTone(job.tone)} size="small">
|
||||
{t(`settings.privacy.exportJobs.status.${job.status}`)}
|
||||
</BadgeFeedback>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
{job.status === "processing" || job.status === "queued" ? (
|
||||
<Progress className="w-32" state="uploading" value={job.progressPercent} statusText={`${job.progressPercent}%`} />
|
||||
) : (
|
||||
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary">
|
||||
{job.resultSizeBytes !== null ? formatBytes(job.resultSizeBytes) : "—"}
|
||||
</span>
|
||||
)}
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-secondary">
|
||||
{formatters.date(job.createdAt, { dateStyle: "medium", timeStyle: "short" })}
|
||||
</span>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
{job.canDownload ? (
|
||||
<div className="flex flex-col items-start gap-1">
|
||||
<Button
|
||||
variant="tertiary"
|
||||
size="small"
|
||||
icon={<FeatherDownload />}
|
||||
onClick={() => actions.onDownload(job.id)}
|
||||
data-ui-id="ui.settings.privacy.exportJobs.download"
|
||||
>
|
||||
{t("settings.privacy.exportJobs.download")}
|
||||
</Button>
|
||||
{job.resultExpiresAt ? (
|
||||
<span className="text-body-extra-small-regular-0 font-body-extra-small-regular-0 text-text-neutral-tertiary">
|
||||
{t("settings.privacy.exportJobs.downloadExpires", {
|
||||
date: formatters.date(job.resultExpiresAt, { dateStyle: "medium", timeStyle: "short" }),
|
||||
})}
|
||||
</span>
|
||||
) : null}
|
||||
</div>
|
||||
) : (
|
||||
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary">
|
||||
{job.status === "expired" ? t("settings.privacy.exportJobs.expiredHint") : "—"}
|
||||
</span>
|
||||
)}
|
||||
</Table.Cell>
|
||||
</Table.Row>
|
||||
))}
|
||||
</Table>
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
{startDialogElement}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
// AK-P21 (AGENTS.md DoD B9) — shared breadcrumb trail for the privacy detail
|
||||
// screens. The hub href is injected by the route instead of being derived from
|
||||
// router state here, so the screens stay pure VM consumers (DoD A5).
|
||||
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Link } from "react-router";
|
||||
|
||||
import { Breadcrumbs } from "~/ui/components/Breadcrumbs";
|
||||
|
||||
export function PrivacyBreadcrumbs({ hubHref, titleKey }: { hubHref: string; titleKey: string }): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<Breadcrumbs data-ui-id="ui.settings.privacy.breadcrumbs">
|
||||
<Link to={hubHref}>
|
||||
<Breadcrumbs.Item>{t("settings.privacy.title")}</Breadcrumbs.Item>
|
||||
</Link>
|
||||
<Breadcrumbs.Divider />
|
||||
<Breadcrumbs.Item active>{t(titleKey)}</Breadcrumbs.Item>
|
||||
</Breadcrumbs>
|
||||
);
|
||||
}
|
||||
+277
@@ -0,0 +1,277 @@
|
||||
// AK-P21 Interim-UI (AD-28) — privacy hub (D-P21 pending). Replaces the
|
||||
// hand-written Phase-10 markup with ~/ui composition: self-service export
|
||||
// (job list + download), account deletion (existing token flow), and
|
||||
// permission-gated entry cards into the tenant admin sub-areas (export,
|
||||
// deletion, subprocessors, AVV). The export/delete/reactivate blocks stay
|
||||
// REAL forms with the established intent/csrf/confirmation contract so the
|
||||
// existing mobile-a11y smoke selectors (ui.settings.privacy.export.form,
|
||||
// .delete.form, .reactivate.form) keep working unchanged.
|
||||
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form } from "react-router";
|
||||
import {
|
||||
FeatherChevronRight,
|
||||
FeatherDownload,
|
||||
FeatherFileText,
|
||||
FeatherServer,
|
||||
FeatherShield,
|
||||
FeatherTrash2,
|
||||
FeatherUserX,
|
||||
} from "@subframe/core";
|
||||
import type { GdprExportJobVM, PrivacyHubSectionKey, PrivacyHubVM } from "@hivegrid/view-models";
|
||||
import { PAGE_HEADER_ICON_CLASS, PageBody, PageHeader, PageIntro, PageShell } from "../shared/PageShell";
|
||||
import { useLocaleFormatters } from "~/locale/format";
|
||||
import { Alert } from "~/ui/components/Alert";
|
||||
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { Card } from "~/ui/components/Card";
|
||||
import { EmptyState } from "~/ui/components/EmptyState";
|
||||
import { Loader } from "~/ui/components/Loader";
|
||||
import { TextInput } from "~/ui/components/TextInput";
|
||||
|
||||
export type PrivacyHubActions = {
|
||||
readonly onOpenSection: (section: PrivacyHubSectionKey) => void;
|
||||
readonly onDownloadJob: (jobId: string) => void;
|
||||
readonly onRetry: () => void;
|
||||
};
|
||||
|
||||
const SECTION_ICONS: Record<PrivacyHubSectionKey, React.JSX.Element> = {
|
||||
export: <FeatherDownload />,
|
||||
deletion: <FeatherTrash2 />,
|
||||
subprocessors: <FeatherServer />,
|
||||
avv: <FeatherFileText />,
|
||||
};
|
||||
|
||||
function jobTone(tone: GdprExportJobVM["tone"]): React.ComponentProps<typeof BadgeFeedback>["farbe"] {
|
||||
if (tone === "success") return "subtle-positive";
|
||||
if (tone === "warning") return "subtle-warning";
|
||||
if (tone === "danger") return "subtle-negative";
|
||||
return "subtle-neutral";
|
||||
}
|
||||
|
||||
export function PrivacyHubPage({
|
||||
vm,
|
||||
actions,
|
||||
csrf,
|
||||
embedded = false,
|
||||
}: {
|
||||
vm: PrivacyHubVM;
|
||||
actions: PrivacyHubActions;
|
||||
csrf?: string | null;
|
||||
/** Inside the Mein-Konto hub (AK-SET-01) the hub owns the header. */
|
||||
embedded?: boolean;
|
||||
}): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
const formatters = useLocaleFormatters();
|
||||
|
||||
if (vm.status === "idle" || vm.status === "loading") {
|
||||
return (
|
||||
<div className="flex w-full flex-col items-start gap-6 px-6 py-6" data-ui-id="ui.settings.privacy.loading">
|
||||
<Card>
|
||||
<div className="flex w-full items-center gap-3">
|
||||
<Loader />
|
||||
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">
|
||||
{t("settings.privacy.states.loadingDescription")}
|
||||
</span>
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (vm.status === "error") {
|
||||
return (
|
||||
<div className="flex w-full flex-col items-start gap-6 px-6 py-6" data-ui-id="ui.settings.privacy.error">
|
||||
<EmptyState
|
||||
outlined
|
||||
variant="error"
|
||||
title={t("settings.privacy.states.errorTitle")}
|
||||
body={t(vm.error.messageKey)}
|
||||
action={
|
||||
<Button variant="tertiary" onClick={actions.onRetry} data-ui-id="ui.settings.privacy.retry">
|
||||
{t("settings.privacy.states.retry")}
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (vm.status === "empty") {
|
||||
return (
|
||||
<div className="flex w-full flex-col items-start gap-6 px-6 py-6" data-ui-id="ui.settings.privacy.empty">
|
||||
<EmptyState outlined title={t("settings.privacy.states.errorTitle")} body={t("settings.privacy.states.loadingDescription")} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const { data } = vm;
|
||||
|
||||
return (
|
||||
<PageShell uiId="ui.settings.privacy.page" className="bg-surface-neutral-primary">
|
||||
{embedded ? null : (
|
||||
<PageHeader
|
||||
icon={<FeatherShield className={PAGE_HEADER_ICON_CLASS} />}
|
||||
title={t("settings.privacy.title")}
|
||||
subtitle={t("settings.privacy.description")}
|
||||
/>
|
||||
)}
|
||||
|
||||
<PageBody className="items-start">
|
||||
{embedded ? <PageIntro uiId="ui.settings.privacy.intro">{t("settings.privacy.description")}</PageIntro> : null}
|
||||
{data.tenantDeletionBanner ? (
|
||||
<Alert
|
||||
notDismissible
|
||||
variant="warning"
|
||||
title={t("settings.privacy.hub.tenantDeletionBanner.title", { days: data.tenantDeletionBanner.graceDaysRemaining })}
|
||||
description={t("settings.privacy.hub.tenantDeletionBanner.description", {
|
||||
date: formatters.date(data.tenantDeletionBanner.gracePeriodEndsAt, { dateStyle: "medium" }),
|
||||
})}
|
||||
/>
|
||||
) : null}
|
||||
|
||||
{/* Self-service export — keeps the established intent/csrf form contract. */}
|
||||
<Card data-ui-id="ui.settings.privacy.selfExport">
|
||||
<div className="flex w-full flex-col items-start gap-4">
|
||||
<div className="flex w-full flex-col items-start">
|
||||
<span className="text-body-large font-body-large text-text-neutral-primary">{t("settings.privacy.export.title")}</span>
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">
|
||||
{t("settings.privacy.export.description")}
|
||||
</span>
|
||||
</div>
|
||||
<Form method="post" data-ui-id="ui.settings.privacy.export.form" className="flex w-full flex-col items-start gap-2">
|
||||
<input type="hidden" name="intent" value="export" />
|
||||
{csrf ? <input type="hidden" name="csrf" value={csrf} /> : null}
|
||||
<Button type="submit" variant="secondary" icon={<FeatherDownload />} disabled={!data.selfExport.canStart}>
|
||||
{t("settings.privacy.export.submit")}
|
||||
</Button>
|
||||
<span className="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-neutral-tertiary">
|
||||
{data.selfExport.canStart
|
||||
? t("settings.privacy.hub.selfExport.remaining", { remaining: data.selfExport.remaining, limit: data.selfExport.limitPer24h })
|
||||
: t("settings.privacy.exportJobs.rateLimit.description", { limit: data.selfExport.limitPer24h })}
|
||||
</span>
|
||||
</Form>
|
||||
{data.selfExport.recentJobs.length > 0 ? (
|
||||
<div className="flex w-full flex-col items-start gap-2" data-ui-id="ui.settings.privacy.selfExport.recent">
|
||||
<span className="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-primary">
|
||||
{t("settings.privacy.hub.selfExport.recentTitle")}
|
||||
</span>
|
||||
{data.selfExport.recentJobs.map((job) => (
|
||||
<div key={job.id} className="border-border-default mobile:flex-col mobile:items-start flex w-full items-center gap-3 rounded-md border border-solid px-3 py-2">
|
||||
<BadgeFeedback farbe={jobTone(job.tone)} size="small">
|
||||
{t(`settings.privacy.exportJobs.status.${job.status}`)}
|
||||
</BadgeFeedback>
|
||||
<span className="grow shrink-0 basis-0 text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-secondary">
|
||||
{formatters.date(job.createdAt, { dateStyle: "medium", timeStyle: "short" })}
|
||||
</span>
|
||||
{job.canDownload ? (
|
||||
<Button
|
||||
variant="tertiary"
|
||||
size="small"
|
||||
icon={<FeatherDownload />}
|
||||
onClick={() => actions.onDownloadJob(job.id)}
|
||||
data-ui-id="ui.settings.privacy.selfExport.download"
|
||||
>
|
||||
{t("settings.privacy.exportJobs.download")}
|
||||
</Button>
|
||||
) : null}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
{/* Account deletion / reactivation — existing token flow, established selectors. */}
|
||||
<Card data-ui-id="ui.settings.privacy.accountDeletion">
|
||||
<div className="flex w-full flex-col items-start gap-4">
|
||||
<div className="flex w-full items-start gap-3">
|
||||
<div className="bg-surface-feedback-subtle-warning flex h-9 w-9 flex-none items-center justify-center rounded-md">
|
||||
<FeatherUserX className="text-body-large font-body-large text-icon-feedback-warning" />
|
||||
</div>
|
||||
<div className="flex grow shrink-0 basis-0 flex-col items-start gap-1">
|
||||
<span className="text-body-large font-body-large text-text-neutral-primary">{t("settings.privacy.delete.title")}</span>
|
||||
{data.userDeletion.pendingDeletion ? (
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">
|
||||
{t("settings.privacy.delete.scheduledPrefix")}{" "}
|
||||
<strong>
|
||||
{data.userDeletion.scheduledDeletionAt
|
||||
? formatters.date(data.userDeletion.scheduledDeletionAt, { dateStyle: "medium", timeStyle: "short" })
|
||||
: t("settings.privacy.delete.unknownDate")}
|
||||
</strong>
|
||||
. {t("settings.privacy.delete.scheduledSuffix")}
|
||||
</span>
|
||||
) : (
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">
|
||||
{t("settings.privacy.delete.description", { days: formatters.number(data.graceDays) })}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
{data.userDeletion.pendingDeletion ? (
|
||||
<Form method="post" data-ui-id="ui.settings.privacy.reactivate.form">
|
||||
<input type="hidden" name="intent" value="reactivate" />
|
||||
{csrf ? <input type="hidden" name="csrf" value={csrf} /> : null}
|
||||
<Button type="submit" variant="secondary">
|
||||
{t("settings.privacy.delete.reactivate")}
|
||||
</Button>
|
||||
</Form>
|
||||
) : (
|
||||
<Form method="post" data-ui-id="ui.settings.privacy.delete.form" className="flex w-full flex-col items-start gap-4">
|
||||
<input type="hidden" name="intent" value="delete" />
|
||||
{csrf ? <input type="hidden" name="csrf" value={csrf} /> : null}
|
||||
<TextInput className="w-full max-w-[420px]" label={t("settings.privacy.delete.confirmationLabel")} showLabel>
|
||||
<TextInput.Input name="confirmation" autoComplete="off" />
|
||||
</TextInput>
|
||||
<Button type="submit" variant="destructive" icon={<FeatherTrash2 />}>
|
||||
{t("settings.privacy.delete.submit")}
|
||||
</Button>
|
||||
</Form>
|
||||
)}
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
{/* Tenant admin sub-areas, permission-gated by the VM. */}
|
||||
{data.sections.length > 0 ? (
|
||||
<div className="flex w-full flex-col items-start gap-4" data-ui-id="ui.settings.privacy.sections">
|
||||
<div className="flex w-full flex-col items-start">
|
||||
<span className="text-body-large font-body-large text-text-neutral-primary">{t("settings.privacy.hub.adminSections.title")}</span>
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">
|
||||
{t("settings.privacy.hub.adminSections.description")}
|
||||
</span>
|
||||
</div>
|
||||
<div className="mobile:grid-cols-1 grid w-full grid-cols-2 gap-4">
|
||||
{data.sections.map((section) => (
|
||||
<Card key={section} data-ui-id={`ui.settings.privacy.sections.${section}`}>
|
||||
<div className="flex w-full items-center gap-3">
|
||||
<div className="border-border-default bg-surface-neutral-tertiary flex h-10 w-10 flex-none items-center justify-center rounded-md border border-solid text-icon-neutral-tertiary">
|
||||
{SECTION_ICONS[section]}
|
||||
</div>
|
||||
<div className="flex grow shrink-0 basis-0 flex-col items-start">
|
||||
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">
|
||||
{t(`settings.privacy.hub.sections.${section}.title`)}
|
||||
</span>
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">
|
||||
{t(`settings.privacy.hub.sections.${section}.description`)}
|
||||
</span>
|
||||
</div>
|
||||
<Button
|
||||
variant="tertiary"
|
||||
size="small"
|
||||
iconRight={<FeatherChevronRight />}
|
||||
onClick={() => actions.onOpenSection(section)}
|
||||
data-ui-id={`ui.settings.privacy.sections.${section}.open`}
|
||||
>
|
||||
{t("settings.privacy.hub.sections.open")}
|
||||
</Button>
|
||||
</div>
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
</PageBody>
|
||||
</PageShell>
|
||||
);
|
||||
}
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
// @vitest-environment node
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
const privacyScreenDir = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
function source(file: string): string {
|
||||
return fs.readFileSync(path.join(privacyScreenDir, file), "utf8");
|
||||
}
|
||||
|
||||
describe("AK-P21 privacy interim screen contracts", () => {
|
||||
const screens = ["PrivacyHubPage.tsx", "GdprExportJobsPage.tsx", "TenantDeletionPage.tsx", "SubprocessorsPage.tsx", "AvvPage.tsx"];
|
||||
|
||||
it.each(screens)("%s separates loading, error, empty, and ready states", (file) => {
|
||||
const content = source(file);
|
||||
expect(content).toContain('vm.status === "idle" || vm.status === "loading"');
|
||||
expect(content).toContain('vm.status === "error"');
|
||||
expect(content).toContain('vm.status === "empty"');
|
||||
expect(content).toContain("actions.onRetry");
|
||||
expect(content).toContain("settings.privacy.states.retry");
|
||||
});
|
||||
|
||||
it.each(screens)("%s stays app-chrome-free and uses synchronized UI components", (file) => {
|
||||
const content = source(file);
|
||||
expect(content).toContain('from "~/ui/components/');
|
||||
expect(content).not.toContain("DefaultPageLayout");
|
||||
expect(content).not.toContain("EditPageLayout");
|
||||
expect(content).not.toContain("Sidebar");
|
||||
});
|
||||
|
||||
// Either the screen writes its own <h1>, or it composes the shared PageHeader, which renders it.
|
||||
it.each(screens)("%s exposes a semantic main heading", (file) => {
|
||||
const content = source(file);
|
||||
const usesSharedHeader = content.includes("<PageHeader") && content.includes("shared/PageShell");
|
||||
expect(usesSharedHeader || (content.includes("<h1") && content.includes("</h1>"))).toBe(true);
|
||||
});
|
||||
|
||||
// AGENTS.md DoD B9 — every privacy screen below the hub must offer a
|
||||
// breadcrumb back to it, and must take the target as a prop instead of
|
||||
// reaching into router data itself (DoD A5).
|
||||
it.each(["GdprExportJobsPage.tsx", "TenantDeletionPage.tsx", "SubprocessorsPage.tsx", "AvvPage.tsx"])("%s carries a breadcrumb back to the privacy hub", (file) => {
|
||||
const content = source(file);
|
||||
expect(content).toContain("<PrivacyBreadcrumbs hubHref={hubHref}");
|
||||
expect(content).toContain("hubHref: string;");
|
||||
expect(content).not.toContain("useLoaderData");
|
||||
});
|
||||
|
||||
it("renders the breadcrumb trail from the hub title to the current screen", () => {
|
||||
const breadcrumbs = source("PrivacyBreadcrumbs.tsx");
|
||||
expect(breadcrumbs).toContain('t("settings.privacy.title")');
|
||||
expect(breadcrumbs).toContain("{t(titleKey)}");
|
||||
expect(breadcrumbs).toContain("<Link to={hubHref}>");
|
||||
expect(breadcrumbs).toContain("Breadcrumbs.Divider");
|
||||
});
|
||||
|
||||
it("keeps the established self-service form contract on the hub", () => {
|
||||
const hub = source("PrivacyHubPage.tsx");
|
||||
expect(hub).toContain('uiId="ui.settings.privacy.page"');
|
||||
expect(hub).toContain('data-ui-id="ui.settings.privacy.export.form"');
|
||||
expect(hub).toContain('data-ui-id="ui.settings.privacy.delete.form"');
|
||||
expect(hub).toContain('data-ui-id="ui.settings.privacy.reactivate.form"');
|
||||
expect(hub).toContain('name="intent" value="export"');
|
||||
expect(hub).toContain('name="intent" value="delete"');
|
||||
expect(hub).toContain('name="intent" value="reactivate"');
|
||||
expect(hub).toContain('name="confirmation"');
|
||||
expect(hub).toContain('name="csrf"');
|
||||
});
|
||||
|
||||
it("builds the deletion wizard as a real ~/ui Dialog with stepper and slug confirm gate", () => {
|
||||
const wizard = source("TenantDeletionWizardDialog.tsx");
|
||||
expect(wizard).toContain('from "~/ui/components/Dialog"');
|
||||
expect(wizard).toContain("<Dialog.Content");
|
||||
expect(wizard).toContain("StepperHorizontal");
|
||||
expect(wizard).toContain("slugConfirm !== tenantSlug");
|
||||
expect(wizard).toContain('data-ui-id="ui.settings.privacy.deletion.wizard.submit"');
|
||||
expect(wizard).not.toContain("DefaultPageLayout");
|
||||
// AD-27: no legacy provider wording in the billing step.
|
||||
expect(wizard).not.toMatch(/stripe/iu);
|
||||
});
|
||||
|
||||
it("exposes stable selectors for the privacy admin actions", () => {
|
||||
expect(source("GdprExportJobsPage.tsx")).toContain('data-ui-id="ui.settings.privacy.exportJobs.download"');
|
||||
expect(source("GdprExportJobsPage.tsx")).toContain('data-ui-id="ui.settings.privacy.exportJobs.startTenant"');
|
||||
expect(source("TenantDeletionPage.tsx")).toContain('data-ui-id="ui.settings.privacy.deletion.open"');
|
||||
expect(source("TenantDeletionPage.tsx")).toContain('data-ui-id="ui.settings.privacy.deletion.cancelConfirm"');
|
||||
expect(source("SubprocessorsPage.tsx")).toContain('data-ui-id="ui.settings.privacy.subprocessors.exportCsv"');
|
||||
expect(source("AvvPage.tsx")).toContain('data-ui-id="ui.settings.privacy.avv.acceptConfirm"');
|
||||
});
|
||||
|
||||
it.each(screens)("%s avoids raw anchor markup", (file) => {
|
||||
expect(source(file)).not.toContain("<a ");
|
||||
});
|
||||
});
|
||||
+231
@@ -0,0 +1,231 @@
|
||||
// AK-P21 Interim-UI (AD-28) — subprocessor register (D-P21 pending). List
|
||||
// hierarchy follows the automation/forms interim canon: header → non-EU
|
||||
// notice → filter pills → table with EU/EEA markers and DPA links. The CSV
|
||||
// export is generated client-side from the VM. Final optics = design-nachzug.
|
||||
|
||||
import { useMemo, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { PrivacyBreadcrumbs } from "./PrivacyBreadcrumbs";
|
||||
import { FeatherDownload, FeatherExternalLink } from "@subframe/core";
|
||||
import type { SubprocessorsVM } from "@hivegrid/view-models";
|
||||
import { subprocessorsToCsv } from "@hivegrid/view-models";
|
||||
import { useLocaleFormatters } from "~/locale/format";
|
||||
import { Alert } from "~/ui/components/Alert";
|
||||
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { Card } from "~/ui/components/Card";
|
||||
import { EmptyState } from "~/ui/components/EmptyState";
|
||||
import { LinkButton } from "~/ui/components/LinkButton";
|
||||
import { Loader } from "~/ui/components/Loader";
|
||||
import { Table } from "~/ui/components/Table";
|
||||
import { ToggleGroup } from "~/ui/components/ToggleGroup";
|
||||
import { useSaveToast, type SaveActionResult } from "~/hooks/use-save-toast";
|
||||
|
||||
export type SubprocessorsActions = {
|
||||
readonly onRetry: () => void;
|
||||
};
|
||||
|
||||
function downloadCsv(csv: string): void {
|
||||
const blob = new Blob([`${csv}`], { type: "text/csv;charset=utf-8" });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const anchor = document.createElement("a");
|
||||
anchor.href = url;
|
||||
anchor.download = "subprozessoren.csv";
|
||||
anchor.click();
|
||||
URL.revokeObjectURL(url);
|
||||
}
|
||||
|
||||
export function SubprocessorsPage({
|
||||
vm,
|
||||
actions,
|
||||
hubHref,
|
||||
embedded = false,
|
||||
}: {
|
||||
vm: SubprocessorsVM;
|
||||
actions: SubprocessorsActions;
|
||||
hubHref: string;
|
||||
/** Inside the Compliance hub (AK-SET-01) the hub owns breadcrumb and heading. */
|
||||
embedded?: boolean;
|
||||
}): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
const formatters = useLocaleFormatters();
|
||||
const [filter, setFilter] = useState<"all" | "eu">("all");
|
||||
const [exportResult, setExportResult] = useState<SaveActionResult>();
|
||||
|
||||
useSaveToast(exportResult);
|
||||
|
||||
function exportCsv(): void {
|
||||
try {
|
||||
downloadCsv(subprocessorsToCsv(rows));
|
||||
setExportResult({ ok: true, messageKey: "settings.privacy.subprocessors.exportReady" });
|
||||
} catch {
|
||||
setExportResult({ errorKey: "settings.privacy.subprocessors.exportFailed" });
|
||||
}
|
||||
}
|
||||
|
||||
const rows = useMemo(() => {
|
||||
if (vm.status !== "ready") return [];
|
||||
return filter === "eu" ? vm.data.subprocessors.filter((subprocessor) => subprocessor.isEuEea) : [...vm.data.subprocessors];
|
||||
}, [vm, filter]);
|
||||
|
||||
if (vm.status === "idle" || vm.status === "loading") {
|
||||
return (
|
||||
<div className="flex w-full flex-col items-start gap-6 px-6 py-6" data-ui-id="ui.settings.privacy.subprocessors.loading">
|
||||
<Card>
|
||||
<div className="flex w-full items-center gap-3">
|
||||
<Loader />
|
||||
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">
|
||||
{t("settings.privacy.states.loadingDescription")}
|
||||
</span>
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (vm.status === "error") {
|
||||
return (
|
||||
<div className="flex w-full flex-col items-start gap-6 px-6 py-6" data-ui-id="ui.settings.privacy.subprocessors.error">
|
||||
<EmptyState
|
||||
outlined
|
||||
variant="error"
|
||||
title={t("settings.privacy.states.errorTitle")}
|
||||
body={t(vm.error.messageKey)}
|
||||
action={
|
||||
<Button variant="tertiary" onClick={actions.onRetry} data-ui-id="ui.settings.privacy.subprocessors.retry">
|
||||
{t("settings.privacy.states.retry")}
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (vm.status === "empty") {
|
||||
return (
|
||||
<div className="flex w-full flex-col items-start gap-6 px-6 py-6" data-ui-id="ui.settings.privacy.subprocessors.empty">
|
||||
<EmptyState
|
||||
outlined
|
||||
title={t("settings.privacy.subprocessors.empty.title")}
|
||||
body={t("settings.privacy.subprocessors.empty.description")}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const { data } = vm;
|
||||
|
||||
return (
|
||||
<div className="bg-surface-neutral-primary flex w-full flex-col items-start" data-ui-id="ui.settings.privacy.subprocessors.page">
|
||||
<div className="border-border-default bg-surface-neutral-secondary mobile:flex-col mobile:px-4 flex w-full items-start justify-between gap-4 border-b border-solid px-6 py-6">
|
||||
<div className="flex flex-col items-start">
|
||||
{embedded ? null : (
|
||||
<>
|
||||
<PrivacyBreadcrumbs hubHref={hubHref} titleKey="settings.privacy.subprocessors.title" />
|
||||
<h1 className="text-heading- font-heading- text-text-neutral-primary">{t("settings.privacy.subprocessors.title")}</h1>
|
||||
</>
|
||||
)}
|
||||
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-tertiary">
|
||||
{t("settings.privacy.subprocessors.description")}
|
||||
</span>
|
||||
</div>
|
||||
<Button
|
||||
className="mobile:w-full"
|
||||
variant="secondary"
|
||||
icon={<FeatherDownload />}
|
||||
onClick={exportCsv}
|
||||
data-ui-id="ui.settings.privacy.subprocessors.exportCsv"
|
||||
>
|
||||
{t("settings.privacy.subprocessors.exportCsv")}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<div className="mobile:px-4 flex w-full flex-col items-start gap-6 px-6 py-6">
|
||||
{data.hasNonEu ? (
|
||||
<Alert
|
||||
notDismissible
|
||||
variant="warning"
|
||||
title={t("settings.privacy.subprocessors.nonEu.title")}
|
||||
description={t("settings.privacy.subprocessors.nonEu.description")}
|
||||
/>
|
||||
) : (
|
||||
<Alert
|
||||
notDismissible
|
||||
variant="success"
|
||||
title={t("settings.privacy.subprocessors.allEu.title")}
|
||||
description={t("settings.privacy.subprocessors.allEu.description")}
|
||||
/>
|
||||
)}
|
||||
|
||||
<ToggleGroup value={filter} onValueChange={(value: string) => setFilter(value === "eu" ? "eu" : "all")}>
|
||||
<ToggleGroup.Item value="all" data-ui-id="ui.settings.privacy.subprocessors.filter.all">
|
||||
{t("settings.privacy.subprocessors.filter.all", { total: data.count })}
|
||||
</ToggleGroup.Item>
|
||||
<ToggleGroup.Item value="eu" data-ui-id="ui.settings.privacy.subprocessors.filter.eu">
|
||||
{t("settings.privacy.subprocessors.filter.euOnly")}
|
||||
</ToggleGroup.Item>
|
||||
</ToggleGroup>
|
||||
|
||||
<Card data-ui-id="ui.settings.privacy.subprocessors.list">
|
||||
<div className="w-full overflow-x-auto">
|
||||
<Table
|
||||
header={
|
||||
<Table.HeaderRow>
|
||||
<Table.HeaderCell>{t("settings.privacy.subprocessors.columns.name")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("settings.privacy.subprocessors.columns.purpose")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("settings.privacy.subprocessors.columns.country")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("settings.privacy.subprocessors.columns.dataCategories")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("settings.privacy.subprocessors.columns.activeSince")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("settings.privacy.subprocessors.columns.dpa")}</Table.HeaderCell>
|
||||
</Table.HeaderRow>
|
||||
}
|
||||
>
|
||||
{rows.map((subprocessor) => (
|
||||
<Table.Row key={subprocessor.id}>
|
||||
<Table.Cell>
|
||||
<span className="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-primary">{subprocessor.name}</span>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-secondary">{subprocessor.purposeText}</span>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-secondary">{subprocessor.country}</span>
|
||||
<BadgeFeedback farbe={subprocessor.isEuEea ? "subtle-positive" : "subtle-warning"} size="small">
|
||||
{subprocessor.isEuEea ? t("settings.privacy.subprocessors.euBadge") : t("settings.privacy.subprocessors.nonEuBadge")}
|
||||
</BadgeFeedback>
|
||||
</div>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary">
|
||||
{subprocessor.dataCategories.join(", ") || "—"}
|
||||
</span>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary">
|
||||
{subprocessor.activeSince ? formatters.date(subprocessor.activeSince, { dateStyle: "medium" }) : "—"}
|
||||
</span>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
{subprocessor.dpaUrl ? (
|
||||
<LinkButton
|
||||
icon={<FeatherExternalLink />}
|
||||
onClick={() => window.open(subprocessor.dpaUrl ?? "", "_blank", "noopener,noreferrer")}
|
||||
data-ui-id="ui.settings.privacy.subprocessors.dpaLink"
|
||||
>
|
||||
{t("settings.privacy.subprocessors.dpaLink")}
|
||||
</LinkButton>
|
||||
) : (
|
||||
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary">—</span>
|
||||
)}
|
||||
</Table.Cell>
|
||||
</Table.Row>
|
||||
))}
|
||||
</Table>
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
+286
@@ -0,0 +1,286 @@
|
||||
// AK-P21 Interim-UI (AD-28) — tenant deletion area (D-P21 pending). Layout and
|
||||
// copy adapted from David's Subframe page "S01 Settings Workspaces
|
||||
// Loeschbereich" (WF-P2 Konto loeschen): explanation card with the
|
||||
// "request, not immediate" info box, export hint, and the destructive request
|
||||
// action. With a pending request the page shows the grace countdown banner
|
||||
// with the cancel action instead. Final Subframe optics = design-nachzug.
|
||||
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { PrivacyBreadcrumbs } from "./PrivacyBreadcrumbs";
|
||||
import { FeatherCheck, FeatherDownload, FeatherInfo, FeatherShieldCheck, FeatherTrash2 } from "@subframe/core";
|
||||
import type { TenantDeletionVM } from "@hivegrid/view-models";
|
||||
import { useLocaleFormatters } from "~/locale/format";
|
||||
import { Alert } from "~/ui/components/Alert";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { Card } from "~/ui/components/Card";
|
||||
import { PageIntro } from "../shared/PageShell";
|
||||
import { Dialog } from "~/ui/components/Dialog";
|
||||
import { EmptyState } from "~/ui/components/EmptyState";
|
||||
import { Loader } from "~/ui/components/Loader";
|
||||
import { TenantDeletionWizardDialog, type TenantDeletionSubmitFields } from "./TenantDeletionWizardDialog";
|
||||
|
||||
export type TenantDeletionActions = {
|
||||
readonly onRequest: (fields: TenantDeletionSubmitFields) => void;
|
||||
readonly onCancelRequest: (requestId: string) => void | Promise<void>;
|
||||
readonly onOpenExport: () => void;
|
||||
readonly onRetry: () => void;
|
||||
};
|
||||
|
||||
export function TenantDeletionPage({
|
||||
vm,
|
||||
actions,
|
||||
hubHref,
|
||||
embedded = false,
|
||||
submitting = false,
|
||||
errorKey = null,
|
||||
}: {
|
||||
vm: TenantDeletionVM;
|
||||
actions: TenantDeletionActions;
|
||||
hubHref: string;
|
||||
/** Inside the Compliance hub (AK-SET-01) the hub owns breadcrumb and heading. */
|
||||
embedded?: boolean;
|
||||
submitting?: boolean;
|
||||
errorKey?: string | null;
|
||||
}): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
const formatters = useLocaleFormatters();
|
||||
const [wizardOpen, setWizardOpen] = useState(false);
|
||||
const [cancelOpen, setCancelOpen] = useState(false);
|
||||
const [cancelling, setCancelling] = useState(false);
|
||||
|
||||
if (vm.status === "idle" || vm.status === "loading") {
|
||||
return (
|
||||
<div className="flex w-full flex-col items-start gap-6 px-6 py-6" data-ui-id="ui.settings.privacy.deletion.loading">
|
||||
<Card>
|
||||
<div className="flex w-full items-center gap-3">
|
||||
<Loader />
|
||||
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">
|
||||
{t("settings.privacy.states.loadingDescription")}
|
||||
</span>
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (vm.status === "error") {
|
||||
return (
|
||||
<div className="flex w-full flex-col items-start gap-6 px-6 py-6" data-ui-id="ui.settings.privacy.deletion.error">
|
||||
<EmptyState
|
||||
outlined
|
||||
variant="error"
|
||||
title={t("settings.privacy.states.errorTitle")}
|
||||
body={t(vm.error.messageKey)}
|
||||
action={
|
||||
<Button variant="tertiary" onClick={actions.onRetry} data-ui-id="ui.settings.privacy.deletion.retry">
|
||||
{t("settings.privacy.states.retry")}
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (vm.status === "empty") {
|
||||
return (
|
||||
<div className="flex w-full flex-col items-start gap-6 px-6 py-6" data-ui-id="ui.settings.privacy.deletion.empty">
|
||||
<EmptyState outlined title={t("settings.privacy.states.errorTitle")} body={t("settings.privacy.states.loadingDescription")} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const { data } = vm;
|
||||
const request = data.request;
|
||||
const pendingRequest = request && request.status === "pending" ? request : null;
|
||||
const executingRequest = request && request.status === "executing" ? request : null;
|
||||
|
||||
async function confirmCancel(): Promise<void> {
|
||||
if (!pendingRequest) return;
|
||||
setCancelling(true);
|
||||
try {
|
||||
await actions.onCancelRequest(pendingRequest.id);
|
||||
setCancelOpen(false);
|
||||
} finally {
|
||||
setCancelling(false);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="bg-surface-neutral-primary flex w-full flex-col items-start" data-ui-id="ui.settings.privacy.deletion.page">
|
||||
{embedded ? null : (
|
||||
<div className="border-border-default bg-surface-neutral-secondary mobile:px-4 flex w-full flex-col items-start border-b border-solid px-6 py-6">
|
||||
<PrivacyBreadcrumbs hubHref={hubHref} titleKey="settings.privacy.deletion.title" />
|
||||
<h1 className="text-heading- font-heading- text-text-neutral-primary">{t("settings.privacy.deletion.title")}</h1>
|
||||
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-tertiary">
|
||||
{t("settings.privacy.deletion.description")}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Full content width: the cards were capped at 720px, which left the
|
||||
screen looking like a narrow column with two thirds of the page empty. */}
|
||||
<div className="mobile:px-4 flex w-full flex-col items-start gap-6 px-6 py-6">
|
||||
{embedded ? <PageIntro uiId="ui.settings.privacy.deletion.intro">{t("settings.privacy.deletion.description")}</PageIntro> : null}
|
||||
{pendingRequest ? (
|
||||
<Card variant="warning" data-ui-id="ui.settings.privacy.deletion.grace">
|
||||
<div className="flex w-full flex-col items-start gap-4">
|
||||
<Alert
|
||||
notDismissible
|
||||
variant="warning"
|
||||
title={t("settings.privacy.deletion.grace.title", { days: pendingRequest.graceDaysRemaining })}
|
||||
description={t("settings.privacy.deletion.grace.description", {
|
||||
date: formatters.date(pendingRequest.gracePeriodEndsAt, { dateStyle: "medium", timeStyle: "short" }),
|
||||
})}
|
||||
/>
|
||||
<div className="flex w-full items-center justify-between gap-4 mobile:flex-col mobile:items-stretch">
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">
|
||||
{t("settings.privacy.deletion.grace.requestedAt", {
|
||||
date: formatters.date(pendingRequest.createdAt, { dateStyle: "medium" }),
|
||||
})}
|
||||
</span>
|
||||
<Button
|
||||
className="mobile:w-full"
|
||||
variant="secondary"
|
||||
onClick={() => setCancelOpen(true)}
|
||||
data-ui-id="ui.settings.privacy.deletion.cancel"
|
||||
>
|
||||
{t("settings.privacy.deletion.grace.cancelCta")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
) : null}
|
||||
|
||||
{executingRequest ? (
|
||||
<Alert
|
||||
notDismissible
|
||||
variant="error"
|
||||
title={t("settings.privacy.deletion.executing.title")}
|
||||
description={t("settings.privacy.deletion.executing.description")}
|
||||
/>
|
||||
) : null}
|
||||
|
||||
{!pendingRequest && !executingRequest ? (
|
||||
<Card data-ui-id="ui.settings.privacy.deletion.request">
|
||||
<div className="flex w-full flex-col items-start gap-5">
|
||||
<div className="flex w-full items-start gap-3">
|
||||
<div className="bg-surface-feedback-subtle-warning flex h-9 w-9 flex-none items-center justify-center rounded-md">
|
||||
<FeatherTrash2 className="text-body-large font-body-large text-icon-feedback-warning" />
|
||||
</div>
|
||||
<div className="flex grow shrink-0 basis-0 flex-col items-start gap-1">
|
||||
<span className="text-heading- font-heading- text-text-neutral-primary">
|
||||
{t("settings.privacy.deletion.request.title")}
|
||||
</span>
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">
|
||||
{t("settings.privacy.deletion.request.description", { days: data.graceDays })}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="border-border-information-subtle bg-surface-feedback-subtle-information flex w-full flex-col items-start gap-2 rounded-md border border-solid px-4 py-4">
|
||||
<div className="flex w-full items-center gap-2">
|
||||
<FeatherInfo className="text-body-default-regular-0 font-body-default-regular-0 text-icon-feedback-information" />
|
||||
<span className="text-body-small-semibold-0 font-body-small-semibold-0 text-text-feedback-information">
|
||||
{t("settings.privacy.deletion.request.notImmediateTitle")}
|
||||
</span>
|
||||
</div>
|
||||
{(["grace", "cancel"] as const).map((point) => (
|
||||
<div key={point} className="flex w-full items-start gap-2">
|
||||
<FeatherCheck className="text-body-small-regular-0 font-body-small-regular-0 text-icon-feedback-information" />
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-feedback-information">
|
||||
{t(`settings.privacy.deletion.request.point.${point}`, { days: data.graceDays })}
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="border-border-default bg-surface-neutral-primary mobile:flex-col mobile:items-stretch flex w-full items-start gap-3 rounded-md border border-solid px-4 py-4">
|
||||
<FeatherDownload className="text-body-large font-body-large text-icon-neutral-tertiary" />
|
||||
<div className="flex grow shrink-0 basis-0 flex-col items-start gap-0.5">
|
||||
<span className="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-primary">
|
||||
{t("settings.privacy.deletion.request.exportTitle")}
|
||||
</span>
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">
|
||||
{t("settings.privacy.deletion.request.exportDescription")}
|
||||
</span>
|
||||
</div>
|
||||
<Button
|
||||
className="mobile:w-full"
|
||||
variant="tertiary"
|
||||
size="small"
|
||||
icon={<FeatherDownload />}
|
||||
onClick={actions.onOpenExport}
|
||||
data-ui-id="ui.settings.privacy.deletion.openExport"
|
||||
>
|
||||
{t("settings.privacy.deletion.request.exportCta")}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<div className="bg-border-default flex h-px w-full flex-none flex-col items-start" />
|
||||
|
||||
<div className="mobile:flex-col mobile:items-stretch mobile:gap-4 flex w-full items-center justify-between gap-4">
|
||||
<div className="flex items-center gap-2">
|
||||
<FeatherShieldCheck className="text-body-default-regular-0 font-body-default-regular-0 text-icon-feedback-positive" />
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">
|
||||
{t("settings.privacy.deletion.request.permissionNote")}
|
||||
</span>
|
||||
</div>
|
||||
<Button
|
||||
className="mobile:w-full"
|
||||
variant="destructive"
|
||||
icon={<FeatherTrash2 />}
|
||||
disabled={!data.canRequest}
|
||||
onClick={() => setWizardOpen(true)}
|
||||
data-ui-id="ui.settings.privacy.deletion.open"
|
||||
>
|
||||
{t("settings.privacy.deletion.request.cta")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
<TenantDeletionWizardDialog
|
||||
open={wizardOpen}
|
||||
tenantSlug={data.tenantSlug}
|
||||
graceDays={data.graceDays}
|
||||
requiresOtp={data.requiresOtp}
|
||||
submitting={submitting}
|
||||
errorKey={errorKey}
|
||||
onSubmit={actions.onRequest}
|
||||
onOpenExport={actions.onOpenExport}
|
||||
onClose={() => setWizardOpen(false)}
|
||||
/>
|
||||
|
||||
<Dialog open={cancelOpen} onOpenChange={(open: boolean) => (open ? undefined : setCancelOpen(false))}>
|
||||
<Dialog.Content
|
||||
className="w-[420px] max-w-[90vw] p-4"
|
||||
aria-label={t("settings.privacy.deletion.cancelDialog.title")}
|
||||
data-ui-id="ui.settings.privacy.deletion.cancelDialog"
|
||||
>
|
||||
<div className="flex w-full flex-col items-start gap-2">
|
||||
<span className="text-heading-0 font-heading-0 text-text-neutral-primary">{t("settings.privacy.deletion.cancelDialog.title")}</span>
|
||||
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
|
||||
{t("settings.privacy.deletion.cancelDialog.description")}
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex w-full items-center justify-end gap-2 pt-4">
|
||||
<Button variant="tertiary" disabled={cancelling} onClick={() => setCancelOpen(false)}>
|
||||
{t("shared.cancel")}
|
||||
</Button>
|
||||
<Button
|
||||
loading={cancelling}
|
||||
onClick={() => void confirmCancel()}
|
||||
data-ui-id="ui.settings.privacy.deletion.cancelConfirm"
|
||||
>
|
||||
{t("settings.privacy.deletion.cancelDialog.confirm")}
|
||||
</Button>
|
||||
</div>
|
||||
</Dialog.Content>
|
||||
</Dialog>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
+252
@@ -0,0 +1,252 @@
|
||||
// AK-P21 Interim-UI (AD-28) — tenant deletion wizard as a REAL ~/ui Dialog
|
||||
// (size M 720) with a StepperHorizontal. Copy and structure adapted from
|
||||
// David's Subframe pages "S01 Settings Workspaces Loeschbereich" +
|
||||
// "M01 Loeschung anfragen" (WF-P2 Konto loeschen) and the re-auth step from
|
||||
// "M01 Identitaet bestaetigen" (WF-P2 Change Password). Steps:
|
||||
// explain (30d grace, read-only, hard delete) → export offer → billing note
|
||||
// (Lago/Mollie gateway wording, AD-27) → verify (password + optional TOTP) →
|
||||
// slug confirm phrase. Submits go through the injected onSubmit callback —
|
||||
// no fetching in here. Final Subframe optics = tracked design-nachzug.
|
||||
//
|
||||
// Interim simplification: the TOTP code uses a single TextInput instead of
|
||||
// the InputOtp compound; David's final D-P21 screens may swap it back.
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { FeatherCheck, FeatherDownload, FeatherInfo, FeatherSend, FeatherShieldCheck, FeatherTrash2 } from "@subframe/core";
|
||||
import { Alert } from "~/ui/components/Alert";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { Dialog } from "~/ui/components/Dialog";
|
||||
import { StepperHorizontal } from "~/ui/components/StepperHorizontal";
|
||||
import { TextArea } from "~/ui/components/TextArea";
|
||||
import { TextInput } from "~/ui/components/TextInput";
|
||||
|
||||
export type TenantDeletionSubmitFields = {
|
||||
password: string;
|
||||
otpCode: string;
|
||||
slugConfirm: string;
|
||||
reasonText: string;
|
||||
};
|
||||
|
||||
export type TenantDeletionWizardDialogProps = {
|
||||
open: boolean;
|
||||
tenantSlug: string;
|
||||
graceDays: number;
|
||||
requiresOtp: boolean;
|
||||
submitting: boolean;
|
||||
errorKey?: string | null;
|
||||
onSubmit: (fields: TenantDeletionSubmitFields) => void;
|
||||
onOpenExport: () => void;
|
||||
onClose: () => void;
|
||||
};
|
||||
|
||||
const STEPS = ["explain", "export", "billing", "verify", "confirm"] as const;
|
||||
|
||||
const bodyText = "text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary";
|
||||
|
||||
export function TenantDeletionWizardDialog(props: TenantDeletionWizardDialogProps) {
|
||||
const { open, tenantSlug, graceDays, requiresOtp, submitting, errorKey, onSubmit, onOpenExport, onClose } = props;
|
||||
const { t } = useTranslation();
|
||||
const [step, setStep] = useState(0);
|
||||
const [password, setPassword] = useState("");
|
||||
const [otpCode, setOtpCode] = useState("");
|
||||
const [slugConfirm, setSlugConfirm] = useState("");
|
||||
const [reasonText, setReasonText] = useState("");
|
||||
|
||||
useEffect(() => {
|
||||
if (open) {
|
||||
setStep(0);
|
||||
setPassword("");
|
||||
setOtpCode("");
|
||||
setSlugConfirm("");
|
||||
setReasonText("");
|
||||
}
|
||||
}, [open]);
|
||||
|
||||
const verifyIncomplete = password.trim().length === 0 || (requiresOtp && otpCode.trim().length < 6);
|
||||
const slugMismatch = slugConfirm.length > 0 && slugConfirm !== tenantSlug;
|
||||
const confirmIncomplete = slugConfirm !== tenantSlug;
|
||||
|
||||
function submit() {
|
||||
onSubmit({ password: password.trim(), otpCode: otpCode.trim(), slugConfirm, reasonText: reasonText.trim() });
|
||||
}
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={(nextOpen: boolean) => (nextOpen ? undefined : onClose())}>
|
||||
<Dialog.Content className="w-[720px] max-w-[90vw] p-6" aria-label={t("settings.privacy.deletion.wizard.title")}>
|
||||
<div className="flex w-full flex-col gap-6" data-ui-id="ui.settings.privacy.deletion.wizard">
|
||||
<div className="flex flex-col gap-2">
|
||||
<span className="text-heading-3 font-heading-3 text-text-neutral-primary">{t("settings.privacy.deletion.wizard.title")}</span>
|
||||
{errorKey ? <Alert variant="error" title={t(errorKey)} /> : null}
|
||||
</div>
|
||||
|
||||
<StepperHorizontal>
|
||||
{STEPS.map((key, index) => (
|
||||
<StepperHorizontal.Step
|
||||
key={key}
|
||||
firstStep={index === 0}
|
||||
lastStep={index === STEPS.length - 1}
|
||||
stepNumber={String(index + 1)}
|
||||
label={t(`settings.privacy.deletion.wizard.step.${key}`)}
|
||||
variant={index === step ? "active" : index < step ? "completed" : "default"}
|
||||
/>
|
||||
))}
|
||||
</StepperHorizontal>
|
||||
|
||||
{step === 0 ? (
|
||||
<div className="flex w-full flex-col gap-4" data-wizard-step="explain">
|
||||
<span className={bodyText}>{t("settings.privacy.deletion.wizard.explain.body", { days: graceDays })}</span>
|
||||
<div className="border-border-information-subtle bg-surface-feedback-subtle-information flex w-full flex-col items-start gap-2 rounded-md border border-solid px-4 py-4">
|
||||
<div className="flex w-full items-center gap-2">
|
||||
<FeatherInfo className="text-body-default-regular-0 font-body-default-regular-0 text-icon-feedback-information" />
|
||||
<span className="text-body-small-semibold-0 font-body-small-semibold-0 text-text-feedback-information">
|
||||
{t("settings.privacy.deletion.wizard.explain.notImmediateTitle")}
|
||||
</span>
|
||||
</div>
|
||||
{(["grace", "readOnly", "cancel"] as const).map((point) => (
|
||||
<div key={point} className="flex w-full items-start gap-2">
|
||||
<FeatherCheck className="text-body-small-regular-0 font-body-small-regular-0 text-icon-feedback-information" />
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-feedback-information">
|
||||
{t(`settings.privacy.deletion.wizard.explain.point.${point}`, { days: graceDays })}
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
<TextArea className="w-full max-w-none" label={t("settings.privacy.deletion.wizard.explain.reasonLabel")} showLabel>
|
||||
<TextArea.Input value={reasonText} onChange={(event) => setReasonText(event.target.value)} data-wizard-field="reasonText" />
|
||||
</TextArea>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{step === 1 ? (
|
||||
<div className="flex w-full flex-col gap-4" data-wizard-step="export">
|
||||
<div className="border-border-default bg-surface-neutral-primary mobile:flex-col mobile:items-stretch flex w-full items-start gap-3 rounded-md border border-solid px-4 py-4">
|
||||
<FeatherDownload className="text-body-large font-body-large text-icon-neutral-tertiary" />
|
||||
<div className="flex grow shrink-0 basis-0 flex-col items-start gap-0.5">
|
||||
<span className="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-primary">
|
||||
{t("settings.privacy.deletion.wizard.export.title")}
|
||||
</span>
|
||||
<span className={bodyText}>{t("settings.privacy.deletion.wizard.export.description")}</span>
|
||||
</div>
|
||||
<Button
|
||||
className="mobile:w-full"
|
||||
variant="tertiary"
|
||||
size="small"
|
||||
icon={<FeatherDownload />}
|
||||
onClick={onOpenExport}
|
||||
data-ui-id="ui.settings.privacy.deletion.wizard.openExport"
|
||||
>
|
||||
{t("settings.privacy.deletion.wizard.export.cta")}
|
||||
</Button>
|
||||
</div>
|
||||
<span className={bodyText}>{t("settings.privacy.deletion.wizard.export.skipHint")}</span>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{step === 2 ? (
|
||||
<div className="flex w-full flex-col gap-4" data-wizard-step="billing">
|
||||
<Alert
|
||||
notDismissible
|
||||
variant="information"
|
||||
title={t("settings.privacy.deletion.wizard.billing.title")}
|
||||
description={t("settings.privacy.deletion.wizard.billing.description")}
|
||||
/>
|
||||
<span className={bodyText}>{t("settings.privacy.deletion.wizard.billing.timing")}</span>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{step === 3 ? (
|
||||
<div className="flex w-full flex-col gap-4" data-wizard-step="verify">
|
||||
<div className="flex w-full items-center gap-2">
|
||||
<FeatherShieldCheck className="text-body-default-regular-0 font-body-default-regular-0 text-icon-feedback-information" />
|
||||
<span className={bodyText}>{t("settings.privacy.deletion.wizard.verify.body")}</span>
|
||||
</div>
|
||||
<TextInput className="w-full" label={t("settings.privacy.deletion.wizard.verify.passwordLabel")} showLabel>
|
||||
<TextInput.Input
|
||||
type="password"
|
||||
autoComplete="current-password"
|
||||
value={password}
|
||||
onChange={(event) => setPassword(event.target.value)}
|
||||
required
|
||||
data-wizard-field="password"
|
||||
/>
|
||||
</TextInput>
|
||||
{requiresOtp ? (
|
||||
<TextInput
|
||||
className="w-full"
|
||||
label={t("settings.privacy.deletion.wizard.verify.otpLabel")}
|
||||
helpText={t("settings.privacy.deletion.wizard.verify.otpHelp")}
|
||||
showLabel
|
||||
>
|
||||
<TextInput.Input
|
||||
inputMode="numeric"
|
||||
autoComplete="one-time-code"
|
||||
maxLength={6}
|
||||
value={otpCode}
|
||||
onChange={(event) => setOtpCode(event.target.value.replace(/\D/g, ""))}
|
||||
required
|
||||
data-wizard-field="otpCode"
|
||||
/>
|
||||
</TextInput>
|
||||
) : null}
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{step === 4 ? (
|
||||
<div className="flex w-full flex-col gap-4" data-wizard-step="confirm">
|
||||
<Alert notDismissible variant="error" title={t("settings.privacy.deletion.wizard.confirm.warningTitle")} description={t("settings.privacy.deletion.wizard.confirm.warningDescription", { days: graceDays })} />
|
||||
<TextInput
|
||||
className="w-full"
|
||||
label={t("settings.privacy.deletion.wizard.confirm.slugLabel", { slug: tenantSlug })}
|
||||
showLabel
|
||||
error={slugMismatch}
|
||||
message={slugMismatch ? t("settings.privacy.deletion.wizard.confirm.slugMismatch") : undefined}
|
||||
>
|
||||
<TextInput.Input
|
||||
autoComplete="off"
|
||||
value={slugConfirm}
|
||||
onChange={(event) => setSlugConfirm(event.target.value)}
|
||||
placeholder={tenantSlug}
|
||||
required
|
||||
data-wizard-field="slugConfirm"
|
||||
/>
|
||||
</TextInput>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
<div className="flex w-full items-center justify-end gap-2">
|
||||
<Button variant="tertiary" onClick={onClose}>
|
||||
{t("shared.cancel")}
|
||||
</Button>
|
||||
{step > 0 ? (
|
||||
<Button variant="secondary" onClick={() => setStep(step - 1)}>
|
||||
{t("shared.back")}
|
||||
</Button>
|
||||
) : null}
|
||||
{step < STEPS.length - 1 ? (
|
||||
<Button
|
||||
disabled={step === 3 && verifyIncomplete}
|
||||
onClick={() => setStep(step + 1)}
|
||||
data-ui-id="ui.settings.privacy.deletion.wizard.next"
|
||||
>
|
||||
{t("shared.next")}
|
||||
</Button>
|
||||
) : (
|
||||
<Button
|
||||
variant="destructive"
|
||||
icon={<FeatherTrash2 />}
|
||||
iconRight={<FeatherSend />}
|
||||
disabled={confirmIncomplete || verifyIncomplete}
|
||||
loading={submitting}
|
||||
onClick={submit}
|
||||
data-ui-id="ui.settings.privacy.deletion.wizard.submit"
|
||||
>
|
||||
{t("settings.privacy.deletion.wizard.confirm.submit")}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</Dialog.Content>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user