Ask with Unraid's own dialog, not the browser's
Every confirm() and prompt() in the plugin could be switched off from inside itself — one tick of "prevent this page from creating additional dialogs" and all 32 of them returned false while drawing nothing, across every tab, until a full reload. swal is already global on every webGUI page and core uses it 370 times without a single confirm(), so this costs no new dependency. vvConfirmRun() is the one that mattered: it returned a boolean to three callers testing !it, and an unawaited promise is always truthy, so leaving those alone would have run every job without asking. The wrapper's callback is a classic function expression on purpose — SweetAlert only calls back on cancel when the callback's own source declares a parameter, and an arrow would have hung the promise forever.
This commit is contained in:
@@ -512,7 +512,7 @@ function _showModalErr(id, msg) {
|
||||
}
|
||||
|
||||
// Proxy event delegation
|
||||
document.getElementById('vv-au-panel-proxies').addEventListener('click', e => {
|
||||
document.getElementById('vv-au-panel-proxies').addEventListener('click', async e => {
|
||||
// Add button
|
||||
if (e.target.id === 'vv-au-proxy-add') { _proxyModal(null); return; }
|
||||
// Toggle
|
||||
@@ -534,7 +534,7 @@ document.getElementById('vv-au-panel-proxies').addEventListener('click', e => {
|
||||
if (delBtn) {
|
||||
const id = parseInt(delBtn.dataset.proxyDel);
|
||||
const p = _proxies.find(x => x.id === id);
|
||||
if (!confirm('Delete proxy for ' + (p?.domain_names||['this host']).join(', ') + '?')) return;
|
||||
if (!await vvConfirm('Delete proxy for ' + (p?.domain_names||['this host']).join(', ') + '?')) return;
|
||||
_post({ action:'npm_delete', id }, r => { if (r.ok) _loadProxies(); });
|
||||
}
|
||||
});
|
||||
@@ -678,7 +678,7 @@ function _addToGroupModal(uid) {
|
||||
}
|
||||
|
||||
// User event delegation
|
||||
document.getElementById('vv-au-panel-users').addEventListener('click', e => {
|
||||
document.getElementById('vv-au-panel-users').addEventListener('click', async e => {
|
||||
if (e.target.id === 'vv-au-user-add') { _userModal(null); return; }
|
||||
|
||||
const editBtn = e.target.closest('[data-user-edit]');
|
||||
@@ -694,7 +694,7 @@ document.getElementById('vv-au-panel-users').addEventListener('click', e => {
|
||||
if (delBtn) {
|
||||
const uid = delBtn.dataset.userDel;
|
||||
const user = _users.find(u => u.id === uid);
|
||||
if (!confirm('Delete user "' + (user?.displayName||uid) + '"?')) return;
|
||||
if (!await vvConfirm('Delete user "' + (user?.displayName||uid) + '"?')) return;
|
||||
_post({ action:'lldap_delete_user', uid }, r => { if (r.ok) _loadUsers(); });
|
||||
return;
|
||||
}
|
||||
@@ -704,7 +704,7 @@ document.getElementById('vv-au-panel-users').addEventListener('click', e => {
|
||||
const uid = rmBadge.dataset.rmFromGroup;
|
||||
const gid = parseInt(rmBadge.dataset.gid);
|
||||
const grp = _groups.find(g => g.id === gid);
|
||||
if (!confirm('Remove from group "' + (grp?.displayName||gid) + '"?')) return;
|
||||
if (!await vvConfirm('Remove from group "' + (grp?.displayName||gid) + '"?')) return;
|
||||
_post({ action:'lldap_remove_from_group', uid, gid }, r => { if (r.ok) { _loadUsers(); _loadGroups(); } });
|
||||
}
|
||||
});
|
||||
@@ -745,7 +745,7 @@ function _loadGroups() {
|
||||
}
|
||||
|
||||
// Group event delegation
|
||||
document.getElementById('vv-au-panel-users').addEventListener('click', e => {
|
||||
document.getElementById('vv-au-panel-users').addEventListener('click', async e => {
|
||||
if (e.target.id === 'vv-au-group-add') {
|
||||
_modal(`<h3>Add Group</h3>
|
||||
<div class="vv-au-field">
|
||||
@@ -783,7 +783,7 @@ document.getElementById('vv-au-panel-users').addEventListener('click', e => {
|
||||
e.stopPropagation();
|
||||
const id = parseInt(delGrp.dataset.groupDel);
|
||||
const grp = _groups.find(g => g.id === id);
|
||||
if (!confirm('Delete group "' + (grp?.displayName||id) + '"?')) return;
|
||||
if (!await vvConfirm('Delete group "' + (grp?.displayName||id) + '"?')) return;
|
||||
_post({ action:'lldap_delete_group', id }, r => { if (r.ok) _loadGroups(); });
|
||||
return;
|
||||
}
|
||||
@@ -927,7 +927,7 @@ function _ruleModal(idx) {
|
||||
}
|
||||
|
||||
// ACL event delegation
|
||||
document.getElementById('vv-au-panel-acl').addEventListener('click', e => {
|
||||
document.getElementById('vv-au-panel-acl').addEventListener('click', async e => {
|
||||
if (e.target.id === 'vv-au-rule-add') { _ruleModal(null); return; }
|
||||
|
||||
if (e.target.id === 'vv-au-ac-save') {
|
||||
@@ -950,7 +950,7 @@ document.getElementById('vv-au-panel-acl').addEventListener('click', e => {
|
||||
const delBtn = e.target.closest('[data-rule-del]');
|
||||
if (delBtn) {
|
||||
const i = parseInt(delBtn.dataset.ruleDel);
|
||||
if (!confirm('Delete this rule?')) return;
|
||||
if (!await vvConfirm('Delete this rule?')) return;
|
||||
_rules.splice(i, 1);
|
||||
_renderAcl();
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user