feat(ui): settings pages edit through TanStack Form with shadcn-vue Field

Each control-plane kind has one store-owned TanStack form, so edits survive
navigation and the save bar submits every dirty section. Shared editors emit
new values, map entries are written whole, unset resources stay null, and the
container runtime page warns when max uptime is under the task limit.
This commit is contained in:
sam committed 2026-10-26 19:17:03 +11:00
1 parent 424a6e4f01
commit cc2f3a46b9
57 files changed
+2323 -863

No files matched your search

+31 -5
View File
@@ -150,14 +150,19 @@ test("apply status shows a process that has never reported, and one that rejecte
]);
});
test("save errors appear on the page only when not presented in the review drawer", () => {
test("save errors appear on the page only when not presented in the review drawer", async () => {
setActivePinia(createPinia());
const store = useSettingsStore();
const kind = "channel-settings";
store.drafts[kind] = {
base: { kind, version: 1, value: { operator: "" } },
value: { operator: "changed" },
};
const realFetch = globalThis.fetch;
globalThis.fetch = async () =>
new Response(JSON.stringify({ resource: { kind, version: 1, value: { operator: "" } } }));
try {
await store.loadResource(kind);
} finally {
globalThis.fetch = realFetch;
}
store.formFor(kind)!.api.setFieldValue("operator", "changed");
store.stateFor(kind).error = "Save failed";
store.stateFor("provider-settings").error = "Load failed";
for (const [reviewing, expected] of [[false, "Save failed"], [true, undefined], [false, "Save failed"]] as const) {
@@ -167,3 +172,24 @@ test("save errors appear on the page only when not presented in the review drawe
assert.equal(store.pageErrorFor("provider-settings"), "Load failed", "unreviewed errors stay visible");
}
});
test("an unset resource opens without changes and an untouched save keeps it unset", async () => {
setActivePinia(createPinia());
const store = useSettingsStore();
const kind = "credential-bindings";
const sent: unknown[] = [];
const realFetch = globalThis.fetch;
globalThis.fetch = async (_input, init) => {
if (init?.body) sent.push(JSON.parse(String(init.body)).value);
return new Response(JSON.stringify({ resource: { kind, version: init?.body ? 2 : 1, value: null } }));
};
try {
await store.loadResource(kind);
assert.deepEqual(store.changesFor(kind), [], "opening an unset section is not an edit");
assert.equal(store.draftValue(kind), null);
assert.equal(await store.formFor(kind)!.submit(), true);
assert.deepEqual(sent, [null], "saving stores null, not {}");
} finally {
globalThis.fetch = realFetch;
}
});