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

@@ -6,16 +6,21 @@
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { FeatherBell } from "@subframe/core";
import type { NotificationCenterItemVM, NotificationCenterVM } from "@hivegrid/view-models";
import { Alert } from "~/ui/components/Alert";
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
import { Button } from "~/ui/components/Button";
import { EmptyState } from "~/ui/components/EmptyState";
import { Tabs } from "~/ui/components/Tabs";
import { PAGE_HEADER_ICON_CLASS, PageBody, PageHeader, PageShell } from "../shared/PageShell";
import { APP_TIME_ZONE } from "~/locale/format";
export type NotificationCenterActions = {
onMarkRead: (deliveryId: string) => void;
onMarkAllRead: () => void;
/** Deeplink click: host marks the delivery read (if unread) and navigates. */
onOpen: (item: NotificationCenterItemVM) => void;
};
export type NotificationCenterPageProps = {
@@ -44,9 +49,28 @@ export function NotificationCenterPage({ vm, connectionStatusKey, actions }: Not
const { t, i18n } = useTranslation();
const [activeTab, setActiveTab] = useState<"all" | "unread">("all");
const header = (
<PageHeader
icon={<FeatherBell className={PAGE_HEADER_ICON_CLASS} />}
title={t("notifications.center.title")}
subtitle={t("notifications.center.diagnostics")}
actions={
vm.status === "ready" && vm.data && vm.data.unreadCount > 0 ? (
<Button variant="secondary" onClick={() => actions.onMarkAllRead()} data-ui-id="ui.notifications.center.bulkClear">
{t("notifications.center.bulkClear")}
</Button>
) : undefined
}
/>
);
// Loading / not-ready: keep the marker so the shell + e2e see a stable surface.
if (vm.status !== "ready" || !vm.data) {
return <div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.notifications.center" />;
return (
<PageShell uiId="ui.notifications.center">
{header}
</PageShell>
);
}
const { items, totalCount, unreadCount, emptyHeadlineKey, emptyBodyKey, unreadEmptyKey } = vm.data;
@@ -54,26 +78,20 @@ export function NotificationCenterPage({ vm, connectionStatusKey, actions }: Not
const numberFormatter = new Intl.NumberFormat(i18n.language);
return (
<div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.notifications.center">
{/* Header: title + subtitle (0px rhythm) */}
<div className="flex flex-col gap-0">
<span className="text-heading-2 font-heading-2 text-text-neutral-primary">{t("notifications.center.title")}</span>
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
{t("notifications.center.diagnostics")}
</span>
<PageShell uiId="ui.notifications.center">
{header}
<PageBody className="mx-auto max-w-5xl">
<span className="sr-only" role="status">
{t(connectionStatusKey)}
</span>
</div>
{totalCount === 0 ? (
<div data-ui-id="ui.notifications.center.empty">
<EmptyState title={t(emptyHeadlineKey)} body={t(emptyBodyKey)} />
</div>
) : (
<>
<div className="flex flex-wrap items-center justify-between gap-4">
<div className="max-w-[360px] flex-1" data-ui-id="ui.notifications.center.tabs">
{totalCount === 0 ? (
<div data-ui-id="ui.notifications.center.empty">
<EmptyState title={t(emptyHeadlineKey)} body={t(emptyBodyKey)} />
</div>
) : (
<>
<div className="max-w-[360px]" data-ui-id="ui.notifications.center.tabs">
<Tabs>
<Tabs.Item active={activeTab === "all"} onClick={() => setActiveTab("all")} role="tab" aria-selected={activeTab === "all"}>
{`${t("notifications.center.tabs.all")} (${numberFormatter.format(totalCount)})`}
@@ -88,35 +106,40 @@ export function NotificationCenterPage({ vm, connectionStatusKey, actions }: Not
</Tabs.Item>
</Tabs>
</div>
{unreadCount > 0 ? (
<Button variant="secondary" onClick={() => actions.onMarkAllRead()} data-ui-id="ui.notifications.center.bulkClear">
{t("notifications.center.bulkClear")}
</Button>
) : null}
</div>
{visibleItems.length === 0 ? (
<div data-ui-id="ui.notifications.center.unreadEmpty">
<EmptyState title={t(unreadEmptyKey)} body={t(emptyBodyKey)} />
</div>
) : (
<ul className="flex list-none flex-col gap-4 p-0" aria-label={String(t("notifications.center.listLabel"))}>
{visibleItems.map((item) => (
<NotificationCard key={item.id} item={item} onMarkRead={actions.onMarkRead} />
))}
</ul>
)}
</>
)}
</div>
{visibleItems.length === 0 ? (
<div data-ui-id="ui.notifications.center.unreadEmpty">
<EmptyState title={t(unreadEmptyKey)} body={t(emptyBodyKey)} />
</div>
) : (
<ul className="flex list-none flex-col gap-4 p-0" aria-label={String(t("notifications.center.listLabel"))}>
{visibleItems.map((item) => (
<NotificationCard key={item.id} item={item} onMarkRead={actions.onMarkRead} onOpen={actions.onOpen} />
))}
</ul>
)}
</>
)}
</PageBody>
</PageShell>
);
}
function NotificationCard({ item, onMarkRead }: { item: NotificationCenterItemVM; onMarkRead: (deliveryId: string) => void }) {
function NotificationCard({
item,
onMarkRead,
onOpen,
}: {
item: NotificationCenterItemVM;
onMarkRead: (deliveryId: string) => void;
onOpen: (item: NotificationCenterItemVM) => void;
}) {
const { t, i18n } = useTranslation();
const dateTimeFormatter = new Intl.DateTimeFormat(i18n.language, { dateStyle: "medium", timeStyle: "short" });
const dateTimeFormatter = new Intl.DateTimeFormat(i18n.language, { timeZone: APP_TIME_ZONE, dateStyle: "medium", timeStyle: "short" });
const messageLabel = i18n.exists(item.messageKey) ? String(t(item.messageKey)) : String(t("notifications.center.unknownMessage"));
const baseMessageLabel = i18n.exists(item.messageKey) ? String(t(item.messageKey)) : String(t("notifications.center.unknownMessage"));
// Subject context (e.g. task title) is appended and ellipsis-truncated via CSS.
const messageLabel = item.subjectLabel ? `${baseMessageLabel}: ${item.subjectLabel}` : baseMessageLabel;
const enumLabel = (key: string, fallbackKey: string) => (i18n.exists(key) ? String(t(key)) : String(t(fallbackKey)));
const formatTimestamp = (iso: string | null) =>
iso ? dateTimeFormatter.format(new Date(iso)) : String(t("notifications.center.timestamps.notRecorded"));
@@ -132,14 +155,30 @@ function NotificationCard({ item, onMarkRead }: { item: NotificationCenterItemVM
{item.deeplinkHref ? (
<a
href={item.deeplinkHref}
className="text-body-default-medium-0 font-body-default-medium-0 text-text-feedback-link-default no-underline"
className="line-clamp-1 break-all text-body-default-medium-0 font-body-default-medium-0 text-text-feedback-link-default no-underline"
title={messageLabel}
data-ui-id="ui.notifications.center.deeplink"
onClick={(event) => {
// Let modified clicks (new tab etc.) keep native anchor behavior.
if (event.defaultPrevented || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey || event.button !== 0) return;
event.preventDefault();
onOpen(item);
}}
>
{messageLabel}
</a>
) : (
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{messageLabel}</span>
<span className="line-clamp-1 break-all text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary" title={messageLabel}>
{messageLabel}
</span>
)}
{item.tagKey && item.tagTone ? (
<span className="mt-1 self-start" data-ui-id="ui.notifications.center.tag">
<BadgeFeedback farbe={item.tagTone} size="small">
{t(item.tagKey)}
</BadgeFeedback>
</span>
) : null}
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary">
{enumLabel(item.categoryKey, "notifications.center.categories.unknown")} ·{" "}
{enumLabel(item.channelKey, "notifications.center.channels.unknown")} · {formatTimestamp(item.sentAtIso ?? item.createdAtIso)}
@@ -6,9 +6,12 @@
// D-P3 ships.
import { useTranslation } from "react-i18next";
import { FeatherBell, FeatherLock } from "@subframe/core";
import type { NotificationSettingChannel, NotificationSettingsVM } from "@hivegrid/view-models";
import { Alert } from "~/ui/components/Alert";
import { Card } from "~/ui/components/Card";
import { Switch } from "~/ui/components/Switch";
import { PAGE_HEADER_ICON_CLASS, PageBody, PageHeader, PageIntro, PageShell } from "../shared/PageShell";
export type NotificationSettingsActions = {
onTogglePreference: (input: { category: string; channel: NotificationSettingChannel; enabled: boolean }) => void;
@@ -21,126 +24,139 @@ export type NotificationSettingsPageProps = {
/** Plain-text result of the last save action (null = nothing saved yet). */
saveState: { ok: boolean; errorText?: string } | null;
actions: NotificationSettingsActions;
/** Inside the Mein-Konto hub (AK-SET-01) the hub owns the header. */
embedded?: boolean;
};
export function NotificationSettingsPage({ vm, saveState, actions }: NotificationSettingsPageProps) {
export function NotificationSettingsPage({ vm, saveState, actions, embedded = false }: NotificationSettingsPageProps) {
const { t } = useTranslation();
// Loading / not-ready: keep the marker so the shell + e2e see a stable surface.
if (vm.status !== "ready" || !vm.data) {
return <div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.settings.notifications.page" />;
return (
<PageShell uiId="ui.settings.notifications.page">
{embedded ? null : (
<PageHeader
icon={<FeatherBell className={PAGE_HEADER_ICON_CLASS} />}
title={t("settings.notifications.heading")}
subtitle={t("settings.notifications.description")}
/>
)}
<PageBody>{null}</PageBody>
</PageShell>
);
}
const { groups, allEmailsDisabled } = vm.data;
return (
<div className="mx-auto flex w-full max-w-3xl flex-col gap-6 p-6" data-ui-id="ui.settings.notifications.page">
{/* Header: title + subtitle (0px rhythm) */}
<div className="flex flex-col gap-0">
<span className="text-heading-2 font-heading-2 text-text-neutral-primary">{t("settings.notifications.heading")}</span>
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
{t("settings.notifications.description")}
</span>
</div>
{saveState ? (
<div data-ui-id="ui.settings.notifications.saveState">
{saveState.ok ? (
<Alert variant="success" title={t("settings.notifications.saved")} />
) : (
<Alert variant="error" title={saveState.errorText ?? t("settings.notifications.errors.invalidPreferenceAction")} />
)}
</div>
) : null}
{/* Master switch: all emails off (card surface, 16px padding) */}
<div
className="flex flex-wrap items-center justify-between gap-4 rounded-md border border-solid border-border-default bg-surface-neutral-primary p-4"
data-ui-id="ui.settings.notifications.master.email"
>
<div className="flex flex-col gap-0">
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">
{t("settings.notifications.master.heading")}
</span>
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary">
{t("settings.notifications.master.description")}
</span>
</div>
<label className="flex items-center gap-2">
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-primary">
{t("settings.notifications.master.disableAllEmails")}
</span>
<Switch
checked={allEmailsDisabled}
onCheckedChange={(checked: boolean) => actions.onSetEmailMaster(checked)}
data-ui-id="ui.settings.notifications.master.switch"
/>
</label>
</div>
{/* Event types grouped per module (A6) */}
<div className="flex flex-col gap-4">
{groups.map((group) => (
<div
key={group.module}
className="flex flex-col rounded-md border border-solid border-border-default bg-surface-neutral-primary"
data-ui-id={`ui.settings.notifications.module.${group.module}`}
>
<span className="border-b border-solid border-border-default px-4 py-2 text-body-small-medium-0 font-body-small-medium-0 uppercase text-text-neutral-tertiary">
{t(group.moduleLabelKey)}
</span>
{group.categories.map((category) => (
<div
key={category.category}
className="flex flex-wrap items-center justify-between gap-4 p-4"
data-ui-id={`ui.settings.notifications.category.${category.category}`}
>
<div className="flex flex-col gap-0">
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">
{t(category.labelKey)}
</span>
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary">
{t("settings.notifications.categoryDescription", { category: String(t(category.labelKey)).toLowerCase() })}
</span>
</div>
<div className="flex flex-wrap items-center gap-4">
<ChannelToggle
label={t("settings.notifications.channels.inApp")}
checked={category.channels.IN_APP}
uiId={`ui.settings.notifications.preference.${category.category}.in_app`}
onChange={(enabled) => actions.onTogglePreference({ category: category.category, channel: "IN_APP", enabled })}
/>
<ChannelToggle
label={t("settings.notifications.channels.email")}
checked={category.channels.EMAIL}
uiId={`ui.settings.notifications.preference.${category.category}.email`}
onChange={(enabled) => actions.onTogglePreference({ category: category.category, channel: "EMAIL", enabled })}
/>
</div>
</div>
))}
<PageShell uiId="ui.settings.notifications.page">
{embedded ? null : (
<PageHeader
icon={<FeatherBell className={PAGE_HEADER_ICON_CLASS} />}
title={t("settings.notifications.heading")}
subtitle={t("settings.notifications.description")}
/>
)}
<PageBody>
<div className="flex w-full justify-center">
<div className="flex w-full max-w-5xl flex-col gap-6">
{embedded ? <PageIntro uiId="ui.settings.notifications.intro">{t("settings.notifications.description")}</PageIntro> : null}
{saveState ? (
<div data-ui-id="ui.settings.notifications.saveState">
{saveState.ok ? (
<Alert variant="success" title={t("settings.notifications.saved")} />
) : (
<Alert variant="error" title={saveState.errorText ?? t("settings.notifications.errors.invalidPreferenceAction")} />
)}
</div>
))}
</div>
</div>
) : null}
{/* Master switch: all emails off (card surface, 16px padding) */}
<Card className="flex-row flex-wrap items-center justify-between" data-ui-id="ui.settings.notifications.master.email">
<div className="flex flex-col gap-0">
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">
{t("settings.notifications.master.heading")}
</span>
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary">
{t("settings.notifications.master.description")}
</span>
</div>
<label className="flex items-center gap-2">
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-primary">
{t("settings.notifications.master.disableAllEmails")}
</span>
<Switch
checked={allEmailsDisabled}
onCheckedChange={(checked: boolean) => actions.onSetEmailMaster(checked)}
aria-label={t("settings.notifications.master.disableAllEmails")}
data-ui-id="ui.settings.notifications.master.switch"
/>
</label>
</Card>
{/* Event types grouped per module (A6) */}
<div className="flex w-full flex-col gap-4">
{groups.map((group) => (
<Card key={group.module} className="gap-0 p-0" data-ui-id={`ui.settings.notifications.module.${group.module}`}>
<span className="border-border-default text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-tertiary w-full border-b border-solid px-4 py-2 uppercase">
{t(group.moduleLabelKey)}
</span>
{group.categories.map((category) => (
<div
key={category.category}
className="flex w-full flex-wrap items-center justify-between gap-4 p-4"
data-ui-id={`ui.settings.notifications.category.${category.category}`}
>
<div className="flex flex-col gap-0">
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{t(category.labelKey)}</span>
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary">
{category.locked
? t("settings.notifications.lockedDescription")
: t("settings.notifications.categoryDescription", { category: t(category.labelKey) })}
</span>
</div>
{category.locked ? (
<span
className="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-tertiary flex items-center gap-1"
data-ui-id={`ui.settings.notifications.locked.${category.category}`}
>
<FeatherLock className="text-body-small-regular-0 font-body-small-regular-0 text-icon-neutral-tertiary" />
{t("settings.notifications.alwaysOn")}
</span>
) : (
<div className="flex flex-wrap items-center gap-4">
<ChannelToggle
label={t("settings.notifications.channels.inApp")}
checked={category.channels.IN_APP}
uiId={`ui.settings.notifications.preference.${category.category}.in_app`}
onChange={(enabled) => actions.onTogglePreference({ category: category.category, channel: "IN_APP", enabled })}
/>
<ChannelToggle
label={t("settings.notifications.channels.email")}
checked={category.channels.EMAIL}
uiId={`ui.settings.notifications.preference.${category.category}.email`}
onChange={(enabled) => actions.onTogglePreference({ category: category.category, channel: "EMAIL", enabled })}
/>
</div>
)}
</div>
))}
</Card>
))}
</div>
</div>
</div>
</PageBody>
</PageShell>
);
}
function ChannelToggle({
label,
checked,
uiId,
onChange,
}: {
label: string;
checked: boolean;
uiId: string;
onChange: (enabled: boolean) => void;
}) {
function ChannelToggle({ label, checked, uiId, onChange }: { label: string; checked: boolean; uiId: string; onChange: (enabled: boolean) => void }) {
return (
<label className="flex items-center gap-2" data-ui-id={uiId}>
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-primary">{label}</span>
<Switch checked={checked} onCheckedChange={onChange} />
<Switch checked={checked} onCheckedChange={onChange} aria-label={label} />
</label>
);
}
@@ -10,6 +10,8 @@ import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
import { Button } from "~/ui/components/Button";
import { Drawer } from "~/ui/components/Drawer";
import { EmptyState } from "~/ui/components/EmptyState";
import { APP_TIME_ZONE } from "~/locale/format";
import { AppLink } from "~/components/app/AppLink";
const DRAWER_MAX_ITEMS = 10;
@@ -24,7 +26,7 @@ export type NotificationsDrawerProps = {
export function NotificationsDrawer({ open, items, allHref, onClose }: NotificationsDrawerProps) {
const { t, i18n } = useTranslation();
const visibleItems = items.slice(0, DRAWER_MAX_ITEMS);
const dateTimeFormatter = new Intl.DateTimeFormat(i18n.language, { dateStyle: "short", timeStyle: "short" });
const dateTimeFormatter = new Intl.DateTimeFormat(i18n.language, { timeZone: APP_TIME_ZONE, dateStyle: "short", timeStyle: "short" });
return (
<Drawer open={open} onOpenChange={(nextOpen: boolean) => (nextOpen ? undefined : onClose())}>
@@ -50,9 +52,9 @@ export function NotificationsDrawer({ open, items, allHref, onClose }: Notificat
)}
<div className="flex justify-end">
<a href={allHref} className="no-underline" data-ui-id="ui.notifications.drawer.showAll">
<AppLink href={allHref} className="no-underline" data-ui-id="ui.notifications.drawer.showAll">
<Button variant="secondary">{t("notifications.center.drawer.showAll")}</Button>
</a>
</AppLink>
</div>
</div>
</Drawer.Content>
@@ -89,9 +91,9 @@ function DrawerItem({ item, formatter }: { item: NotificationCenterItemVM; forma
data-read={item.isRead}
>
{item.deeplinkHref ? (
<a href={item.deeplinkHref} className="no-underline" data-ui-id="ui.notifications.drawer.deeplink">
<AppLink href={item.deeplinkHref} className="no-underline" data-ui-id="ui.notifications.drawer.deeplink">
{body}
</a>
</AppLink>
) : (
body
)}