// R-P5 Interim-UI (AD-28) โ€” per-app connection management screen composed from // ~/ui (D-P5 "App-Detail / Connection-Verwaltung", archetype A6+A2). Pure // presentational: renders the server-built ConnectionDetailVM and reports the // lifecycle mutations (connect / reconnect / disconnect / manual re-sync) // through injected actions โ€” the route owns the fetcher. Degraded/broken // connections raise a screen banner with a reconnect solution button (D-P5 // Klartext requirement). Final Subframe optics = tracked design-nachzug. import { useEffect, useState } from "react"; import { Link } from "react-router"; import { useTranslation } from "react-i18next"; import { FeatherPlus } from "@subframe/core"; import type { AppCredentialField } from "@hivegrid/integrations"; import type { ConnectionDetailVM, ConnectionRow } from "@hivegrid/view-models"; import { Alert } from "~/ui/components/Alert"; import { Button } from "~/ui/components/Button"; import { Dialog } from "~/ui/components/Dialog"; import { EmptyState } from "~/ui/components/EmptyState"; import { LinkButton } from "~/ui/components/LinkButton"; import { ConnectionCard } from "./ConnectionCard"; import { ConnectWizardDialog, type ConnectWizardMode, type ConnectWizardSubmit } from "./ConnectWizardDialog"; export type ConnectionDetailActions = { /** POSTs intent=connect to the app route action. */ onConnect: (input: ConnectWizardSubmit) => void; /** POSTs intent=reconnect (same connection id, no history loss). */ onReconnect: (connectionId: string, input: ConnectWizardSubmit) => void; /** POSTs intent=disconnect (status revoked, no hard delete). */ onDisconnect: (connectionId: string) => void; /** POSTs intent=manual-sync. */ onManualSync: (connectionId: string) => void; }; export type ConnectionDetailPageProps = { vm: ConnectionDetailVM; connectionType: string; credentialFields: readonly AppCredentialField[]; backHref: string; actions: ConnectionDetailActions; submitting: boolean; errorMessage: string | null; /** Increments after a successful mutation โ€” closes any open dialog. */ closeSignal: number; }; type WizardState = ConnectWizardMode | null; export function ConnectionDetailPage({ vm, connectionType, credentialFields, backHref, actions, submitting, errorMessage, closeSignal }: ConnectionDetailPageProps) { const { t } = useTranslation(); const [wizard, setWizard] = useState(null); const [disconnectRow, setDisconnectRow] = useState(null); useEffect(() => { if (closeSignal > 0) { setWizard(null); setDisconnectRow(null); } }, [closeSignal]); if (vm.status !== "ready" || !vm.data) { return
; } const { appTitleKey, rows, canConnect, canDisconnect, canManualSync, emptyHeadlineKey, emptyBodyKey } = vm.data; const unhealthy = rows.filter((row) => row.status === "degraded" || row.status === "broken"); return (
{/* Breadcrumb back to the catalog (DoD B9) + header with connect CTA */} {t("integrations.connections.back")}
{t(appTitleKey)} {t("integrations.connections.subtitle")}
{canConnect ? ( ) : null}
{/* Screen banner (hierarchy ยง8): at least one degraded/broken connection. */} {unhealthy.length > 0 ? ( row.status === "broken") ? "error" : "warning"} title={t("integrations.connections.banner.title", { count: unhealthy.length })} description={unhealthy[0].healthMessageKey ? t(unhealthy[0].healthMessageKey) : undefined} actions={ canConnect ? ( ) : undefined } data-ui-id="ui.integrations.app.banner" /> ) : null} {rows.length === 0 ? (
{canConnect ? ( ) : null}
) : (
{rows.map((row) => ( setWizard({ type: "reconnect", connectionId: target.id, label: target.label })} onDisconnect={setDisconnectRow} /> ))}
)} {/* Connect/Reconnect wizard (A5, M 720) */} {wizard ? ( { if (wizard.type === "reconnect") actions.onReconnect(wizard.connectionId, input); else actions.onConnect(input); }} onClose={() => setWizard(null)} /> ) : null} {/* Disconnect confirm (XS 420, Klartext: sync jobs stop, history preserved) */} (open ? undefined : setDisconnectRow(null))}> {disconnectRow ? (
{t("integrations.disconnect.title", { label: disconnectRow.label })} {t("integrations.disconnect.description")} {errorMessage ? : null}
) : (
)}
); }