feat(webui): inline editing for per-repo allow_concurrent/max_retries/review_enabled
Adds PATCH /api/config/repos/{owner}/{name}, a dedicated seam distinct
from the generic dotted-key PATCH /api/config path: a repository is
one element of []config.Repo, not a flat key. Traced the mechanism
before adding any new plumbing -- overlay.Nest/ApplyOverlayValues
already handle "repos" as a single whole-slice key with no dot, so
the fix is a webui handler plus a bootstrap seam that reads the
daemon's live, untrimmed Repos (never webui.RepoView, which omits
Preflight/TestGlob), mutates the one matched field via the pure
applyRepoFieldUpdate helper, and republishes through the existing
UpdateConfig(ctx, {"repos": repos}) path unchanged.
config-row.js's row() gains an opts.save override so an edit can be
redirected to a different persistence call. The repositories table
renders an autosaving checkbox for the two booleans and a
save-on-blur/Enter input for max_retries, via api.configRepoUpdate.
Closes archie-core-b6ew.6, and with it archie-core-b6ew.
This commit is contained in:
1 parent
a444253209
commit
a4fbd8d6ef
12 files changed
+427
-20
No files matched your search
@@ -100,6 +100,16 @@ export const api = {
|
||||
if (!res.ok) throw new ApiError(await errorMessage(res), res.status);
|
||||
return res.json();
|
||||
},
|
||||
configRepoUpdate: async (owner, name, field, value) => {
|
||||
const res = await fetch(`/api/config/repos/${encodeURIComponent(owner)}/${encodeURIComponent(name)}`, {
|
||||
method: "PATCH",
|
||||
headers: { Accept: "application/json", "Content-Type": "application/json", "X-Archie-CSRF": "1" },
|
||||
body: JSON.stringify({ field, value }),
|
||||
signal: AbortSignal.timeout(15000),
|
||||
});
|
||||
if (!res.ok) throw new ApiError(await errorMessage(res), res.status);
|
||||
return res.json();
|
||||
},
|
||||
configReset: async (key) => {
|
||||
const res = await fetch("/api/config/reset", {
|
||||
method: "POST",
|
||||
|
||||
@@ -111,6 +111,13 @@ function note(rowEl, message) {
|
||||
|
||||
function startEdit(rowEl, label, opts, restore) {
|
||||
const { key, type, raw, options, onSaved } = opts;
|
||||
// save lets a caller redirect where an edit is persisted -- the
|
||||
// repositories table's per-repo fields PATCH /api/config/repos/{owner}/
|
||||
// {name} instead of the generic dotted-key /api/config path, since a
|
||||
// repository is one element of a slice, not a flat key (see
|
||||
// api.configRepoUpdate, archie-core-b6ew.6). Defaults to the ordinary
|
||||
// dotted-key update every other row already used.
|
||||
const save = opts.save || ((value) => api.configUpdate({ [key]: value }));
|
||||
const input = type === "bool"
|
||||
? el(
|
||||
"select.kv-input",
|
||||
@@ -123,11 +130,11 @@ function startEdit(rowEl, label, opts, restore) {
|
||||
...(options || []).map((o) => el("option", { value: o, selected: raw === o }, o)),
|
||||
)
|
||||
: el("input.kv-input", { type: "text", value: String(raw ?? "") });
|
||||
const save = el("button.kv-save", { type: "button" }, "Save");
|
||||
const saveBtn = el("button.kv-save", { type: "button" }, "Save");
|
||||
const cancel = el("button.kv-cancel", { type: "button" }, "Cancel");
|
||||
const error = el("span.kv-note.is-error");
|
||||
|
||||
mount(rowEl, el("span.kv-label", label), input, el("div.kv-actions", save, cancel), error);
|
||||
mount(rowEl, el("span.kv-label", label), input, el("div.kv-actions", saveBtn, cancel), error);
|
||||
input.focus?.();
|
||||
input.select?.();
|
||||
|
||||
@@ -136,26 +143,26 @@ function startEdit(rowEl, label, opts, restore) {
|
||||
input.addEventListener("keydown", (e) => {
|
||||
if (e.key === "Enter") {
|
||||
e.preventDefault?.();
|
||||
save.click();
|
||||
saveBtn.click();
|
||||
}
|
||||
if (e.key === "Escape") done();
|
||||
});
|
||||
|
||||
save.addEventListener("click", async () => {
|
||||
saveBtn.addEventListener("click", async () => {
|
||||
const parsed = parseEdit(type, input.value);
|
||||
if (parsed.error) {
|
||||
error.textContent = parsed.error;
|
||||
return;
|
||||
}
|
||||
save.disabled = true;
|
||||
saveBtn.disabled = true;
|
||||
try {
|
||||
await api.configUpdate({ [key]: parsed.value });
|
||||
await save(parsed.value);
|
||||
onSaved?.();
|
||||
} catch (err) {
|
||||
// The server's reason (validation failure, denylisted key) is the
|
||||
// part the operator can act on; show it instead of the status.
|
||||
error.textContent = String(err.message || err);
|
||||
save.disabled = false;
|
||||
saveBtn.disabled = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+59
-12
@@ -120,7 +120,7 @@ export function settingsPage() {
|
||||
body,
|
||||
...banners,
|
||||
...schemaCards(cfg.schema || []),
|
||||
repositoriesCard(cfg.repositories),
|
||||
repositoriesCard(cfg.repositories, reload),
|
||||
modelsAndProvidersCard(cfg.models, cfg.providers),
|
||||
provenanceCard(cfg.provenance),
|
||||
);
|
||||
@@ -223,7 +223,7 @@ function roleButtonClass(kind) {
|
||||
return kind === "quiet" ? "btn-quiet" : kind === "danger" ? "btn-danger" : "";
|
||||
}
|
||||
|
||||
function repositoriesCard(repos) {
|
||||
function repositoriesCard(repos, onSaved) {
|
||||
if (!repos?.length) {
|
||||
return section(
|
||||
"Repositories",
|
||||
@@ -234,8 +234,8 @@ function repositoriesCard(repos) {
|
||||
return section(
|
||||
"Repositories",
|
||||
"Each repository Archie polls, and the quality gate a change must pass before it opens a pull request. " +
|
||||
"Concurrent tasks, retries, and self-review are set per repository in config.toml -- read-only here " +
|
||||
"until archie-core-b6ew.4's follow-up gives them an inline editor.",
|
||||
"Concurrent tasks, retries, and self-review are per-repository overrides -- PATCH /api/config/repos/{owner}/{name}, " +
|
||||
"not the file config.toml directly.",
|
||||
el(
|
||||
"div.table-scroll",
|
||||
el(
|
||||
@@ -259,9 +259,9 @@ function repositoriesCard(repos) {
|
||||
el("td", r.ecosystem || "go"),
|
||||
el("td.mono", gateSummary(r.gate)),
|
||||
el("td.mono", r.protect?.length ? r.protect.join(", ") : "—"),
|
||||
el("td", boolPill(r.allow_concurrent)),
|
||||
el("td.mono", String(r.max_retries ?? 0)),
|
||||
el("td", boolPill(r.review_enabled)),
|
||||
repoBoolCell(r, "allow_concurrent", onSaved),
|
||||
repoIntCell(r, "max_retries", onSaved),
|
||||
repoBoolCell(r, "review_enabled", onSaved),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -270,11 +270,58 @@ function repositoriesCard(repos) {
|
||||
);
|
||||
}
|
||||
|
||||
// boolPill renders a config flag as the same pill used elsewhere on this
|
||||
// page (e.g. provider credential status), so "on"/"off" reads consistently
|
||||
// with the rest of the dashboard rather than as raw true/false text.
|
||||
function boolPill(value) {
|
||||
return value ? pill("on", "ok") : pill("off", "idle");
|
||||
// repoBoolCell renders an immediately-autosaving checkbox, PATCHing
|
||||
// api.configRepoUpdate on change and reverting the toggle if the save
|
||||
// fails (archie-core-b6ew.6). A table cell doesn't fit config-row.js's
|
||||
// label/value/actions Edit-then-Save flow, and a checkbox is the more
|
||||
// natural control for a boolean in a table anyway.
|
||||
function repoBoolCell(r, field, onSaved) {
|
||||
const cb = el("input.repo-field-checkbox", { type: "checkbox", checked: !!r[field] });
|
||||
const note = el("span.kv-note.is-error");
|
||||
cb.addEventListener("change", async () => {
|
||||
const next = cb.checked;
|
||||
cb.disabled = true;
|
||||
try {
|
||||
await api.configRepoUpdate(r.owner, r.name, field, next);
|
||||
onSaved?.();
|
||||
} catch (err) {
|
||||
cb.checked = !next;
|
||||
note.textContent = String(err.message || err);
|
||||
cb.disabled = false;
|
||||
}
|
||||
});
|
||||
return el("td", cb, note);
|
||||
}
|
||||
|
||||
// repoIntCell renders a plain text input that saves on blur/Enter. Errors
|
||||
// (a non-numeric entry, a rejected save) stay on the cell rather than
|
||||
// reloading the page out from under the operator mid-edit.
|
||||
function repoIntCell(r, field, onSaved) {
|
||||
const input = el("input.kv-input", { type: "text", value: String(r[field] ?? 0) });
|
||||
const note = el("span.kv-note.is-error");
|
||||
const commit = async () => {
|
||||
const n = parseInt(input.value, 10);
|
||||
if (Number.isNaN(n)) {
|
||||
note.textContent = "Enter a whole number";
|
||||
return;
|
||||
}
|
||||
input.disabled = true;
|
||||
try {
|
||||
await api.configRepoUpdate(r.owner, r.name, field, n);
|
||||
onSaved?.();
|
||||
} catch (err) {
|
||||
note.textContent = String(err.message || err);
|
||||
input.disabled = false;
|
||||
}
|
||||
};
|
||||
input.addEventListener("keydown", (e) => {
|
||||
if (e.key === "Enter") {
|
||||
e.preventDefault?.();
|
||||
input.blur();
|
||||
}
|
||||
});
|
||||
input.addEventListener("blur", commit);
|
||||
return el("td", input, note);
|
||||
}
|
||||
|
||||
function gateSummary(gate) {
|
||||
|
||||
Reference in new issue
Block a user