Let a non-blocking checklist item be dismissed with a recorded decision, and run discovery on the mirror once there is something to discover

This commit is contained in:
Gmer4Lfe
2026-08-16 21:56:00 -04:00
parent 39dba3f8ab
commit cce1e25c2b
5 changed files with 146 additions and 6 deletions
+33 -3
View File
@@ -446,16 +446,40 @@ const vvActionHref = {
onboard: '?tab=partnership',
};
// URLSearchParams, not FormData — a FormData fetch POST hangs on this platform with no status
// and no server-side trace. The fetch shim in Varaverk.page adds the CSRF header either way.
function vvDeferItem(btn, id, defer) {
btn.disabled = true;
btn.textContent = defer ? 'Deferring…' : 'Restoring…';
fetch('/plugins/varaverk/api/setup.php', {
method: 'POST', headers: {'Content-Type': 'application/x-www-form-urlencoded'},
body: new URLSearchParams({action: defer ? 'defer' : 'undefer', item: id})
}).then(r => r.text()).then(text => {
if (!text.trim()) throw new Error('Empty response — request rejected before it reached setup.php');
const d = JSON.parse(text);
if (!d.ok) throw new Error(d.error || 'Unknown error');
vvLoadChecklist();
}).catch(e => {
btn.disabled = false;
btn.textContent = defer ? 'Not now' : 'Undo';
vvAlert('Could not update: ' + e.message);
});
}
function vvLoadChecklist() {
fetch('/plugins/varaverk/api/checklist.php?_=' + Date.now())
.then(r => r.json()).then(d => {
const el = document.getElementById('vv-checklist');
if (!d.ok || !d.items) { el.innerHTML = '<span style="color:#555">Unable to load checklist</span>'; return; }
el.innerHTML = d.items.map(item => {
const icon = item.ok === null ? '○' : (item.ok ? '✓' : '✗');
const iclr = item.ok === null ? '#444' : (item.ok ? '#4a8' : '#a66');
// Deferred reads as its own state, not as pass and not as fail: the thing is still not
// done, the operator has said not now, and the row has to keep saying both.
const icon = item.deferred ? '' : (item.ok === null ? '○' : (item.ok ? '✓' : '✗'));
const iclr = item.deferred ? '#a80' : (item.ok === null ? '#444' : (item.ok ? '#4a8' : '#a66'));
let act = '';
if (item.action) {
if (item.action === 'undefer') {
act = `<div class="vv-cl-act"><button onclick="vvDeferItem(this,'${item.id}',false)">Undo</button></div>`;
} else if (item.action) {
const lbl = vvActionLabels[item.action] || item.action;
const href = vvActionHref[item.action];
if (href) {
@@ -471,6 +495,12 @@ function vvLoadChecklist() {
+ `<div id="vv-ssh-out" class="vv-cl-err"></div></div>`;
}
}
// Offered alongside the real action, never instead of it — "not now" is a second choice
// on a row that still tells you how to do the thing.
if (item.can_defer) {
act += `<div class="vv-cl-act"><button onclick="vvDeferItem(this,'${item.id}',true)"
style="background:#1a1400;border-color:#3a2e00;color:#a80;">Not now</button></div>`;
}
return `<div class="vv-cl-item">
<div class="vv-cl-icon" style="color:${iclr}">${icon}</div>
<div class="vv-cl-body">