Refresh HiveGrid Cloud reference snapshot

This commit is contained in:
david committed 2026-08-03 15:31:14 +02:00
1 parent 5e99e14772
commit 7f88026f79
5955 files changed
+1177325 -188362

No files matched your search

@@ -0,0 +1,62 @@
import type { ReactNode } from "react";
import { Link } from "react-router";
import { useTranslation } from "react-i18next";
import type { SettingsHubVM } from "@hivegrid/view-models";
import { PAGE_HEADER_ICON_CLASS, PageHeader, PageShell } from "../shared/PageShell";
import { Tabs } from "~/ui/components/Tabs";
/**
* AK-SET-01 · shared chrome for every settings hub.
*
* Renders the hub header plus a permanently visible tab bar and yields the
* active tab's route below it. The tab markup follows the settings tab bar
* already shipped in MembersPage: a <Link> wrapping a <Tabs.Item>, so each tab
* stays a real navigation target rather than an onClick handler.
*
* The inner settings rail (SidebarIconsLayout) is deliberately untouched by
* this component — it only ever receives a shorter item list.
*/
export function SettingsHubShell({
vm,
icon,
children,
}: {
vm: SettingsHubVM;
icon?: ReactNode;
children: ReactNode;
}): React.JSX.Element {
const { t } = useTranslation();
// `empty` means the loader handed over a hub without a single reachable tab.
// It should have thrown a 404 instead, so render the content bare rather than
// an empty chrome that suggests the user is somewhere they may not be.
if (vm.status !== "ready") {
return <PageShell uiId="ui.settings.hub">{children}</PageShell>;
}
const { hubId, titleKey, subtitleKey, tabs } = vm.data;
return (
<PageShell uiId={`ui.settings.hub.${hubId}`} className="bg-surface-neutral-primary">
<PageHeader
icon={icon ? <span className={PAGE_HEADER_ICON_CLASS}>{icon}</span> : undefined}
title={t(titleKey)}
subtitle={subtitleKey ? t(subtitleKey) : undefined}
/>
<div className="flex w-full flex-col px-6 pt-4 mobile:px-4">
<Tabs>
{tabs.map((tab) => (
<Link key={tab.id} to={tab.href} className="contents no-underline" data-ui-id={`ui.settings.hub.${hubId}.tab.${tab.id}`}>
<Tabs.Item active={tab.active}>{t(tab.labelKey)}</Tabs.Item>
</Link>
))}
</Tabs>
</div>
{/* PageShell is items-start, so the tab content would size to its own
content and leave dead space on the right — this keeps it stretched. */}
<div className="w-full">{children}</div>
</PageShell>
);
}
@@ -0,0 +1,72 @@
// @vitest-environment jsdom
import "@testing-library/jest-dom/vitest";
import { render } from "@testing-library/react";
import { MemoryRouter } from "react-router";
import { describe, expect, it, vi } from "vitest";
import { buildSettingsHubVM } from "@hivegrid/view-models";
import { SettingsHubShell } from "./SettingsHubShell";
const labels: Record<string, string> = {
"settings.hubs.account.title": "Mein Konto",
"settings.hubs.team.title": "Team & Zugriff",
"settings.hubs.workspace.title": "Workspace",
"settings.hubs.billing.title": "Abrechnung",
"settings.hubs.integrations.title": "Erweiterungen",
"settings.hubs.compliance.title": "Compliance & Protokolle",
"customerPortal.admin.title": "Kundenportal",
"settings.hubs.subtitle": "Interim-UI",
"settings.hubs.tab": "Übersicht",
};
vi.mock("react-i18next", () => ({
useTranslation: () => ({ t: (key: string) => labels[key] ?? key }),
}));
const hubs = [
["account", "settings.hubs.account.title"],
["team", "settings.hubs.team.title"],
["workspace", "settings.hubs.workspace.title"],
["billing", "settings.hubs.billing.title"],
["integrations", "settings.hubs.integrations.title"],
["compliance", "settings.hubs.compliance.title"],
["customerPortal", "customerPortal.admin.title"],
] as const;
describe("AK-SET-01 settings hubs interim visual baseline", () => {
it("renders all seven compact hub headers and their permanent tab bar", () => {
const { container } = render(
<MemoryRouter>
<main data-ui-id="ui.settings.hubs.interim.visualBaseline">
{hubs.map(([hubId, titleKey]) => (
<SettingsHubShell
key={hubId}
vm={buildSettingsHubVM({
hubId,
titleKey,
subtitleKey: "settings.hubs.subtitle",
tabs: [{ id: "overview", labelKey: "settings.hubs.tab", href: `/acme/settings/${hubId}` }],
currentPath: `/acme/settings/${hubId}`,
})}
>
<div data-ui-id={`ui.settings.hub.${hubId}.fixture`}>Fixture</div>
</SettingsHubShell>
))}
</main>
</MemoryRouter>
);
for (const [hubId, titleKey] of hubs) {
expect(container.querySelector(`[data-ui-id="ui.settings.hub.${hubId}"]`)).toBeInTheDocument();
expect(container).toHaveTextContent(labels[titleKey]);
expect(container.querySelector(`[data-ui-id="ui.settings.hub.${hubId}.tab.overview"]`)).toBeInTheDocument();
}
// The fixed 208px rail uses these labels; keeping them compact prevents
// the truncation regression without touching SidebarIconsLayout itself.
expect(hubs.map(([, titleKey]) => labels[titleKey].length)).toEqual([10, 14, 9, 10, 13, 23, 12]);
const stableMarkup = container.innerHTML.replace(/<svg\b[^>]*>[\s\S]*?<\/svg>/gu, '<svg data-visual-icon="true"></svg>');
expect(stableMarkup).toMatchSnapshot();
});
});
@@ -0,0 +1,31 @@
// @vitest-environment jsdom
import "@testing-library/jest-dom/vitest";
import { fireEvent, render, screen } from "@testing-library/react";
import { describe, expect, it, vi } from "vitest";
import { UiPreferencesSettingsPage } from "./UiPreferencesSettingsPage";
vi.mock("react-i18next", () => ({
useTranslation: () => ({ t: (key: string) => key }),
}));
describe("UiPreferencesSettingsPage", () => {
it("renders both browser-local preferences and forwards toggle changes", () => {
const onSetAutoCollapseSidebar = vi.fn();
const onSetVisualEffectsEnabled = vi.fn();
render(
<UiPreferencesSettingsPage
preferences={{ autoCollapseSidebar: true, visualEffectsEnabled: true }}
actions={{ onSetAutoCollapseSidebar, onSetVisualEffectsEnabled }}
/>
);
fireEvent.click(screen.getByLabelText("settings.appearance.autoCollapse.title"));
fireEvent.click(screen.getByLabelText("settings.appearance.effects.title"));
expect(onSetAutoCollapseSidebar).toHaveBeenCalledWith(false);
expect(onSetVisualEffectsEnabled).toHaveBeenCalledWith(false);
expect(screen.getByText("settings.appearance.browserHint")).toBeInTheDocument();
});
});
@@ -0,0 +1,86 @@
import { useTranslation } from "react-i18next";
import type { UiPreferences } from "~/components/app/UiPreferencesContext";
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
import { Card } from "~/ui/components/Card";
import { Switch } from "~/ui/components/Switch";
import { PageBody, PageIntro, PageShell } from "../shared/PageShell";
export type UiPreferencesSettingsPageProps = {
preferences: UiPreferences;
actions: {
onSetAutoCollapseSidebar: (enabled: boolean) => void;
onSetVisualEffectsEnabled: (enabled: boolean) => void;
};
};
export function UiPreferencesSettingsPage({ preferences, actions }: UiPreferencesSettingsPageProps): React.JSX.Element {
const { t } = useTranslation();
return (
<PageShell uiId="ui.settings.appearance.page">
<PageBody>
<div className="flex w-full justify-center">
<div className="flex w-full max-w-3xl flex-col gap-6">
<PageIntro uiId="ui.settings.appearance.intro">{t("settings.appearance.description")}</PageIntro>
<div className="flex w-full flex-col gap-4">
<PreferenceCard
title={t("settings.appearance.autoCollapse.title")}
description={t("settings.appearance.autoCollapse.description")}
checked={preferences.autoCollapseSidebar}
onCheckedChange={actions.onSetAutoCollapseSidebar}
uiId="ui.settings.appearance.autoCollapse"
badge={t("settings.appearance.recommended")}
/>
<PreferenceCard
title={t("settings.appearance.effects.title")}
description={t("settings.appearance.effects.description")}
checked={preferences.visualEffectsEnabled}
onCheckedChange={actions.onSetVisualEffectsEnabled}
uiId="ui.settings.appearance.effects"
/>
</div>
<p className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">
{t("settings.appearance.browserHint")}
</p>
</div>
</div>
</PageBody>
</PageShell>
);
}
function PreferenceCard({
title,
description,
checked,
onCheckedChange,
uiId,
badge,
}: {
title: string;
description: string;
checked: boolean;
onCheckedChange: (enabled: boolean) => void;
uiId: string;
badge?: string;
}): React.JSX.Element {
return (
<Card className="flex-row flex-wrap items-center justify-between gap-4" data-ui-id={uiId}>
<div className="flex min-w-0 grow basis-80 flex-col gap-1">
<div className="flex flex-wrap items-center gap-2">
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{title}</span>
{badge ? (
<BadgeFeedback farbe="subtle-brand-primary" size="small">
{badge}
</BadgeFeedback>
) : null}
</div>
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary">{description}</span>
</div>
<Switch checked={checked} onCheckedChange={onCheckedChange} aria-label={title} data-ui-id={`${uiId}.switch`} />
</Card>
);
}
@@ -0,0 +1,169 @@
// Workspace > Konto in the shape the neighbouring tabs already wear: PageBody
// with PageIntro and stacked Cards, controls from ~/ui.
//
// The tab was the last settings screen still on the old boilerplate frame — a
// SettingSection grid with the heading in a left column, hand-drawn <div>
// separators between the sections, and the boilerplate form controls
// (InputText, ButtonPrimary, LoadingButton). Richtlinien and Demo-Daten next to
// it are Card screens, so Konto read as a different product.
//
// Presentational: the route owns the submits and passes the callbacks (M014).
// The icon picker keeps UploadDocuments — it does the base64 conversion the
// existing action expects for the `icon` field.
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { FeatherSave, FeatherTrash2, FeatherUpload } from "@subframe/core";
import type { Anrede } from "@hivegrid/i18n";
import UploadDocuments from "~/components/ui/uploaders/UploadDocument";
import InputChoicebox from "~/components/ui/input/InputChoicebox";
import UrlUtils from "~/utils/app/UrlUtils";
import { Avatar } from "~/ui/components/Avatar";
import { Button } from "~/ui/components/Button";
import { Card } from "~/ui/components/Card";
import { TextInput } from "~/ui/components/TextInput";
import { PageBody, PageIntro } from "../shared/PageShell";
export type WorkspaceGeneralData = {
name: string;
slug: string;
icon: string | null;
anrede: Anrede;
canUpdate: boolean;
canDelete: boolean;
};
export type WorkspaceGeneralActions = {
/** POSTs the unchanged action=edit contract (name / slug / icon). */
onSaveDetails: (input: { name: string; slug: string; icon: string }) => void;
/** POSTs the unchanged action=update-anrede contract. */
onChangeAnrede: (anrede: Anrede) => void;
/** Opens the delete confirmation the route owns. */
onDeleteWorkspace: () => void;
};
const SECTION_HEADING_CLASS = "text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary";
const SECTION_HINT_CLASS = "text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary";
function SectionHeading({ title, description }: { title: string; description: string }) {
return (
<div className="flex w-full flex-col gap-1">
<span className={SECTION_HEADING_CLASS}>{title}</span>
<span className={SECTION_HINT_CLASS}>{description}</span>
</div>
);
}
export function WorkspaceGeneralPage({
data,
actions,
submitting = false,
}: {
data: WorkspaceGeneralData;
actions: WorkspaceGeneralActions;
submitting?: boolean;
}): React.JSX.Element {
const { t } = useTranslation();
const [name, setName] = useState(data.name);
const [slug, setSlug] = useState(data.slug);
const [icon, setIcon] = useState(data.icon ?? "");
const disabled = !data.canUpdate;
const nameMissing = name.trim().length === 0 || slug.trim().length === 0;
return (
<PageBody uiId="ui.settings.workspace.general.page">
{/* AK-SET-01: the Workspace hub owns the page header — the description stays here. */}
<PageIntro uiId="ui.settings.workspace.general.intro">{t("settings.tenant.subtitle")}</PageIntro>
<Card data-ui-id="ui.settings.account.form">
<SectionHeading title={t("settings.tenant.general")} description={t("settings.tenant.generalDescription")} />
<div className="grid w-full gap-4 sm:grid-cols-2">
<TextInput className="w-full max-w-full" label={t("shared.name")} showLabel>
<TextInput.Input
value={name}
onChange={(event) => setName(event.target.value)}
required
disabled={disabled}
data-ui-id="ui.settings.account.name"
/>
</TextInput>
<TextInput className="w-full max-w-full" label={t("shared.slug")} showLabel>
<TextInput.Input
value={slug}
// Same slugify-on-type behaviour the old form had.
onChange={(event) => setSlug(UrlUtils.slugify(event.target.value) || "")}
required
disabled={disabled}
data-ui-id="ui.settings.account.slug"
/>
</TextInput>
</div>
<div className="flex w-full flex-col gap-2">
<span className="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-tertiary">{t("shared.icon")}</span>
<div className="flex w-full flex-wrap items-center gap-4">
<Avatar size="large" image={icon || undefined}>
{name.charAt(0).toUpperCase()}
</Avatar>
{icon ? (
<Button variant="secondary" size="small" icon={<FeatherTrash2 />} disabled={disabled} onClick={() => setIcon("")}>
{t("shared.delete")}
</Button>
) : (
<UploadDocuments
disabled={disabled}
accept="image/png, image/jpg, image/jpeg"
icon={<FeatherUpload className="text-heading- font-heading- text-icon-neutral-tertiary" />}
onDropped={(base64) => setIcon(base64)}
/>
)}
</div>
</div>
<div className="flex w-full items-center justify-end border-t border-solid border-border-default pt-4">
<Button
icon={<FeatherSave />}
loading={submitting}
disabled={disabled || nameMissing}
onClick={() => actions.onSaveDetails({ name: name.trim(), slug: slug.trim(), icon })}
data-ui-id="ui.settings.account.submit"
>
{t("shared.save")}
</Button>
</div>
</Card>
<Card data-ui-id="ui.settings.account.anrede">
<SectionHeading title={t("settings:tenant.anrede.title")} description={t("settings:tenant.anrede.description")} />
<InputChoicebox
name="anrede"
value={data.anrede}
onChange={(value) => actions.onChangeAnrede(value as Anrede)}
disabled={submitting}
options={[
{ value: "du", name: t("settings:tenant.anrede.du") },
{ value: "sie", name: t("settings:tenant.anrede.sie") },
]}
/>
</Card>
<Card variant="negative" data-ui-id="ui.settings.account.danger">
<div className="flex w-full flex-col gap-1">
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-feedback-negative">{t("settings.danger.title")}</span>
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary">{t("settings.danger.description")}</span>
</div>
<Button
variant="destructive"
icon={<FeatherTrash2 />}
disabled={!data.canDelete}
onClick={actions.onDeleteWorkspace}
data-ui-id="ui.settings.account.delete"
>
{t("settings.danger.deleteWorkspace")}
</Button>
</Card>
</PageBody>
);
}
@@ -0,0 +1,3 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
exports[`AK-SET-01 settings hubs interim visual baseline > renders all seven compact hub headers and their permanent tab bar 1`] = `"<main data-ui-id="ui.settings.hubs.interim.visualBaseline"><div class="flex w-full flex-col items-start bg-surface-neutral-primary" data-ui-id="ui.settings.hub.account"><div class="flex w-full items-start gap-4 border-b border-solid border-border-default bg-surface-neutral-secondary px-6 py-5 mobile:flex-col mobile:px-4"><div class="flex grow shrink-0 basis-0 flex-col items-start gap-1"><div class="flex items-center gap-2"><h1 class="text-subtitle font-subtitle text-text-neutral-primary mobile:text-heading- mobile:font-heading-">Mein Konto</h1></div><p class="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">Interim-UI</p></div></div><div class="flex w-full flex-col px-6 pt-4 mobile:px-4"><div class="flex w-full items-end"><div class="flex grow shrink-0 basis-0 items-start"><a class="contents no-underline" data-ui-id="ui.settings.hub.account.tab.overview" href="/acme/settings/account" data-discover="true"><div class="group/d5612535 flex w-full cursor-pointer items-center justify-center gap-2 rounded-t-md px-4 py-2.5 hover:border-b-2 hover:border-x-0 hover:border-t-0 hover:border-solid hover:border-brand-brand-border-solid-default hover:bg-surface-neutral-primary active:border-b-2 active:border-x-0 active:border-t-0 active:border-solid active:border-border-default active:bg-surface-neutral-secondary focus-within:shadow-focus border-b-2 border-x-0 border-t-0 border-solid border-brand-brand-border-solid-default bg-surface-neutral-tertiary"><span class="text-text-neutral-secondary group-hover/d5612535:text-text-neutral-primary text-body-small-medium-0 font-body-small-medium-0">Übersicht</span></div></a></div></div></div><div class="w-full"><div data-ui-id="ui.settings.hub.account.fixture">Fixture</div></div></div><div class="flex w-full flex-col items-start bg-surface-neutral-primary" data-ui-id="ui.settings.hub.team"><div class="flex w-full items-start gap-4 border-b border-solid border-border-default bg-surface-neutral-secondary px-6 py-5 mobile:flex-col mobile:px-4"><div class="flex grow shrink-0 basis-0 flex-col items-start gap-1"><div class="flex items-center gap-2"><h1 class="text-subtitle font-subtitle text-text-neutral-primary mobile:text-heading- mobile:font-heading-">Team &amp; Zugriff</h1></div><p class="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">Interim-UI</p></div></div><div class="flex w-full flex-col px-6 pt-4 mobile:px-4"><div class="flex w-full items-end"><div class="flex grow shrink-0 basis-0 items-start"><a class="contents no-underline" data-ui-id="ui.settings.hub.team.tab.overview" href="/acme/settings/team" data-discover="true"><div class="group/d5612535 flex w-full cursor-pointer items-center justify-center gap-2 rounded-t-md px-4 py-2.5 hover:border-b-2 hover:border-x-0 hover:border-t-0 hover:border-solid hover:border-brand-brand-border-solid-default hover:bg-surface-neutral-primary active:border-b-2 active:border-x-0 active:border-t-0 active:border-solid active:border-border-default active:bg-surface-neutral-secondary focus-within:shadow-focus border-b-2 border-x-0 border-t-0 border-solid border-brand-brand-border-solid-default bg-surface-neutral-tertiary"><span class="text-text-neutral-secondary group-hover/d5612535:text-text-neutral-primary text-body-small-medium-0 font-body-small-medium-0">Übersicht</span></div></a></div></div></div><div class="w-full"><div data-ui-id="ui.settings.hub.team.fixture">Fixture</div></div></div><div class="flex w-full flex-col items-start bg-surface-neutral-primary" data-ui-id="ui.settings.hub.workspace"><div class="flex w-full items-start gap-4 border-b border-solid border-border-default bg-surface-neutral-secondary px-6 py-5 mobile:flex-col mobile:px-4"><div class="flex grow shrink-0 basis-0 flex-col items-start gap-1"><div class="flex items-center gap-2"><h1 class="text-subtitle font-subtitle text-text-neutral-primary mobile:text-heading- mobile:font-heading-">Workspace</h1></div><p class="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">Interim-UI</p></div></div><div class="flex w-full flex-col px-6 pt-4 mobile:px-4"><div class="flex w-full items-end"><div class="flex grow shrink-0 basis-0 items-start"><a class="contents no-underline" data-ui-id="ui.settings.hub.workspace.tab.overview" href="/acme/settings/workspace" data-discover="true"><div class="group/d5612535 flex w-full cursor-pointer items-center justify-center gap-2 rounded-t-md px-4 py-2.5 hover:border-b-2 hover:border-x-0 hover:border-t-0 hover:border-solid hover:border-brand-brand-border-solid-default hover:bg-surface-neutral-primary active:border-b-2 active:border-x-0 active:border-t-0 active:border-solid active:border-border-default active:bg-surface-neutral-secondary focus-within:shadow-focus border-b-2 border-x-0 border-t-0 border-solid border-brLine truncated