// VD-MCP Interim-UI (AD-28) — "Mit KI verbinden" as a shell dialog, modelled on // the Subframe "Connect to code" modal: one accordion per client, each step a // copyable command or URL. Presentational only: the shell injects the VM and the // revoke callback, so there is no useLoaderData/useFetcher in here (DoD A.5). // Final Subframe optics land as a tracked design-nachzug. import { useTranslation } from "react-i18next"; import { FeatherX } from "@subframe/core"; import type { McpClientGuideVM, McpConnectionVM, McpConnectVM } from "@hivegrid/view-models"; import { Accordion } from "~/ui/components/Accordion"; import { Button } from "~/ui/components/Button"; import { CopyToClipboardButton } from "~/ui/components/CopyToClipboardButton"; import { Dialog } from "~/ui/components/Dialog"; import { IconButton } from "~/ui/components/IconButton"; import { useLocaleFormatters } from "~/locale/format"; import { ClientIcon } from "./ClientIcon"; export type McpConnectDialogProps = { open: boolean; onOpenChange: (open: boolean) => void; vm: McpConnectVM; /** Cuts one client's tokens; the shell reloads the VM afterwards. */ onRevoke: (clientId: string) => void; /** Client id currently being revoked, for the pending button state. */ revokingClientId?: string | null; }; export function McpConnectDialog({ open, onOpenChange, vm, onRevoke, revokingClientId = null }: McpConnectDialogProps) { const { t } = useTranslation(); return (
{t("mcp.connect.title")} {vm.status === "ready" ? t("mcp.connect.subtitle", { tenantName: vm.data.tenantName, appName: vm.data.appName }) : t("mcp.connect.subtitleFallback")}
} aria-label={t("shared.close")} onClick={() => onOpenChange(false)} />
{vm.status === "loading" || vm.status === "idle" ? (

{t("mcp.connect.loading")}

) : null} {vm.status === "error" ? (

{t(vm.error.messageKey, { defaultValue: t("mcp.connect.error") })}

) : null} {vm.status === "ready" ? ( <>
{t("mcp.connect.connectorHeading")} {t("mcp.connect.connectorHint")}
{t("mcp.connect.setupHeading")} {vm.data.guides.map((guide) => ( ))}
{t("mcp.connect.connectionsHeading")} {vm.data.connections.length === 0 ? (

{t("mcp.connect.connections.empty")}

) : (
    {vm.data.connections.map((connection) => ( ))}
)}
) : null}
); } function GuideAccordion({ guide }: { guide: McpClientGuideVM }) { const { t } = useTranslation(); return ( {t(guide.labelKey)} } >
{guide.steps.map((step) => (
{t(step.titleKey)} {step.hintKey ? ( {t(step.hintKey)} ) : null} {step.copyText ? : null}
))}
); } function CopyRow({ value, label, uiId }: { value: string; label: string; uiId: string }) { return (
{value}
); } function ConnectionRow({ connection, canRevoke, pending, onRevoke, }: { connection: McpConnectionVM; canRevoke: boolean; pending: boolean; onRevoke: (clientId: string) => void; }) { const { t } = useTranslation(); const formatters = useLocaleFormatters(); return (
  • {/* The client's own mark identifies the row; the live/expired state moved into the meta line so the icon slot can carry the brand. */}
    {connection.clientName || t("mcp.connect.connections.unnamedClient")} {t(connection.expired ? "mcp.connect.connections.statusExpired" : "mcp.connect.connections.statusActive")} {" "} · {t(connection.accessKey)} · {t("mcp.connect.connections.connectedAt", { date: formatters.date(connection.connectedAtIso) })}
    {canRevoke ? ( ) : null}
  • ); }