Job Runs
A table of background job runs with state, attempts, progress, error and retry or cancel actions.
4 rows
| Job | Status | Attempts | Progress | Error | Actions |
|---|---|---|---|---|---|
| invoice.generate | running | 1 | 340/500 · March invoices | ||
| email.digest | done | 1 | |||
| payout.settle | dead | 5 | GATEWAY_TIMEOUT: Bank did not respond | ||
| report.export | queued | 0 |
import { type JobRun, JobRuns } from "@dapplelight/signet-ui/domain/job-runs"
import { useState } from "react"
const initial: JobRun[] = [
{
id: "run_8f21",
job: "invoice.generate",
state: "running",
attempt: 1,
progress: { done: 340, total: 500, note: "March invoices" },
},
{ id: "run_8f20", job: "email.digest", state: "done", attempt: 1 },
{
id: "run_8f1e",
job: "payout.settle",
state: "dead",
attempt: 5,
error: { code: "GATEWAY_TIMEOUT", message: "Bank did not respond" },
},
{ id: "run_8f1b", job: "report.export", state: "queued", attempt: 0 },
]
export function JobRunsDemo() {
const [runs, setRuns] = useState(initial)
return (
<div className="w-full">
<JobRuns
runs={runs}
onRetry={(run) =>
setRuns((rs) =>
rs.map((r) =>
r.id === run.id ? { ...r, state: "queued", attempt: r.attempt + 1, error: undefined } : r,
),
)
}
onCancel={(run) => setRuns((rs) => rs.map((r) => (r.id === run.id ? { ...r, state: "cancelled" } : r)))}
/>
</div>
)
}Installation
npm i @dapplelight/signet-uiUsage
import { JobRuns, type JobRun } from "@dapplelight/signet-ui/domain/job-runs"
import { cancel, retry, runs } from "./jobs"
<JobRuns runs={runs} onRetry={retry} onCancel={cancel} />Examples
Retry and cancel
4 rows
| Job | Status | Attempts | Progress | Error | Actions |
|---|---|---|---|---|---|
| invoice.generate | running | 1 | 340/500 · March invoices | ||
| email.digest | done | 1 | |||
| payout.settle | dead | 5 | GATEWAY_TIMEOUT: Bank did not respond | ||
| report.export | queued | 0 |
import { type JobRun, JobRuns } from "@dapplelight/signet-ui/domain/job-runs"
import { useState } from "react"
const initial: JobRun[] = [
{
id: "run_8f21",
job: "invoice.generate",
state: "running",
attempt: 1,
progress: { done: 340, total: 500, note: "March invoices" },
},
{ id: "run_8f20", job: "email.digest", state: "done", attempt: 1 },
{
id: "run_8f1e",
job: "payout.settle",
state: "dead",
attempt: 5,
error: { code: "GATEWAY_TIMEOUT", message: "Bank did not respond" },
},
{ id: "run_8f1b", job: "report.export", state: "queued", attempt: 0 },
]
export function JobRunsDemo() {
const [runs, setRuns] = useState(initial)
return (
<div className="w-full">
<JobRuns
runs={runs}
onRetry={(run) =>
setRuns((rs) =>
rs.map((r) =>
r.id === run.id ? { ...r, state: "queued", attempt: r.attempt + 1, error: undefined } : r,
),
)
}
onCancel={(run) => setRuns((rs) => rs.map((r) => (r.id === run.id ? { ...r, state: "cancelled" } : r)))}
/>
</div>
)
}Read only
2 rows
| Job | Status | Attempts | Progress | Error | Actions |
|---|---|---|---|---|---|
| invoice.generate | running | 1 | 340/500 · March invoices | ||
| email.digest | done | 1 |
import { type JobRun, JobRuns } from "@dapplelight/signet-ui/domain/job-runs"
const initial: JobRun[] = [
{
id: "run_8f21",
job: "invoice.generate",
state: "running",
attempt: 1,
progress: { done: 340, total: 500, note: "March invoices" },
},
{ id: "run_8f20", job: "email.digest", state: "done", attempt: 1 },
{
id: "run_8f1e",
job: "payout.settle",
state: "dead",
attempt: 5,
error: { code: "GATEWAY_TIMEOUT", message: "Bank did not respond" },
},
{ id: "run_8f1b", job: "report.export", state: "queued", attempt: 0 },
]
export function JobRunsReadOnlyDemo() {
return (
<div className="w-full">
<JobRuns runs={initial.slice(0, 2)} />
</div>
)
}Empty
0 rows
| Job | Status | Attempts | Progress | Error | Actions |
|---|---|---|---|---|---|
| Nothing has run yet | |||||
import { JobRuns } from "@dapplelight/signet-ui/domain/job-runs"
export function JobRunsEmptyDemo() {
return (
<div className="w-full">
<JobRuns runs={[]} emptyMessage="Nothing has run yet" />
</div>
)
}API Reference
JobRuns
| Prop | Type | Default | Description |
|---|---|---|---|
runs | JobRun[] | — | Rows as jobs.status(id) or a dead-letter entry describe them. |
onRetry | (run: JobRun) => void | — | Shows Retry on failed (dead) runs. |
onCancel | (run: JobRun) => void | — | Shows Cancel on runs that have not finished. |
emptyMessage | string | "No job runs" | Shown when runs is empty. |
className | string | — | Class for the table. |
JobRun
| Prop | Type | Default | Description |
|---|---|---|---|
id | string | — | Run id. |
job | string | — | Job name. |
state | string | — | running, done, dead, cancelled, or any other state. |
attempt | number | — | Attempts so far. |
error | { code: string; message?: string } | — | Shown in red. |
progress | { done: number; total?: number; note?: string } | — | Shown as done/total · note. |
updatedAt | string | — | Last update. |