Blocks / Automation list

Automation list

The automations of a workspace: trigger, state, last run, runs of the last days, owner.

import { AutomationList, RunBars } from "@forgeron/ui";
/01 → Default
AutomationStateRuns · 14 d
Won deal → invoiceSales · v4Active
Carrier ratesOperations · v7Paused
import { Clock01Icon, TrophyIcon } from "@forgeron/icons";
import { AutomationList } from "@forgeron/ui";

// Fewer columns for a narrow place: a side panel, a dashboard tile.
export default function Default() {
  return (
    <div style={{ width: 440 }}>
      <AutomationList
        columns={["state", "runs"]}
        onOpen={() => {}}
        automations={[
          {
            id: "won",
            name: "Won deal → invoice",
            meta: "Sales · v4",
            trigger: { label: "CRM · Deal moved to Won", icon: TrophyIcon },
            state: "active",
            runs: [3, 5, 2, 0, 0, 4, 6, 3, 5, 7, 2, 0, 0, 4],
          },
          {
            id: "rates",
            name: "Carrier rates",
            meta: "Operations · v7",
            trigger: { label: "Weekdays at 09:15", icon: Clock01Icon },
            state: "paused",
            runs: [1, 1, 1, 0, 0, 1, 2, 1, 1, 1, 0, 0, 1, 2],
            errors: [0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1],
          },
        ]}
      />
    </div>
  );
}
/02 → Full
AutomationTriggerStateLast runRuns · 14 dOwner
Won deal → invoiceSales · 6 steps · v4CRM · Deal moved to WonActive4 min ago612 msCamille Roy
Carrier ratesOperations · 4 steps · v7Weekdays at 09:15Active1 h ago1.8 sHugo Bernard
Partner syncOperations · 3 stepsWebhook POSTDraftNeverLéa Martin
import { ApiIcon, Clock01Icon, TrophyIcon } from "@forgeron/icons";
import { AutomationList } from "@forgeron/ui";

export default function Full() {
  return (
    <div style={{ width: "100%", maxWidth: 980 }}>
      <AutomationList
        onOpen={() => {}}
        automations={[
          {
            id: "won",
            name: "Won deal → invoice",
            meta: "Sales · 6 steps · v4",
            trigger: { label: "CRM · Deal moved to Won", icon: TrophyIcon },
            state: "active",
            lastRun: { status: "success", ago: "4 min ago", durationMs: 612 },
            runs: [3, 5, 2, 0, 0, 4, 6, 3, 5, 7, 2, 0, 0, 4],
            owner: "Camille Roy",
          },
          {
            id: "rates",
            name: "Carrier rates",
            meta: "Operations · 4 steps · v7",
            trigger: { label: "Weekdays at 09:15", icon: Clock01Icon },
            state: "active",
            lastRun: { status: "error", ago: "1 h ago", durationMs: 1840 },
            runs: [1, 1, 1, 0, 0, 1, 2, 1, 1, 1, 0, 0, 1, 2],
            errors: [0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1],
            owner: "Hugo Bernard",
          },
          {
            id: "partner",
            name: "Partner sync",
            meta: "Operations · 3 steps",
            trigger: { label: "Webhook POST", icon: ApiIcon },
            state: "draft",
            owner: "Léa Martin",
          },
        ]}
      />
    </div>
  );
}
/03 → With actions
AutomationTriggerStateLast runRuns · 14 dOwnerActions
Triage new ticketsSupport · 5 steps · v2Helpdesk · Ticket createdActivejust now140 msNadia Petit
Month-end reportFinance · 4 steps · v1Monthly on the 1st at 06:00Paused17 days ago1 min 15 sTom Garnier
import { Clock01Icon, MoreHorizontalIcon, Ticket01Icon } from "@forgeron/icons";
import { AutomationList, IconButton, RunBars, Switch, type AutomationSummary } from "@forgeron/ui";
import { useState } from "react";

const start: AutomationSummary[] = [
  {
    id: "triage",
    name: "Triage new tickets",
    meta: "Support · 5 steps · v2",
    trigger: { label: "Helpdesk · Ticket created", icon: Ticket01Icon },
    state: "active",
    lastRun: { status: "success", ago: "just now", durationMs: 140 },
    runs: [12, 9, 14, 3, 2, 11, 16, 13, 10, 15, 4, 1, 12, 14],
    errors: [0, 1, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0],
    owner: "Nadia Petit",
  },
  {
    id: "report",
    name: "Month-end report",
    meta: "Finance · 4 steps · v1",
    trigger: { label: "Monthly on the 1st at 06:00", icon: Clock01Icon },
    state: "paused",
    lastRun: { status: "success", ago: "17 days ago", durationMs: 75_400 },
    runs: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
    owner: "Tom Garnier",
  },
];

// The end of each row is the screen's: here the active switch and a menu. RunBars also stands alone.
export default function WithActions() {
  const [rows, setRows] = useState(start);
  return (
    <div style={{ display: "grid", gap: 16, width: "100%", maxWidth: 980 }}>
      <AutomationList
        automations={rows}
        onOpen={() => {}}
        renderActions={(a) => (
          <span style={{ display: "inline-flex", alignItems: "center", gap: 8 }}>
            <Switch
              label={<span className="fg-sr">Active</span>}
              checked={a.state === "active"}
              onChange={(e) =>
                setRows(
                  rows.map((r) =>
                    r.id === a.id ? { ...r, state: e.target.checked ? "active" : "paused" } : r,
                  ),
                )
              }
            />
            <IconButton icon={MoreHorizontalIcon} label={`Actions of ${a.name}`} size="sm" />
          </span>
        )}
      />
      <RunBars
        values={[12, 9, 14, 3, 2, 11, 16]}
        errors={[0, 1, 0, 0, 0, 0, 2]}
        width={140}
        height={32}
        label="Runs, last 7 days"
      />
    </div>
  );
}
API → Props
PropTypeDefaultDescription
automations{ id, name, meta?, trigger: { label, icon }, state, lastRun?, runs?, errors?, owner? }[]—state is active, paused or draft; lastRun is { status, ago, durationMs? }; runs and errors are per day, oldest first.
onOpen(automation) => void—A row opens on click and Enter.
columns("trigger" | "state" | "last" | "runs" | "owner")[]allThe columns after the name, in order; fewer for a narrow place.
renderActions(automation) => ReactNode—The end of a row: a menu, a switch. Clicks there do not open the row.
runsLabelstring"Runs · 14 d"Header of the bars.
emptyReactNode—Shown when there is no automation.
classNamestring—Extra classes.