155 lines
8.1 KiB
TypeScript
155 lines
8.1 KiB
TypeScript
// R-P5 Interim-UI (AD-28) — sync-run detail screen composed from ~/ui (D-P5
|
|
// "Sync-Run-Detail", archetype A3): run header with item counters + Klartext
|
|
// summary, AppSyncItem table (entity ↔ external id, operation, status, Klartext
|
|
// error) and the AppSyncRunLog lines with severity badges. Pure presentational.
|
|
// Final Subframe optics = tracked design-nachzug.
|
|
|
|
import { useTranslation } from "react-i18next";
|
|
import { FeatherRefreshCw } from "@subframe/core";
|
|
import type { SyncRunDetailVM } from "@hivegrid/view-models";
|
|
import { Alert } from "~/ui/components/Alert";
|
|
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
|
|
import { Card } from "~/ui/components/Card";
|
|
import { EmptyState } from "~/ui/components/EmptyState";
|
|
import { Table } from "~/ui/components/Table";
|
|
import { PageBackLink, PageBody, PageShell } from "../shared/PageShell";
|
|
import { syncItemStatusBadge, syncLogSeverityBadge, syncStatusBadge } from "./integrationsBadges";
|
|
import { APP_TIME_ZONE } from "~/locale/format";
|
|
|
|
export type SyncRunDetailPageProps = {
|
|
vm: SyncRunDetailVM;
|
|
backHref: string;
|
|
};
|
|
|
|
export function SyncRunDetailPage({ vm, backHref }: SyncRunDetailPageProps) {
|
|
const { t, i18n } = useTranslation();
|
|
|
|
if (vm.status !== "ready" || !vm.data) {
|
|
return <PageShell uiId="ui.integrations.runDetail" />;
|
|
}
|
|
|
|
const data = vm.data;
|
|
const dateFormatter = new Intl.DateTimeFormat(i18n.language, { timeZone: APP_TIME_ZONE, dateStyle: "medium", timeStyle: "short" });
|
|
|
|
return (
|
|
<PageShell uiId="ui.integrations.runDetail">
|
|
<PageBody>
|
|
{/* Breadcrumb back to the sync history (DoD B9) */}
|
|
<PageBackLink to={backHref} label={t("integrations.runDetail.back")} uiId="ui.integrations.runDetail.back" />
|
|
|
|
{/* Embedded in the Erweiterungen hub (AK-SET-01): the hub owns the page
|
|
<h1> and tab bar, so this screen carries a simple section heading. */}
|
|
<div className="flex w-full items-start justify-between gap-4 mobile:flex-col">
|
|
<div className="flex min-w-0 flex-col gap-1">
|
|
<div className="flex items-center gap-2">
|
|
<FeatherRefreshCw className="text-heading-3 font-heading-3 text-icon-neutral-tertiary" />
|
|
<span className="text-heading-3 font-heading-3 text-text-neutral-primary" data-ui-id="ui.integrations.runDetail.title">
|
|
{t("integrations.runDetail.title")}
|
|
</span>
|
|
</div>
|
|
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">
|
|
{t(data.kindKey)} · {data.startedIso ? dateFormatter.format(new Date(data.startedIso)) : "—"}
|
|
</span>
|
|
</div>
|
|
<BadgeFeedback farbe={syncStatusBadge(data.status)}>{t(data.statusKey)}</BadgeFeedback>
|
|
</div>
|
|
|
|
{/* Counters + Klartext summary */}
|
|
<Card>
|
|
<div className="flex w-full flex-wrap items-center gap-6">
|
|
<div className="flex flex-col gap-0">
|
|
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{t("integrations.runDetail.stats.total")}</span>
|
|
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{data.itemsTotal}</span>
|
|
</div>
|
|
<div className="flex flex-col gap-0">
|
|
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{t("integrations.runDetail.stats.succeeded")}</span>
|
|
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{data.itemsSucceeded}</span>
|
|
</div>
|
|
<div className="flex flex-col gap-0">
|
|
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{t("integrations.runDetail.stats.failed")}</span>
|
|
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{data.itemsFailed}</span>
|
|
</div>
|
|
</div>
|
|
{data.summaryKey ? (
|
|
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">{t(data.summaryKey)}</span>
|
|
) : null}
|
|
</Card>
|
|
|
|
{data.status === "failed" ? <Alert variant="error" title={data.summaryKey ? t(data.summaryKey) : t("integrations.syncStatus.failed")} /> : null}
|
|
|
|
{/* AppSyncItem table (A3) */}
|
|
<div className="flex w-full flex-col gap-3">
|
|
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{t("integrations.runDetail.itemsHeadline")}</span>
|
|
{data.items.length === 0 ? (
|
|
<div data-ui-id="ui.integrations.runDetail.emptyItems">
|
|
<EmptyState title={t(data.emptyItemsHeadlineKey)} body={t(data.emptyItemsBodyKey)} />
|
|
</div>
|
|
) : (
|
|
<div className="w-full overflow-x-auto">
|
|
<Table
|
|
data-ui-id="ui.integrations.runDetail.items"
|
|
header={
|
|
<Table.HeaderRow>
|
|
<Table.HeaderCell>{t("integrations.runDetail.column.entity")}</Table.HeaderCell>
|
|
<Table.HeaderCell>{t("integrations.runDetail.column.externalId")}</Table.HeaderCell>
|
|
<Table.HeaderCell>{t("integrations.runDetail.column.operation")}</Table.HeaderCell>
|
|
<Table.HeaderCell>{t("integrations.runDetail.column.status")}</Table.HeaderCell>
|
|
<Table.HeaderCell>{t("integrations.runDetail.column.error")}</Table.HeaderCell>
|
|
</Table.HeaderRow>
|
|
}
|
|
>
|
|
{data.items.map((item) => (
|
|
<Table.Row key={item.id} data-row-id={item.id} data-status={item.status}>
|
|
<Table.Cell>
|
|
<span className="whitespace-nowrap text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-primary">
|
|
{item.entityType}
|
|
{item.entityId ? ` · ${item.entityId}` : ""}
|
|
</span>
|
|
</Table.Cell>
|
|
<Table.Cell>
|
|
<span className="whitespace-nowrap text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">{item.externalId}</span>
|
|
</Table.Cell>
|
|
<Table.Cell>
|
|
<span className="whitespace-nowrap text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">
|
|
{t(item.operationKey)}
|
|
</span>
|
|
</Table.Cell>
|
|
<Table.Cell>
|
|
<BadgeFeedback farbe={syncItemStatusBadge(item.status)} size="small">
|
|
{t(item.statusKey)}
|
|
</BadgeFeedback>
|
|
</Table.Cell>
|
|
<Table.Cell>
|
|
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-tertiary">
|
|
{item.errorText ? t(item.errorText) : "—"}
|
|
</span>
|
|
</Table.Cell>
|
|
</Table.Row>
|
|
))}
|
|
</Table>
|
|
</div>
|
|
)}
|
|
</div>
|
|
|
|
{/* AppSyncRunLog lines with severity */}
|
|
<div className="flex w-full flex-col gap-3" data-ui-id="ui.integrations.runDetail.logs">
|
|
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{t("integrations.runDetail.logsHeadline")}</span>
|
|
<div className="flex w-full flex-col gap-2">
|
|
{data.logs.map((log) => (
|
|
<div key={log.id} className="flex w-full items-center gap-2" data-log-id={log.id} data-severity={log.severity}>
|
|
<BadgeFeedback farbe={syncLogSeverityBadge(log.severity)} size="small">
|
|
{t(log.severityKey)}
|
|
</BadgeFeedback>
|
|
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">{t(log.messageKey)}</span>
|
|
<span className="whitespace-nowrap text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">
|
|
{dateFormatter.format(new Date(log.createdIso))}
|
|
</span>
|
|
</div>
|
|
))}
|
|
</div>
|
|
</div>
|
|
</PageBody>
|
|
</PageShell>
|
|
);
|
|
}
|