Watch
0
0
Fork
You've already forked hyperhive
0

frontend: one time wording for the swarm UI and the dashboard, and no HTML strings in the dashboard's busy buttons

fmtAgo, fmtUntil and durationLabel move to @hive/shared/time.js. The swarm UI's util.ts is deleted and its importers (RelativeTime, ReviewRuns, BuildsPage) read the shared module directly. The dashboard's own copies are gone: its fmtAgeSecs (a third phrasing, used for two status lines) becomes the shared fmtAgo, and the dashboard util.js lost fmtAgo, fmtElapsed, epochSec and truncate, which nothing called. asyncBtn and the bulk action buttons mark themselves busy with markBusy: a spinner node before the label and aria-busy, in place of replacing the button's innerHTML with a string (and the label, so the button changed width and lost its name). The el() helper loses its html attribute.
This commit is contained in:
iris 2026-11-19 19:21:15 +01:00
commit 3be4ec069c

View file

@ -1,11 +1,9 @@
// Tiny DOM-builder helper shared by the dashboard and the per-agent UI —
// both packages built their own copy independently; this is the merged
// canonical version (dashboard's, which had the extra `data-` branch;
// functionally identical to the `class`/`html` handling either package
// used).
// Tiny DOM-builder helper shared by the dashboard and the per-agent UI. There
// is no `html` attribute on purpose: content is built from nodes and text, so a
// string from the API can never become markup.
//
// `el(tag, attrs, ...children)` creates an element, applying `attrs` as
// either the `class`/`html` special cases or plain attributes, and
// either the `class` special case or plain attributes, and
// appending `children` (strings become text nodes, `null`/`undefined`
// entries are skipped so callers can inline conditional children).
// `tag` can be any custom element's tag name too (e.g. `el('hive-btn',
@ -15,7 +13,6 @@ export const el = (tag, attrs = {}, ...children) => {
const e = document.createElement(tag);
for (const [k, v] of Object.entries(attrs)) {
if (k === "class") e.className = v;
else if (k === "html") e.innerHTML = v;
else e.setAttribute(k, v);
}
for (const c of children) {