Files
Stirling-PDF/frontend/editor/src/portal/components/pipelines/PipelinesTable.tsx
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

87 lines
2.3 KiB
TypeScript
Raw Normal View History

2026-06-30 17:11:48 +01:00
import { useMemo } from "react";
import { useTranslation } from "react-i18next";
import {
column,
DataTable,
type DataTableColumn,
2026-06-30 17:11:48 +01:00
type StatusTone,
} from "@app/ui";
import { pipelineIcon } from "@portal/components/pipelines/pipelineIcon";
2026-06-30 17:11:48 +01:00
import type { PipelineStatus, PipelineView } from "@portal/api/pipelines";
const STATUS_TONE: Record<PipelineStatus, StatusTone> = {
active: "success",
paused: "neutral",
};
interface PipelinesTableProps {
pipelines: PipelineView[];
/** A row opens that pipeline's own page. */
2026-06-30 17:11:48 +01:00
onRowClick: (pipeline: PipelineView) => void;
}
export function PipelinesTable({ pipelines, onRowClick }: PipelinesTableProps) {
2026-06-30 17:11:48 +01:00
const { t } = useTranslation();
const columns = useMemo<DataTableColumn<PipelineView>[]>(
2026-06-30 17:11:48 +01:00
() => [
column.entity({
2026-06-30 17:11:48 +01:00
key: "name",
header: t("portal.pipelines.table.name"),
sortable: true,
icon: (p) => pipelineIcon(p.icon, "1.25rem"),
primary: (p) => p.name,
}),
column.text({
key: "type",
header: t("portal.pipelines.table.type", "Type"),
sortable: true,
get: (p) =>
p.required
? t("portal.pipelines.type.policy")
: t("portal.pipelines.type.pipeline"),
}),
column.text({
key: "trigger",
header: t("portal.pipelines.table.trigger", "Trigger"),
sortable: true,
get: (p) =>
t(`portal.pipelines.trigger.${p.trigger}`, {
defaultValue: p.trigger,
}),
}),
column.badge({
2026-06-30 17:11:48 +01:00
key: "status",
header: t("portal.pipelines.table.status"),
sortable: true,
get: (p) => ({
tone: STATUS_TONE[p.status],
label: t(`portal.pipelines.status.${p.status}`),
}),
}),
column.number({
2026-06-30 17:11:48 +01:00
key: "steps",
header: t("portal.pipelines.table.steps"),
sortable: true,
get: (p) => p.steps.length,
}),
column.number({
2026-06-30 17:11:48 +01:00
key: "sources",
header: t("portal.pipelines.table.sources"),
sortable: true,
get: (p) => p.sources.length,
}),
2026-06-30 17:11:48 +01:00
],
[t],
2026-06-30 17:11:48 +01:00
);
return (
<DataTable<PipelineView>
2026-06-30 17:11:48 +01:00
columns={columns}
rows={pipelines}
rowKey={(p) => p.id}
onRowClick={onRowClick}
rowAffordance="chevron"
2026-06-30 17:11:48 +01:00
/>
);
}