Watch
0
0
Fork
You've already forked hyperhive
0

dashboard: action buttons use the swarm UI's button, with its danger tone and touch height

Button.css moves to @hive/shared, a rename from swarm-ui/src/ui/button/Button.css to shared/src/button/Button.css; the swarm UI's Button imports it from there and the dashboard imports it too. The dashboard's own .btn rules and its eleven per-action colour modifiers are gone: the bulk action buttons, the per-row purge and the selection bar's clear are ui-button, destroy and purge are ui-button-danger, and all of them have the 2.75em height the dashboard buttons were under. The form() and addBulkButton helpers take a tone (danger or default) in place of a btn-* class. The danger variant is the one the confirmations PR adds, identical, so the two merge in either order.
This commit is contained in:
iris 2026-11-19 19:24:59 +01:00 • committed by mara
commit 16a5bff2b1

View file

@ -4,7 +4,7 @@
// job-queue-rollup ops. See docs/4-implementation/web-ui/dashboard.md::Container row for the
// rendering contract.
import { $, form, fmtAgeSecs } from "./common.js";
import { $, buttonClass, form, fmtAgeSecs } from "./common.js";
import { el } from "@hive/shared/dom.js";
import { themedConfirm, themedToast } from "@hive/shared/modal.js";
import { h, render } from "preact";
@ -731,7 +731,7 @@ export function renderSelectionBar(containers) {
return `${label} not available — ${blockers.join(", ")} ${blockers.length === 1 ? "is" : "are"} blocking it`;
}
addBulkButton(actions, "btn-restart", "↺ R3ST4RT", allRunning, selected, {
addBulkButton(actions, "default", "↺ R3ST4RT", allRunning, selected, {
action: "/api/restart/",
confirm: (names) =>
`restart ${names.length} agent${names.length === 1 ? "" : "s"} (${names.join(", ")})?`,
@ -743,7 +743,7 @@ export function renderSelectionBar(containers) {
stoppedNames.map((n) => `\`${n}\` is stopped`),
),
});
addBulkButton(actions, "btn-stop", "■ ST0P", allRunning, selected, {
addBulkButton(actions, "default", "■ ST0P", allRunning, selected, {
action: "/api/kill/",
confirm: (names) =>
`stop ${names.length} agent${names.length === 1 ? "" : "s"} (${names.join(", ")})?`,
@ -754,7 +754,7 @@ export function renderSelectionBar(containers) {
stoppedNames.map((n) => `\`${n}\` is already stopped`),
),
});
addBulkButton(actions, "btn-start", "▶ ST4RT", allStopped, selected, {
addBulkButton(actions, "default", "▶ ST4RT", allStopped, selected, {
action: "/api/start/",
confirm: (names) =>
`start ${names.length} agent${names.length === 1 ? "" : "s"} (${names.join(", ")})?`,
@ -763,7 +763,7 @@ export function renderSelectionBar(containers) {
runningNames.map((n) => `\`${n}\` is already running`),
),
});
addBulkButton(actions, "btn-pause", "⏸ P4US3", allUnpaused, selected, {
addBulkButton(actions, "default", "⏸ P4US3", allUnpaused, selected, {
action: "/api/pause/",
confirm: (names) =>
`pause ${names.length} agent${names.length === 1 ? "" : "s"} (${names.join(", ")})? parks the turn loop — inbox messages queue unacked.`,
@ -772,7 +772,7 @@ export function renderSelectionBar(containers) {
pausedNames.map((n) => `\`${n}\` is already paused`),
),
});
addBulkButton(actions, "btn-resume", "▶ R3SUM3", allPaused, selected, {
addBulkButton(actions, "default", "▶ R3SUM3", allPaused, selected, {
action: "/api/resume/",
confirm: (names) =>
`resume ${names.length} agent${names.length === 1 ? "" : "s"} (${names.join(", ")})? the turn loop restarts and drains queued messages.`,
@ -781,17 +781,17 @@ export function renderSelectionBar(containers) {
unpausedNames.map((n) => `\`${n}\` is not paused`),
),
});
addBulkButton(actions, "btn-rebuild", "↻ R3BU1LD", true, selected, {
addBulkButton(actions, "default", "↻ R3BU1LD", true, selected, {
action: "/api/rebuild/",
confirm: (names) =>
`rebuild ${names.length} agent${names.length === 1 ? "" : "s"} (${names.join(", ")})? hot-reloads each container.`,
});
addBulkButton(actions, "btn-destroy", "DESTR0Y", true, selected, {
addBulkButton(actions, "danger", "DESTR0Y", true, selected, {
action: "/api/destroy/",
confirm: (names) =>
`destroy ${names.length} agent${names.length === 1 ? "" : "s"} (${names.join(", ")})? containers are removed; state + creds kept.`,
});
addBulkButton(actions, "btn-destroy", "PURG3", true, selected, {
addBulkButton(actions, "danger", "PURG3", true, selected, {
action: "/api/destroy/",
body: { purge: "on" },
confirm: (names) =>
@ -799,13 +799,13 @@ export function renderSelectionBar(containers) {
});
}
function addBulkButton(parent, btnClass, label, enabled, selected, opts) {
function addBulkButton(parent, tone, label, enabled, selected, opts) {
const names = selected.map((c) => c.name);
const btn = el(
"button",
{
type: "button",
class: "btn " + btnClass,
class: buttonClass(tone),
},
label,
);