Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

feat(workflows): show record names instead of ids in the Workflow Runs table

aashu4c9fcf41d5ff
diff --git a/apps/erp/app/modules/workflows/ui/Runs/WorkflowRunsTable.tsx b/apps/erp/app/modules/workflows/ui/Runs/WorkflowRunsTable.tsx
index 5793925815..b979b63dbb 100644
--- a/apps/erp/app/modules/workflows/ui/Runs/WorkflowRunsTable.tsx
+++ b/apps/erp/app/modules/workflows/ui/Runs/WorkflowRunsTable.tsx
@@ -1,3 +1,4 @@
+import { getTableLabel } from "@carbon/database/audit.config";
import { HStack } from "@carbon/react";
import { formatDateTime, formatDurationMilliseconds } from "@carbon/utils";
import { useLingui } from "@lingui/react/macro";
@@ -20,8 +21,10 @@ import { EntityRecordLink } from "./EntityRecordLink";
import { RunsLiveUpdates } from "./RunLiveUpdates";
import { RunStatus, TestRunBadge } from "./RunStatus";
+export type WorkflowRunListItem = WorkflowRun & { recordName?: string };
+
type WorkflowRunsTableProps = {
- data: WorkflowRun[];
+ data: WorkflowRunListItem[];
count: number;
};
@@ -38,7 +41,7 @@ const WorkflowRunsTable = memo(({ data, count }: WorkflowRunsTableProps) => {
(row) => row.status === "Queued" || row.status === "Running"
);
- const columns = useMemo<ColumnDef<WorkflowRun>[]>(
+ const columns = useMemo<ColumnDef<WorkflowRunListItem>[]>(
() => [
{
accessorKey: "status",
@@ -65,7 +68,7 @@ const WorkflowRunsTable = memo(({ data, count }: WorkflowRunsTableProps) => {
meta: {
icon: <LuLink />,
filterHeader: t`Workflow`,
- exportValue: (row: WorkflowRun) =>
+ exportValue: (row: WorkflowRunListItem) =>
(row.workflow as { name?: string } | null)?.name ?? row.workflowId
}
},
@@ -83,16 +86,22 @@ const WorkflowRunsTable = memo(({ data, count }: WorkflowRunsTableProps) => {
accessorKey: "triggerRecordId",
header: t`Record`,
cell: ({ row }) => {
- const { triggerTable, triggerRecordId } = row.original;
+ const { triggerTable, triggerRecordId, recordName } = row.original;
if (!triggerTable || !triggerRecordId) return "—";
- return <EntityRecordLink table={triggerTable} id={triggerRecordId} />;
+ return (
+ <EntityRecordLink
+ table={triggerTable}
+ id={triggerRecordId}
+ name={recordName}
+ />
+ );
},
meta: {
icon: <LuLink />,
filterHeader: t`Record`,
- exportValue: (row: WorkflowRun) =>
- row.triggerRecordId
- ? `${row.triggerTable} ${row.triggerRecordId}`
+ exportValue: (row: WorkflowRunListItem) =>
+ row.triggerTable && row.triggerRecordId
+ ? `${getTableLabel(row.triggerTable)} ${row.recordName ?? row.triggerRecordId}`
: ""
}
},
@@ -121,7 +130,7 @@ const WorkflowRunsTable = memo(({ data, count }: WorkflowRunsTableProps) => {
meta: {
icon: <LuUser />,
filterHeader: t`Owner`,
- exportValue: (row: WorkflowRun) => row.ownerId ?? ""
+ exportValue: (row: WorkflowRunListItem) => row.ownerId ?? ""
}
},
{
@@ -149,7 +158,7 @@ const WorkflowRunsTable = memo(({ data, count }: WorkflowRunsTableProps) => {
return (
<>
{hasInFlight && <RunsLiveUpdates companyId={company.id} />}
- <Table<WorkflowRun>
+ <Table<WorkflowRunListItem>
data={data}
columns={columns}
count={count}
diff --git a/apps/erp/app/routes/x+/workflows+/runs.tsx b/apps/erp/app/routes/x+/workflows+/runs.tsx
index 7ab550e6cf..a8d5d52808 100644
--- a/apps/erp/app/routes/x+/workflows+/runs.tsx
+++ b/apps/erp/app/routes/x+/workflows+/runs.tsx
@@ -3,7 +3,10 @@ import { requireFeature } from "@carbon/ee/plan.server";
import { VStack } from "@carbon/react";
import type { LoaderFunctionArgs } from "react-router";
import { Outlet, useLoaderData } from "react-router";
-import { getWorkflowRuns } from "~/modules/workflows";
+import {
+ getWorkflowRunRecordNames,
+ getWorkflowRuns
+} from "~/modules/workflows";
import WorkflowRunsTable from "~/modules/workflows/ui/Runs/WorkflowRunsTable";
import { path } from "~/utils/path";
import { getGenericQueryFilters } from "~/utils/query";
@@ -33,8 +36,22 @@ export async function loader({ request }: LoaderFunctionArgs) {
filters
});
+ const data = runs.data ?? [];
+ const recordNames = await getWorkflowRunRecordNames(
+ client,
+ companyId,
+ data.flatMap((run) =>
+ run.triggerTable && run.triggerRecordId
+ ? [{ table: run.triggerTable, id: run.triggerRecordId }]
+ : []
+ )
+ );
+
return {
- data: runs.data ?? [],
+ data: data.map((run) => ({
+ ...run,
+ recordName: recordNames[`${run.triggerTable}:${run.triggerRecordId}`]
+ })),
count: runs.count ?? 0
};
}