Fix the dashboard's pending-changes count; explain zones in the docs
The dashboard counted every open changeset, including empty ones and other users', so "Pending changes (1 open)" led to an empty Changes page. It now counts the user's own changesets that contain changes, the status API's open_changesets skips empty ones, and in review mode a draft created for an edit the server rejects is discarded instead of left open. docs/concepts.md: zone types, a new zone's name servers and glue, reverse zones for any network, and dynamic updates versus API tokens and TSIG keys. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
785b0006f9
commit
5cb8602a7f
5 files changed
+104
-6
No files matched your search
@@ -116,10 +116,19 @@ export function useDraft(cs) {
|
||||
async function ensureDraft() {
|
||||
if (state.draft) return state.draft;
|
||||
const cs = await api("POST", "/changesets", { body: { description: "" } });
|
||||
cs.fresh = true;
|
||||
useDraft(cs);
|
||||
return cs;
|
||||
}
|
||||
|
||||
// dropFreshDraft discards a draft that was created for an edit the server
|
||||
// then rejected, so no empty changeset is left open.
|
||||
async function dropFreshDraft(cs) {
|
||||
if (!cs.fresh || (state.draft && state.draft.id !== cs.id) || (state.draft && (state.draft.ops || []).length)) return;
|
||||
try { await api("POST", "/changesets/" + cs.id + "/discard"); } catch { /* leave it */ }
|
||||
useDraft(null);
|
||||
}
|
||||
|
||||
// change sends a configuration change: staged into the draft changeset,
|
||||
// or applied at once when immediate mode is on (or opts.immediate).
|
||||
// It returns the API response.
|
||||
@@ -140,6 +149,7 @@ export async function change(method, path, body, opts = {}) {
|
||||
useDraft(null);
|
||||
return change(method, path, body, opts);
|
||||
}
|
||||
await dropFreshDraft(cs);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
@@ -152,7 +162,13 @@ export async function changeMany(ops, description, opts = {}) {
|
||||
return r;
|
||||
}
|
||||
const cs = await ensureDraft();
|
||||
const r = await api("POST", "/changesets/" + cs.id + "/ops", { body: { ops } });
|
||||
let r;
|
||||
try {
|
||||
r = await api("POST", "/changesets/" + cs.id + "/ops", { body: { ops } });
|
||||
} catch (e) {
|
||||
await dropFreshDraft(cs);
|
||||
throw e;
|
||||
}
|
||||
if (r && r.changeset) state.draft = r.changeset;
|
||||
notify();
|
||||
return r;
|
||||
|
||||
Reference in new issue
Block a user