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
+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>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user