Files
archie/ui/src/settings/update-status.jsx
T
sam a64d72ddbe refactor(ui): extract Pill to ui/src/base/, closing archie-core-mlro
Pill was independently duplicated byte-for-byte across 11 files
(tasks, logs, mapping-editor, capture-row, settings, update-status,
skills, dashboard, memory, channels, curators) plus the bindings page
built earlier this session -- a violation of organisation.md's
"extract on the second distinct consumer" rule, predating this
session entirely. Found while building the bindings UI.

Mechanical extraction only, no behavior change: ui/src/base/pill.jsx
is now the single definition; every call site imports from there.
skills.jsx's copy used `class=` instead of `className=` (functionally
identical in Preact) -- normalized to the shared version's className.
captures.jsx's import of Pill (previously re-exported through
capture-row.jsx) now points at the shared module directly.

Verified via task test:ui (120/120 unchanged) and, since this touches
the exact rendering path that had a real app-wide regression earlier
tonight (commit 8f9f2d6), re-verified in a real browser across all 12
pages: zero "[object Object]" occurrences, and every page's .pill
elements render with real content (settings: 9, bindings: 2, etc.),
not just "the build succeeded."
2026-09-03 06:25:21 +10:00

72 lines
2.5 KiB
React

import { h } from "preact";
import { Pill } from "../base/pill.jsx";
function Empty({ title, detail }) {
return (
<div className="empty">
<div className="empty-title">{title}</div>
{detail && <div>{detail}</div>}
</div>
);
}
function Section({ sub, title, children }) {
return (
<div className="card cfg-section">
<div className="card-head">
<div>
<h2 className="card-title">{title || "Update status"}</h2>
<p className="card-sub">{sub}</p>
</div>
</div>
{children}
</div>
);
}
const STATUS_LABELS = { ok: "OK", update_available: "Update available", drift: "Drift", unknown: "Unknown" };
const STATUS_KINDS = { ok: "ok", update_available: "info", drift: "danger", unknown: "idle" };
export function UpdateStatusCard({ components }) {
if (!components || !components.length) {
return (
<Section sub="How each component is deployed, and whether what's running matches what's installed.">
<Empty title="No components reported" detail="The configured update-check command returned nothing." />
</Section>
);
}
return (
<Section sub="How each component is deployed, and whether what's running matches what's installed. Hover a row for the exact versions compared.">
<div className="table-scroll">
<table className="table">
<thead>
<tr>
<th>Component</th><th>Install type</th><th>Running</th><th>Latest available</th><th>Status</th>
</tr>
</thead>
<tbody>
{components.map(c => {
const basis = [
`Installed claim: ${c.installed_claim || "unknown"}`,
`Running: ${c.running_version || "not observed"}`,
c.reference ? `Reference: ${c.reference}` : null,
].filter(Boolean).join("\n");
return (
<tr title={basis} key={c.id || c.label}>
<td className="strong">{c.label || c.id}</td>
<td className="mono">{c.install_type || "—"}</td>
<td className="mono">{c.running_version || "—"}</td>
<td className="mono">{c.latest_available || "—"}</td>
<td>
<Pill text={STATUS_LABELS[c.status] || c.status} kind={STATUS_KINDS[c.status] || "idle"} />
</td>
</tr>
);
})}
</tbody>
</table>
</div>
</Section>
);
}