fix(#1218): bulk topology move uses one git commit via new set-parent-bulk endpoint
This commit is contained in:
parent
644519f358
commit
7ec0a36d7a
4 changed files with 179 additions and 4 deletions
|
|
@ -976,9 +976,10 @@ window.marked = marked;
|
|||
}
|
||||
sel.disabled = true;
|
||||
const failures = [];
|
||||
for (const name of names) {
|
||||
if (names.length === 1) {
|
||||
// Single agent — use the form-encoded endpoint (backwards compat).
|
||||
try {
|
||||
const body = new URLSearchParams({ child: name, new_parent: newParent });
|
||||
const body = new URLSearchParams({ child: names[0], new_parent: newParent });
|
||||
const resp = await fetch('/api/topology/set-parent', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
||||
|
|
@ -989,10 +990,30 @@ window.marked = marked;
|
|||
|| (resp.status >= 200 && resp.status < 400);
|
||||
if (!ok) {
|
||||
const text = await resp.text().catch(() => '');
|
||||
failures.push(`${name}: http ${resp.status}${text ? ' — ' + text.slice(0, 200) : ''}`);
|
||||
failures.push(`${names[0]}: http ${resp.status}${text ? ' — ' + text.slice(0, 200) : ''}`);
|
||||
}
|
||||
} catch (err) {
|
||||
failures.push(`${name}: ${err}`);
|
||||
failures.push(`${names[0]}: ${err}`);
|
||||
}
|
||||
} else {
|
||||
// Multiple agents — use the bulk endpoint so all moves land in
|
||||
// a single git commit instead of one per agent.
|
||||
try {
|
||||
const payload = names.map((n) => ({ child: n, new_parent: newParent || null }));
|
||||
const resp = await fetch('/api/topology/set-parent-bulk', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(payload),
|
||||
redirect: 'manual',
|
||||
});
|
||||
const ok = resp.ok || resp.type === 'opaqueredirect'
|
||||
|| (resp.status >= 200 && resp.status < 400);
|
||||
if (!ok) {
|
||||
const text = await resp.text().catch(() => '');
|
||||
failures.push(`bulk: http ${resp.status}${text ? ' — ' + text.slice(0, 200) : ''}`);
|
||||
}
|
||||
} catch (err) {
|
||||
failures.push(`bulk: ${err}`);
|
||||
}
|
||||
}
|
||||
sel.disabled = false;
|
||||
|
|
|
|||
Loading…
Reference in a new issue