Update hivegrid-cloud reference to latest main
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e98d38e716
commit
7b21524c86
3781 files changed
+373484
-225607
No files matched your search
+130
-114
@@ -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>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user