T12.5: CR-020 bulk delete with typed confirmation
'Delete selected…' in the bulk bar. The dialog lists every affected username (scrolling inside the dialog for a long list), says the delete cannot be undone and offers disable instead, and sends nothing until the word DELETE is typed in capitals, whatever the count (confirmed 2026-10-06). Wrong words keep the dialog open with the reason; cancel sends nothing. Your own account cannot be selected; if it ever reached the request, the server refuses that row and the report names it with the reason. The bulk delete is a prompt-style dialog, so it is covered in tests/console_dialogs_check.py (its docstring asks for exactly this): new section 4 drives it in the browser with native dialogs poisoned. DOM harness: 48/48.
This commit is contained in:
@@ -212,7 +212,9 @@ function renderBulkActions(){
|
||||
projRoles.map(r => '<option value="'+r+'">Role: '+uesc(PERM_LABELS[r])+' here</option>').join('')+
|
||||
'</select>'+
|
||||
'<button type="button" onclick="bulkProject(\'add\')">Add to project</button>'+
|
||||
'<button type="button" onclick="bulkProject(\'remove\')">Remove from project</button>') : '');
|
||||
'<button type="button" onclick="bulkProject(\'remove\')">Remove from project</button>') : '') +
|
||||
group('Delete',
|
||||
'<button type="button" class="danger" onclick="bulkDelete()">Delete selected…</button>');
|
||||
}
|
||||
|
||||
function selectedIds(){ return _users.filter(u => _selected.has(u.id)).map(u => u.id); }
|
||||
@@ -230,16 +232,44 @@ async function runBulk(path, body, ask){
|
||||
const ids = selectedIds();
|
||||
if(!ids.length) return;
|
||||
if(!(await wpConfirmDialog({title: ask.title, okLabel: ask.ok, message: ask.message(ids.length)}))) return;
|
||||
bannerHtml('bulk-banner', '', uesc(ask.title)+': working on '+uesc(people(ids.length))+'…');
|
||||
return sendBulk(path, body, ask.title, ids);
|
||||
}
|
||||
|
||||
async function sendBulk(path, body, title, ids){
|
||||
bannerHtml('bulk-banner', '', uesc(title)+': working on '+uesc(people(ids.length))+'…');
|
||||
const { status, json } = await api('POST', path, Object.assign({ user_ids: ids }, body));
|
||||
if(status !== 200 || !json || !Array.isArray(json.results)){
|
||||
bannerHtml('bulk-banner', 'bad', '✕ '+uesc(apiError(status, json, ask.title+' failed'))+' Nothing was changed.');
|
||||
bannerHtml('bulk-banner', 'bad', '✕ '+uesc(apiError(status, json, title+' failed'))+' Nothing was changed.');
|
||||
return;
|
||||
}
|
||||
showBulkResult(json, ask.title);
|
||||
showBulkResult(json, title);
|
||||
loadUsers();
|
||||
}
|
||||
|
||||
// T12.5: delete is permanent (a hard delete, as for one account) and one bad
|
||||
// multi-select now removes many, so it asks more than the other actions do:
|
||||
// every affected username is listed, and nothing is sent until the word DELETE
|
||||
// is typed, whatever the count (confirmed 2026-10-06). Your own account cannot
|
||||
// be selected; if it ever reached the request, the server refuses that row and
|
||||
// the report names it.
|
||||
async function bulkDelete(){
|
||||
const chosen = _users.filter(u => _selected.has(u.id));
|
||||
if(!chosen.length) return;
|
||||
const n = chosen.length;
|
||||
const typed = await wpPromptDialog({
|
||||
title: 'Delete '+people(n),
|
||||
message: 'Delete '+(n === 1 ? 'this account' : 'these '+n+' accounts')+'? Each one, and every project '+
|
||||
'assignment it has, is removed. This cannot be undone. Disable them instead if you only want to '+
|
||||
'block sign-in.\n\n'+chosen.map(u => '• '+u.username+(u.full_name ? ' ('+u.full_name+')' : '')).join('\n'),
|
||||
label: 'Type DELETE to confirm',
|
||||
value: '',
|
||||
okLabel: 'Delete '+people(n),
|
||||
validate: v => v === 'DELETE' ? '' : 'Type DELETE, in capital letters, to confirm.',
|
||||
});
|
||||
if(typed !== 'DELETE') return;
|
||||
return sendBulk('/api/auth/bulk-users/delete', {}, 'Delete accounts', chosen.map(u => u.id));
|
||||
}
|
||||
|
||||
// Every row is accounted for: changed, already so, or failed with the server's
|
||||
// reason. A batch that partly failed never reads as a success (CR-020).
|
||||
function showBulkResult(json, title){
|
||||
|
||||
Reference in New Issue
Block a user