Update hivegrid-cloud reference to latest main

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
davidandClaude Fable 5 committed 2026-07-08 16:15:37 +02:00
1 parent e98d38e716
commit 7b21524c86
3781 files changed
+373484 -225607

No files matched your search

@@ -1,6 +1,6 @@
import { redirect, type ActionFunctionArgs, type LoaderFunctionArgs } from "react-router";
import { serverOnly$ } from "vite-env-only/macros";
import { loadRequiredWebConfig } from "@toolctrl/config";
import { loadRequiredWebConfig } from "@hivegrid/config";
import { getTranslations } from "~/locale/i18next.server";
import { ADMIN_MFA_DEFAULT_REDIRECT_PATH, ADMIN_MFA_ENROLLMENT_PATH } from "~/utils/auth/mfa/paths";
import { setMfaStepUpState, type MfaStepUpMethod } from "~/utils/auth/mfa/step-up.server";
@@ -0,0 +1,87 @@
import { redirect, type ActionFunctionArgs, type LoaderFunctionArgs } from "react-router";
import { loadRequiredWebConfig } from "@hivegrid/config";
import { buildSelectTenantVM, type SelectTenantData } from "@hivegrid/view-models";
import type { VMState } from "@hivegrid/view-models";
import { getTranslations } from "~/locale/i18next.server";
import { absoluteAppPath } from "~/utils/app/CrossHostUrls";
import { adminGetAllActiveTenantSimple } from "~/utils/db/tenants.db.server";
import { verifyUserHasPermission } from "~/utils/helpers/.server/PermissionsService";
import { getUserInfo, validateCSRFToken } from "~/utils/session.server";
type AdminSelectTenantVM = VMState<SelectTenantData>;
export type AdminSelectTenantLoaderData = {
title: string;
vm: AdminSelectTenantVM;
copy: {
titleKey: string;
subtitleKey: string;
infoTooltipKey: string;
searchPlaceholderKey: string;
emptyKey: string;
noResultsKey: string;
sectionLabelKey: string;
};
showCreateAction: false;
};
export type AdminSelectTenantActionData = {
error?: string;
};
const copy: AdminSelectTenantLoaderData["copy"] = {
titleKey: "admin.selectTenant.title",
subtitleKey: "admin.selectTenant.subtitle",
infoTooltipKey: "admin.selectTenant.infoTooltip",
searchPlaceholderKey: "admin.selectTenant.searchPlaceholder",
emptyKey: "admin.selectTenant.empty",
noResultsKey: "admin.selectTenant.noResults",
sectionLabelKey: "admin.selectTenant.sectionLabel",
};
async function requireAdminTenantSwitchAccess(request: Request) {
const userInfo = await getUserInfo(request);
if (!userInfo.userId) {
throw redirect("/login");
}
await verifyUserHasPermission(request, "admin.accounts.view");
return userInfo;
}
export async function loader({ request }: LoaderFunctionArgs) {
await requireAdminTenantSwitchAccess(request);
const { t } = await getTranslations(request);
const tenants = await adminGetAllActiveTenantSimple();
const vm = buildSelectTenantVM({
tenants: tenants.map((tenant) => ({
id: tenant.id,
name: tenant.name,
slug: tenant.slug,
image: tenant.icon ?? tenant.logo ?? null,
role: null,
subtitle: null,
})),
});
return Response.json({
title: t("admin.selectTenant.title"),
vm,
copy,
showCreateAction: false,
} satisfies AdminSelectTenantLoaderData);
}
export async function action({ request }: ActionFunctionArgs) {
await requireAdminTenantSwitchAccess(request);
const form = await request.formData();
await validateCSRFToken(request, { formData: form });
const tenantId = String(form.get("tenantId") ?? "");
const slug = String(form.get("slug") ?? "");
if (!tenantId || !slug) {
return Response.json({ error: "admin.selectTenant.errors.invalidSelection" } satisfies AdminSelectTenantActionData, { status: 400 });
}
const tenant = (await adminGetAllActiveTenantSimple()).find((candidate) => candidate.id === tenantId);
if (!tenant || tenant.slug !== slug) {
return Response.json({ error: "admin.selectTenant.errors.invalidSelection" } satisfies AdminSelectTenantActionData, { status: 400 });
}
throw redirect(absoluteAppPath(loadRequiredWebConfig().routing, tenant.slug, "dashboard"));
}
@@ -1,6 +1,7 @@
import { useRef, useState } from "react";
import { Form, useActionData, useLoaderData, useNavigation } from "react-router";
import { Form, useActionData, useLoaderData, useNavigate, useNavigation } from "react-router";
import { useTranslation } from "react-i18next";
import { FeatherArrowLeft } from "@subframe/core";
import { useRootData } from "~/utils/data/useRootData";
import { AuthShell } from "~/components/auth/AuthShell";
import { Button } from "~/ui/components/Button";
@@ -10,11 +11,6 @@ import { LinkButton } from "~/ui/components/LinkButton";
import { TextInput } from "~/ui/components/TextInput";
import type { ActionData, LoaderData } from "~/routeModules/auth/login-mfa.impl";
// D-D0a — 2FA-Code-Eingabe nach Davids Subframe-Design ("_2FA _ Code Entry"): Logo + Card
// (Bestaetigung in zwei Schritten) + 6-stellige InputOtp + "Geraet vertrauen"-Checkbox + Bestaetigen +
// Recovery-Code-Toggle. An die bestehende login-mfa-Action verdrahtet (code/recoveryCode/rememberDevice/csrf).
// Die 6 OTP-Boxen werden zu einem hidden "code"-Feld kombiniert (Auto-Advance, Paste, Backspace).
const OTP_LENGTH = 6;
export default function LoginMfaRoute() {
@@ -23,6 +19,7 @@ export default function LoginMfaRoute() {
const data = useLoaderData<LoaderData>();
const actionData = useActionData<ActionData>();
const navigation = useNavigation();
const navigate = useNavigate();
const isSubmitting = navigation.state !== "idle";
const [digits, setDigits] = useState<string[]>(Array(OTP_LENGTH).fill(""));
@@ -39,7 +36,7 @@ export default function LoginMfaRoute() {
next[index] = "";
return next;
}
// Einzelzeichen ODER Paste (z.B. "123456") ab dieser Box vorwaerts fuellen.
for (let k = 0; k < clean.length && index + k < OTP_LENGTH; k++) {
next[index + k] = clean[k];
}
@@ -61,14 +58,24 @@ export default function LoginMfaRoute() {
}
}
function handlePaste(index: number, event: React.ClipboardEvent<HTMLInputElement>) {
const clean = event.clipboardData.getData("text").replace(/\D/g, "");
if (!clean) {
return;
}
event.preventDefault();
handleChange(index, clean);
}
const errorState = Boolean(actionData?.error && navigation.state === "idle");
return (
<AuthShell
title={t("account.loginMfa.twoStepTitle")}
subtitle={t("account.loginMfa.codeSubtitle")}
logoIconOnly
subtitleStrong
subtitleVariant="medium-150"
cardSize="extra-large"
dataUiId="ui.auth.loginMfa.page"
>
<Form method="post" noValidate className="flex w-full flex-col gap-4" data-ui-id="ui.auth.loginMfa.form">
@@ -78,10 +85,10 @@ export default function LoginMfaRoute() {
<input type="hidden" name="rememberDevice" value={trustDevice ? "on" : ""} readOnly />
{!showRecovery ? (
<div className="flex w-full flex-col items-center py-2">
<InputOtp state={errorState ? "error" : "default"} helperText={t("account.loginMfa.codeHelper")}>
<div className="flex w-full flex-col items-center">
<InputOtp state={errorState ? "error" : "default"} title="" helperText={t("account.loginMfa.codeHelper")}>
{Array.from({ length: OTP_LENGTH }).map((_, i) => (
<InputOtp.OtpInputItem key={i} error={errorState}>
<InputOtp.OtpInputItem key={i} error={errorState} disabled={isSubmitting}>
<InputOtp.Input
className="h-auto w-12 flex-none self-stretch"
ref={(el) => {
@@ -90,9 +97,12 @@ export default function LoginMfaRoute() {
value={digits[i]}
onChange={(event) => handleChange(i, event.target.value)}
onKeyDown={(event) => handleKeyDown(i, event)}
onPaste={(event) => handlePaste(i, event)}
inputMode="numeric"
autoComplete={i === 0 ? "one-time-code" : "off"}
maxLength={OTP_LENGTH}
disabled={isSubmitting}
aria-invalid={errorState || undefined}
aria-label={`${t("account.loginMfa.fields.authenticatorCode")} ${i + 1}`}
data-ui-id={i === 0 ? "ui.auth.loginMfa.code" : undefined}
/>
@@ -120,7 +130,7 @@ export default function LoginMfaRoute() {
data-ui-id="ui.auth.loginMfa.rememberDevice"
/>
<Button type="submit" loading={isSubmitting} disabled={isSubmitting} data-ui-id="ui.auth.loginMfa.submit">
<Button type="submit" className="h-9 w-full flex-none" loading={isSubmitting} disabled={isSubmitting} data-ui-id="ui.auth.loginMfa.submit">
{t("account.loginMfa.confirm")}
</Button>
@@ -131,7 +141,7 @@ export default function LoginMfaRoute() {
) : null}
</Form>
<div className="flex w-full items-center justify-center">
<div className="flex w-full flex-col items-center justify-center gap-2">
<LinkButton
size="small"
hideIcon
@@ -140,6 +150,15 @@ export default function LoginMfaRoute() {
>
{showRecovery ? t("account.loginMfa.useAuthenticator") : t("account.loginMfa.useRecoveryCode")}
</LinkButton>
<LinkButton
size="small"
icon={<FeatherArrowLeft />}
iconRight={null}
onClick={() => navigate("/login")}
data-ui-id="ui.auth.loginMfa.backToLogin"
>
{t("account.loginMfa.backToLogin")}
</LinkButton>
</div>
</AuthShell>
);
@@ -1,34 +1,40 @@
import { useMemo, useState } from "react";
import { Form, useActionData, useLoaderData, useNavigate, useNavigation } from "react-router";
import { useTranslation } from "react-i18next";
import {
FeatherChevronRight,
FeatherPlus,
FeatherUserPlus,
FeatherUsers,
} from "@subframe/core";
import { FeatherChevronRight, FeatherInfo, FeatherPlus } from "@subframe/core";
import * as SubframeCore from "@subframe/core";
import { useRootData } from "~/utils/data/useRootData";
import { Avatar } from "~/ui/components/Avatar";
import { Button } from "~/ui/components/Button";
import { Card } from "~/ui/components/Card";
import { DropdownMenu } from "~/ui/components/DropdownMenu";
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
import { ErrorState } from "~/ui/components/ErrorState";
import { Logo } from "~/ui/components/Logo";
import { SearchInput } from "~/ui/components/SearchInput";
import { Tag_Label } from "~/ui/components/Tag_Label";
import { IconButton } from "~/ui/components/IconButton";
import { LinkButton } from "~/ui/components/LinkButton";
import { TextInput } from "~/ui/components/TextInput";
import { Tooltip } from "~/ui/components/Tooltip";
import { AuthShell } from "~/components/auth/AuthShell";
import type { RoleTone } from "@hivegrid/view-models";
import type { ActionData, LoaderData } from "~/routeModules/auth/select-tenant.impl";
// D-D0a — Flow "Login Tenantauswahl (Admin)". 1:1 an Davids Subframe-Page "Tenantauswahl": Logo +
// Karten-Box (Such-Feld immer sichtbar, Profil-Karten, Divider, "Profil hinzufuegen"-Dropdown). An die
// echten Tenants des Users (Loader-VM) verdrahtet: Karte = Form-Submit -> Action (CSRF + Membership-
// Check serverseitig) -> Tenant-Space. SearchInput filtert client-seitig. Fehler/Empty via ~/ui ErrorState.
// data-ui-id-Marker bleiben beim spaeteren Subframe-Swap erhalten.
// D-D0a / WF-P2 — Flow "Workspace Auswahl". 1:1 an Davids Subframe-Page "S01 Workspace Auswahl":
// AuthShell (Davids echte Card, large) + Titel mit Info-Tooltip + Untertitel + Such-Feld (TextInput
// type=search) + "ZULETZT GENUTZT"-Sektion + Workspace-Zeilen (Avatar, Name + Rollen-Badge, Untertitel,
// Chevron, Hover) + Divider + "Neuen Workspace anlegen"-LinkButton. An die echten Tenants des Users
// (Loader-VM) verdrahtet: Zeile = Form-Submit -> Action (CSRF + Membership-Check serverseitig) ->
// Tenant-Space. TextInput filtert client-seitig. data-ui-id-Marker bleiben fuer den Subframe-Swap erhalten.
// Davids Demo-Metadaten (Branche / Mitgliederzahl / "zuletzt aktiv" / "Aktiv"/"Gesperrt"-Status, gesperrte
// Zeile) haben kein Backend im VM und werden NICHT erfunden -> nur reale VM-Daten gerendert.
const ROLE_BADGE_FARBE: Record<RoleTone, "subtle-negative" | "subtle-blue" | "subtle-positive" | "subtle-neutral"> = {
"red-subtle": "subtle-negative",
"blue-subtle": "subtle-blue",
"green-subtle": "subtle-positive",
"neutral-subtle": "subtle-neutral",
};
export default function SelectTenantRoute() {
const { t } = useTranslation();
const { csrf } = useRootData();
const { vm } = useLoaderData<LoaderData>();
const { vm, copy, showCreateAction = true } = useLoaderData<LoaderData>();
const actionData = useActionData<ActionData>();
const navigate = useNavigate();
const navigation = useNavigation();
@@ -42,53 +48,84 @@ export default function SelectTenantRoute() {
return tenants.filter((tenant) => tenant.name.toLowerCase().includes(q));
}, [tenants, query]);
const titleNode = (
<span className="inline-flex items-center gap-2">
{t(copy?.titleKey ?? "account.selectTenant.title")}
<SubframeCore.Tooltip.Provider>
<SubframeCore.Tooltip.Root>
<SubframeCore.Tooltip.Trigger asChild>
<IconButton
variant="ghost"
size="small"
icon={<FeatherInfo />}
aria-label={t(copy?.infoTooltipKey ?? "account.selectTenant.infoTooltip")}
data-ui-id="ui.auth.selectTenant.info"
/>
</SubframeCore.Tooltip.Trigger>
<SubframeCore.Tooltip.Portal>
<SubframeCore.Tooltip.Content side="top" align="center" sideOffset={6} asChild>
<Tooltip>{t(copy?.infoTooltipKey ?? "account.selectTenant.infoTooltip")}</Tooltip>
</SubframeCore.Tooltip.Content>
</SubframeCore.Tooltip.Portal>
</SubframeCore.Tooltip.Root>
</SubframeCore.Tooltip.Provider>
</span>
);
return (
<div
className="flex min-h-screen w-full flex-col items-center justify-center gap-8 bg-surface-neutral-primary px-4 py-12"
data-ui-id="ui.auth.selectTenant.page"
<AuthShell
title={titleNode}
subtitle={t(copy?.subtitleKey ?? "account.selectTenant.subtitle")}
titleAlign="center"
headerGap="gap-2"
subtitleVariant="regular-150"
cardSize="large"
cardClassName="max-w-[480px]"
showLogo={true}
dataUiId="ui.auth.selectTenant.page"
>
<Logo size="64" />
<div className="flex w-full max-w-[36rem] flex-col items-start gap-6 rounded-lg border border-solid border-border-default bg-surface-neutral-secondary px-8 py-8 shadow-lg">
<div className="flex w-full flex-col items-center gap-2">
<h1 className="text-heading- font-heading- text-text-neutral-primary">{t("account.selectTenant.title")}</h1>
<p className="w-full text-center text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">
{t("account.selectTenant.subtitle")}
</p>
</div>
{actionData?.error ? (
<ErrorState
variant="full-width"
hideCancel
title={t(actionData.error)}
data-ui-id="ui.auth.selectTenant.error"
/>
) : null}
{actionData?.error ? (
<ErrorState
variant="full-width"
hideCancel
title={t(actionData.error)}
data-ui-id="ui.auth.selectTenant.error"
/>
) : null}
{vm.status === "ready" ? (
<SearchInput
className="h-auto w-full min-w-[288px] flex-none"
fillContainer
hideShortcut
placeholder={t("account.selectTenant.searchPlaceholder")}
{vm.status === "ready" ? (
<TextInput
className="h-auto w-full flex-none"
variant="filled"
fillContainer
type="search"
data-ui-id="ui.auth.selectTenant.search"
>
<TextInput.Input
type="search"
placeholder={t(copy?.searchPlaceholderKey ?? "account.selectTenant.searchPlaceholder")}
value={query}
onChange={(event) => setQuery(event.target.value)}
aria-label={t("account.selectTenant.searchPlaceholder")}
data-ui-id="ui.auth.selectTenant.search"
aria-label={t(copy?.searchPlaceholderKey ?? "account.selectTenant.searchPlaceholder")}
/>
) : null}
</TextInput>
) : null}
{vm.status === "empty" ? (
<div className="flex w-full flex-col items-center gap-4 py-4 text-center" data-ui-id="ui.auth.selectTenant.empty">
<p className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">
{t("account.selectTenant.empty")}
</p>
</div>
) : (
<div className="flex w-full flex-col items-start gap-2" data-ui-id="ui.auth.selectTenant.list">
{vm.status === "empty" ? (
<div className="flex w-full flex-col items-center gap-4 py-4 text-center" data-ui-id="ui.auth.selectTenant.empty">
<p className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">
{t(copy?.emptyKey ?? "account.selectTenant.empty")}
</p>
</div>
) : (
<div className="flex w-full flex-col items-center gap-2" data-ui-id="ui.auth.selectTenant.list">
<span className="text-body-extra-small-semibold-0 font-body-extra-small-semibold-0 text-text-neutral-tertiary tracking-wide">
{t(copy?.sectionLabelKey ?? "account.selectTenant.recentlyUsed")}
</span>
<div className="flex w-full flex-col items-start">
{visibleTenants.length === 0 ? (
<p className="w-full py-4 text-center text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">
{t("account.selectTenant.noResults")}
{t(copy?.noResultsKey ?? "account.selectTenant.noResults")}
</p>
) : (
visibleTenants.map((tenant) => (
@@ -99,75 +136,54 @@ export default function SelectTenantRoute() {
<button
type="submit"
disabled={isSubmitting}
className="w-full text-left transition disabled:cursor-default disabled:opacity-60"
className="group/row flex w-full cursor-pointer items-center gap-3 rounded-md px-3 py-3 text-left transition hover:bg-surface-neutral-tertiary disabled:cursor-default disabled:opacity-60"
data-ui-id="ui.auth.selectTenant.card"
>
<Card className="group/card transition hover:border-border-strong hover:bg-surface-neutral-tertiary">
<div className="flex w-full items-center gap-4">
<Avatar size="medium" color={tenant.avatarColor} image={tenant.avatarImage}>
{tenant.avatarInitials}
</Avatar>
<div className="flex grow shrink-0 basis-0 flex-col items-start gap-1">
<div className="flex w-full items-center gap-2">
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">
{tenant.name}
</span>
{tenant.role && tenant.roleTone ? (
<Tag_Label tone={tenant.roleTone} noAction size="small">
{t(tenant.roleLabelKey ?? "")}
</Tag_Label>
) : null}
</div>
<span className="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-neutral-tertiary">
{[tenant.subtitle, tenant.isCurrent ? t("account.selectTenant.lastUsed") : null]
.filter(Boolean)
.join(" · ")}
</span>
</div>
<FeatherChevronRight className="text-body-large font-body-large text-icon-neutral-tertiary group-hover/card:text-icon-neutral-primary" />
<Avatar size="medium" color={tenant.avatarColor} image={tenant.avatarImage}>
{tenant.avatarInitials}
</Avatar>
<div className="flex grow shrink-0 basis-0 flex-col items-start gap-0.5">
<div className="flex w-full items-center gap-2">
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">
{tenant.name}
</span>
{tenant.role && tenant.roleTone ? (
<BadgeFeedback farbe={ROLE_BADGE_FARBE[tenant.roleTone]} size="small">
{t(tenant.roleLabelKey ?? "")}
</BadgeFeedback>
) : null}
</div>
</Card>
<span className="w-full text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-neutral-tertiary">
{[tenant.subtitle, tenant.isCurrent ? t("account.selectTenant.lastUsed") : null]
.filter(Boolean)
.join(" · ")}
</span>
</div>
<FeatherChevronRight className="text-body-default-regular-0 font-body-default-regular-0 text-icon-neutral-tertiary group-hover/row:text-icon-neutral-primary" />
</button>
</Form>
))
)}
</div>
)}
</div>
)}
<div className="flex h-px w-full flex-none flex-col items-center bg-border-default" />
{showCreateAction ? (
<>
<div className="flex h-px w-full flex-none flex-col items-center bg-border-default" />
<SubframeCore.DropdownMenu.Root>
<SubframeCore.DropdownMenu.Trigger asChild>
<Button
className="h-auto w-full flex-none"
<div className="flex w-full flex-col items-center justify-center gap-6">
<LinkButton
icon={<FeatherPlus />}
data-ui-id="ui.auth.selectTenant.addProfile"
iconRight={null}
onClick={() => navigate("/new-account")}
data-ui-id="ui.auth.selectTenant.addNew"
>
{t("account.selectTenant.addProfile")}
</Button>
</SubframeCore.DropdownMenu.Trigger>
<SubframeCore.DropdownMenu.Portal>
<SubframeCore.DropdownMenu.Content side="bottom" align="center" sideOffset={4} asChild>
<DropdownMenu className="h-auto w-auto flex-none">
<DropdownMenu.DropdownItem
icon={<FeatherUsers />}
onClick={() => navigate("/login")}
data-ui-id="ui.auth.selectTenant.addExisting"
>
{t("account.selectTenant.addExisting")}
</DropdownMenu.DropdownItem>
<DropdownMenu.DropdownItem
icon={<FeatherUserPlus />}
onClick={() => navigate("/new-account")}
data-ui-id="ui.auth.selectTenant.addNew"
>
{t("account.selectTenant.addNew")}
</DropdownMenu.DropdownItem>
</DropdownMenu>
</SubframeCore.DropdownMenu.Content>
</SubframeCore.DropdownMenu.Portal>
</SubframeCore.DropdownMenu.Root>
</div>
</div>
{t("account.selectTenant.addNew")}
</LinkButton>
</div>
</>
) : null}
</AuthShell>
);
}
@@ -1,7 +1,7 @@
import { redirect, type ActionFunctionArgs, type LoaderFunctionArgs } from "react-router";
import { serverOnly$ } from "vite-env-only/macros";
import { buildSelectTenantVM, type SelectTenantData, type TenantRole } from "@toolctrl/view-models";
import type { VMState } from "@toolctrl/view-models";
import { buildSelectTenantVM, type SelectTenantData, type TenantRole } from "@hivegrid/view-models";
import type { VMState } from "@hivegrid/view-models";
import { TenantUserType } from "~/application/enums/tenants/TenantUserType";
import { appPath } from "~/utils/app/CanonicalUrlUtils";
import { getMyTenants, getTenantUserType } from "~/utils/db/tenants.db.server";
@@ -16,8 +16,21 @@ import { getUserInfo, validateCSRFToken } from "~/utils/session.server";
export type SelectTenantVM = VMState<SelectTenantData>;
export type SelectTenantCopy = {
titleKey?: string;
subtitleKey?: string;
infoTooltipKey?: string;
searchPlaceholderKey?: string;
emptyKey?: string;
noResultsKey?: string;
sectionLabelKey?: string;
};
export type LoaderData = {
vm: SelectTenantVM;
title?: string;
copy?: SelectTenantCopy;
showCreateAction?: boolean;
};
export type ActionData = {