@spunto/design-system 0.41.0 → 0.42.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
|
@@ -239,6 +239,9 @@ opinions a dashboard doesn't want, so it gets an entry too.
|
|
|
239
239
|
at the top of its panel, drawn by `WorkerTaskHistory` (`/tasks`) — the live task
|
|
240
240
|
as a card, then every other task that ran on the workspace, most recent first.
|
|
241
241
|
The project's task list can be passed as is; the panel keeps this worker's.
|
|
242
|
+
- **`WorkerCockpit`** takes `actions` (since 0.42.0): the host's own actions
|
|
243
|
+
(`{ id, label, icon?, hint?, onClick, busy?, disabled? }`), drawn like Rebuild at the
|
|
244
|
+
top of the Actions section — a sandbox's "Create snapshot" and "Fork".
|
|
242
245
|
- **Its bricks, exported individually** because the table view assembles them
|
|
243
246
|
differently: `WorkerStatusDot`/`WorkerStatusPill` (+`resolveWorkerStatus`,
|
|
244
247
|
`workerStatusConfig`), `SetupProgress` (+`setupProgress`, `phaseLabel`,
|
package/package.json
CHANGED
|
@@ -18,7 +18,7 @@ export { ActionMenu } from "../action-menu"
|
|
|
18
18
|
export type { ActionMenuProps, ActionMenuItem, ActionMenuEntry, ActionMenuLinkRender } from "../action-menu"
|
|
19
19
|
|
|
20
20
|
export { WorkerCockpit } from "./worker-cockpit"
|
|
21
|
-
export type { WorkerCockpitProps } from "./worker-cockpit"
|
|
21
|
+
export type { WorkerCockpitAction, WorkerCockpitProps } from "./worker-cockpit"
|
|
22
22
|
|
|
23
23
|
export { WorkerStatusDot, WorkerStatusPill, resolveWorkerStatus, workerStatusConfig } from "./worker-status"
|
|
24
24
|
export type { WorkerStatus, WorkerStatusConfig, WorkerStatusKey } from "./worker-status"
|
|
@@ -54,6 +54,17 @@ import type { TaskItem } from "../tasks/types"
|
|
|
54
54
|
|
|
55
55
|
type CockpitTab = "logs" | "terminal"
|
|
56
56
|
|
|
57
|
+
export interface WorkerCockpitAction {
|
|
58
|
+
id: string
|
|
59
|
+
label: string
|
|
60
|
+
icon?: ComponentType<{ className?: string }>
|
|
61
|
+
hint?: string
|
|
62
|
+
onClick: () => void
|
|
63
|
+
/** In flight: the button is disabled and its icon spins. */
|
|
64
|
+
busy?: boolean
|
|
65
|
+
disabled?: boolean
|
|
66
|
+
}
|
|
67
|
+
|
|
57
68
|
export interface WorkerCockpitProps {
|
|
58
69
|
worker: WorkerCockpitWorker
|
|
59
70
|
/** Above the worker name, e.g. "my-project /". Omitted → no breadcrumb. */
|
|
@@ -107,6 +118,13 @@ export interface WorkerCockpitProps {
|
|
|
107
118
|
/** Fetches the one-shot SSH command; the cockpit copies it to the clipboard and owns the button's own idle/loading/copied state. */
|
|
108
119
|
onCopySsh?: () => Promise<string>
|
|
109
120
|
|
|
121
|
+
/**
|
|
122
|
+
* More of the worker's own actions, drawn like Rebuild in the Actions section — before it, in this
|
|
123
|
+
* order. What a host offers beyond the built-in ones (a sandbox's "Create snapshot", "Fork"…).
|
|
124
|
+
* `hint`: the muted words on the right. Shown whatever the worker's state: pass only what applies now.
|
|
125
|
+
*/
|
|
126
|
+
actions?: WorkerCockpitAction[]
|
|
127
|
+
|
|
110
128
|
/**
|
|
111
129
|
* The worker's status transitions, as journaled by the control plane. Omitted or empty → no
|
|
112
130
|
* History section. The current stay is measured up to `now` at render time.
|
|
@@ -198,6 +216,7 @@ export function WorkerCockpit({
|
|
|
198
216
|
onDelete,
|
|
199
217
|
deleting = false,
|
|
200
218
|
onCopySsh,
|
|
219
|
+
actions = [],
|
|
201
220
|
statusHistory,
|
|
202
221
|
tasks,
|
|
203
222
|
taskHref,
|
|
@@ -244,7 +263,7 @@ export function WorkerCockpit({
|
|
|
244
263
|
}
|
|
245
264
|
}
|
|
246
265
|
|
|
247
|
-
const showActions = !!((settled && onCopySsh) || (hasContainer && !status.settingUp && !isDeleting && onRebuild) || ((hasContainer || isDeleting) && nodeOnline !== false && onDelete))
|
|
266
|
+
const showActions = !!(actions.length > 0 || (settled && onCopySsh) || (hasContainer && !status.settingUp && !isDeleting && onRebuild) || ((hasContainer || isDeleting) && nodeOnline !== false && onDelete))
|
|
248
267
|
const hasTasks = !!taskHref && !!tasks?.some((t) => t.workerId === worker.id)
|
|
249
268
|
const showTags = (worker.tags?.length ?? 0) > 0 || !!onAddTag
|
|
250
269
|
|
|
@@ -406,6 +425,16 @@ export function WorkerCockpit({
|
|
|
406
425
|
<span className="text-[10px] text-muted-foreground/50">5 min token</span>
|
|
407
426
|
</button>
|
|
408
427
|
)}
|
|
428
|
+
{actions.map((a) => {
|
|
429
|
+
const Icon = a.icon
|
|
430
|
+
return (
|
|
431
|
+
<button key={a.id} type="button" disabled={a.disabled || a.busy} onClick={a.onClick} className="flex w-full items-center gap-2 rounded-lg border border-border/50 bg-muted/20 px-3 py-2.5 text-xs text-foreground transition-colors hover:bg-muted/40 disabled:opacity-50">
|
|
432
|
+
{a.busy ? <LoaderIcon className="h-3.5 w-3.5 animate-spin text-muted-foreground" /> : Icon ? <Icon className="h-3.5 w-3.5 text-muted-foreground" /> : null}
|
|
433
|
+
<span className="font-medium">{a.label}</span>
|
|
434
|
+
{a.hint && <span className="ml-auto text-[10px] text-muted-foreground/50">{a.hint}</span>}
|
|
435
|
+
</button>
|
|
436
|
+
)
|
|
437
|
+
})}
|
|
409
438
|
{hasContainer && !status.settingUp && !isDeleting && onRebuild && (
|
|
410
439
|
<button type="button" disabled={rebuilding} onClick={onRebuild} className="flex w-full items-center gap-2 rounded-lg border border-border/50 bg-muted/20 px-3 py-2.5 text-xs text-foreground transition-colors hover:bg-muted/40 disabled:opacity-50">
|
|
411
440
|
<RefreshCwIcon className={cn("h-3.5 w-3.5 text-muted-foreground", rebuilding && "animate-spin")} />
|