@spunto/design-system 0.39.0 → 0.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -230,6 +230,11 @@ opinions a dashboard doesn't want, so it gets an entry too.
|
|
|
230
230
|
same Base UI markup to do it. `actions` stays as the escape hatch (a submenu, a
|
|
231
231
|
checkbox item) and wins over `menu` when both are given; `render.menuLink` is
|
|
232
232
|
the link slot for an entry with an `href`.
|
|
233
|
+
- **The task on the machine is a prop too.** `task={{ entry, href }}` — `entry`
|
|
234
|
+
from `indexTasksByWorker` (`/tasks`) — draws a "Task" line at the top of the
|
|
235
|
+
footer, above View (or above a custom `footer`), muted once the task is over.
|
|
236
|
+
Before 0.40.0 the dashboard did it through `footer` and redrew the View button
|
|
237
|
+
by hand.
|
|
233
238
|
- **Its bricks, exported individually** because the table view assembles them
|
|
234
239
|
differently: `WorkerStatusDot`/`WorkerStatusPill` (+`resolveWorkerStatus`,
|
|
235
240
|
`workerStatusConfig`), `SetupProgress` (+`setupProgress`, `phaseLabel`,
|
package/package.json
CHANGED
|
@@ -23,6 +23,7 @@ import { TaskTitle } from "./task-title"
|
|
|
23
23
|
import { runStats, toolSubject, toolVerb, type ToolRun } from "./tool-stack"
|
|
24
24
|
import type { TaskCommand, TaskEvent, TaskItem } from "./types"
|
|
25
25
|
import { indexTasksByWorker } from "./worker-link"
|
|
26
|
+
import { WorkerCard } from "../workers/worker-card"
|
|
26
27
|
|
|
27
28
|
const ev = (seq: number, type: string, payload: Record<string, unknown>, ts = `2026-09-24T10:00:${String(seq).padStart(2, "0")}Z`): TaskEvent => ({
|
|
28
29
|
seq,
|
|
@@ -192,6 +193,22 @@ describe("worker ↔ task", () => {
|
|
|
192
193
|
expect(index.get("w1")).toMatchObject({ task: { id: "live" }, live: true })
|
|
193
194
|
expect(index.get("w2")).toMatchObject({ task: { id: "other" }, live: false })
|
|
194
195
|
})
|
|
196
|
+
|
|
197
|
+
it("draws the task on a worker card above its View button", () => {
|
|
198
|
+
const entry = indexTasksByWorker([task({ id: "t9", title: "Ship the card", workerId: "w1" })]).get("w1")!
|
|
199
|
+
render(<WorkerCard worker={{ id: "w1", name: "box" }} href="/w/w1" task={{ entry, href: "/t/t9" }} />)
|
|
200
|
+
expect(screen.getByRole("link", { name: /Ship the card/ }).getAttribute("href")).toBe("/t/t9")
|
|
201
|
+
expect(screen.getByRole("link", { name: /View/ }).getAttribute("href")).toBe("/w/w1")
|
|
202
|
+
})
|
|
203
|
+
|
|
204
|
+
it("keeps the task line when the caller replaces the footer, and draws none without a task", () => {
|
|
205
|
+
const entry = indexTasksByWorker([task({ title: "Ship the card", workerId: "w1" })]).get("w1")!
|
|
206
|
+
const { rerender } = render(<WorkerCard worker={{ id: "w1" }} task={{ entry, href: "/t" }} footer={<button>IDE</button>} />)
|
|
207
|
+
expect(screen.getByText("Ship the card")).toBeTruthy()
|
|
208
|
+
expect(screen.getByRole("button", { name: "IDE" })).toBeTruthy()
|
|
209
|
+
rerender(<WorkerCard worker={{ id: "w1" }} href="/w/w1" />)
|
|
210
|
+
expect(screen.queryByText("Task")).toBeNull()
|
|
211
|
+
})
|
|
195
212
|
})
|
|
196
213
|
|
|
197
214
|
describe("formatters", () => {
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
|
|
9
9
|
export { WorkerCard } from "./worker-card"
|
|
10
10
|
export type { WorkerCardProps, LinkRender } from "./worker-card"
|
|
11
|
+
// The card's `task` prop carries one of these — see `indexTasksByWorker` in `/tasks`.
|
|
12
|
+
export type { WorkerTask } from "../tasks/worker-link"
|
|
11
13
|
|
|
12
14
|
// The card's `menu` prop is a list of these. Re-exported here (they also ship
|
|
13
15
|
// from the root entry) so an app can type its worker menu without importing the
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
} from "lucide-react"
|
|
13
13
|
|
|
14
14
|
import { cn, formatDuration, formatRelativeTime } from "../../utils"
|
|
15
|
+
import { WorkerTaskChip, type WorkerTask } from "../tasks/worker-link"
|
|
15
16
|
import { ActionMenu, type ActionMenuEntry, type ActionMenuLinkRender } from "../action-menu"
|
|
16
17
|
import { buttonVariants } from "../button-variants"
|
|
17
18
|
import { CreatorAvatar } from "./creator-avatar"
|
|
@@ -104,6 +105,14 @@ export interface WorkerCardProps {
|
|
|
104
105
|
* item, a dialog opened from an entry). Takes precedence over `menu`.
|
|
105
106
|
*/
|
|
106
107
|
actions?: ReactNode
|
|
108
|
+
/**
|
|
109
|
+
* The task that holds this machine, or the last one that ran on it — typically
|
|
110
|
+
* `indexTasksByWorker(tasks).get(worker.id)` (`@spunto/design-system/tasks`).
|
|
111
|
+
* Drawn as a "Task" line at the top of the footer, above the View button (or
|
|
112
|
+
* above `footer`), so naming the task never means redrawing the footer. A
|
|
113
|
+
* finished task is drawn muted: the machine is free. Absent → no line.
|
|
114
|
+
*/
|
|
115
|
+
task?: { entry: WorkerTask; href: string }
|
|
107
116
|
/** Replaces the default "View" footer entirely (extra buttons, an IDE link…). */
|
|
108
117
|
footer?: ReactNode
|
|
109
118
|
/** Label of the default footer button. */
|
|
@@ -149,6 +158,7 @@ export function WorkerCard({
|
|
|
149
158
|
onDismissError,
|
|
150
159
|
menu,
|
|
151
160
|
actions,
|
|
161
|
+
task,
|
|
152
162
|
footer,
|
|
153
163
|
viewLabel = "View",
|
|
154
164
|
className,
|
|
@@ -318,14 +328,26 @@ export function WorkerCard({
|
|
|
318
328
|
</Banner>
|
|
319
329
|
)}
|
|
320
330
|
|
|
321
|
-
{(footer
|
|
322
|
-
<div className="mt-auto border-t border-border/50 bg-muted/20 px-3 py-2">
|
|
323
|
-
{
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
331
|
+
{(task || footer || href) && (
|
|
332
|
+
<div className="mt-auto flex flex-col gap-2 border-t border-border/50 bg-muted/20 px-3 py-2">
|
|
333
|
+
{/* « Sur quoi cette machine travaille » — la même paire que la colonne
|
|
334
|
+
Task du tableau, vue depuis la carte. Dans le pied plutôt que dans
|
|
335
|
+
les bandes du dessus : c'est un lien vers ailleurs, comme View. */}
|
|
336
|
+
{task && (
|
|
337
|
+
<div className="flex min-w-0 items-center gap-2">
|
|
338
|
+
<span className="shrink-0 text-[10px] font-semibold tracking-wider text-muted-foreground/60 uppercase">
|
|
339
|
+
Task
|
|
340
|
+
</span>
|
|
341
|
+
<WorkerTaskChip entry={task.entry} href={task.href} render={{ link: render?.link }} />
|
|
342
|
+
</div>
|
|
328
343
|
)}
|
|
344
|
+
{footer ??
|
|
345
|
+
(href && (
|
|
346
|
+
<Link href={href} className={cn(buttonVariants({ variant: "default", size: "sm" }), "h-7 w-full gap-1.5 text-xs")}>
|
|
347
|
+
{viewLabel}
|
|
348
|
+
<ChevronRightIcon className="h-3.5 w-3.5" />
|
|
349
|
+
</Link>
|
|
350
|
+
))}
|
|
329
351
|
</div>
|
|
330
352
|
)}
|
|
331
353
|
</div>
|