1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-03 17:36:05 +00:00

fix(ui): a block or a job's cancel asks first; every delete and save says it is done

- Block in the Users list asks first: the user is signed out and their
  API tokens are deleted, which unblocking does not bring back. Block
  and Unblock then say what they did.
- Cancel on a job's page and in the job panel asks first, naming the
  job; the button says Cancel the job, apart from the dialog's Cancel.
- Deleting a user or a group, removing a host from the panel or an
  owner from a VM, and deleting an interface, a network filter or a
  secret say so, as the other deletes do.
- Renaming a tag and saving a VM's title and description say so.
This commit is contained in:
catborise 2026-11-21 20:47:26 +03:00
parent 00a44f7621
commit e79817e7db
22 changed files with 247 additions and 39 deletions

View file

@ -53,7 +53,7 @@ const urls = { resource: "/r", job: (id) => "/j/" + id, cancel: (id) => "/c/" +
// the labels and texts the page gives (job_panel_script), here as in English
const STATES = { queued: "queued", running: "running", cancelling: "cancelling", succeeded: "succeeded",
failed: "failed", cancelled: "cancelled", uncertain: "uncertain" };
const TEXT = { cancel: "Cancel", open: "Open", refresh: "Refresh", dismiss: "Dismiss", finishing: "Finishing\u2026",
const TEXT = { cancel: "Cancel", cancel_confirm: "Cancel %(job)s?", open: "Open", refresh: "Refresh", dismiss: "Dismiss", finishing: "Finishing\u2026",
not_removed: "Files not removed:", short_operation: "A short operation is in progress.",
worker_unavailable: "Worker unavailable, last seen", never: "never",
cancel_failed: "Cancel failed (HTTP %(status)s).",
@ -224,9 +224,15 @@ const queued = { ...running, id: "q", state: "queued", cancellable: true, progre
jobPanel(el9, urls, "tok", undefined, STATES, TEXT);
advance(0);
answer("/r", { ...empty, jobs: [queued] });
assert.ok(el9.innerHTML.includes('data-cancel="q">Cancel</button>'), "an enabled cancel button");
click9({ target: { dataset: { cancel: "q" } } });
assert.ok(el9.innerHTML.includes('data-cancel="q" disabled>'), "disabled while the request runs");
assert.ok(el9.innerHTML.includes('data-cancel="q" data-label="' + queued.label + '">Cancel</button>'), "an enabled cancel button");
// asked first (confirm_dialog.js): nothing is sent until it is confirmed
let asked = [];
global.confirmAction = (action, question, danger, act) => asked.push({ action, question, act });
click9({ target: { dataset: { cancel: "q", label: queued.label } } });
assert.deepStrictEqual(asked.map((a) => [a.action, a.question]), [["Cancel", "Cancel " + queued.label + "?"]]);
assert.ok(!open.some((r) => r.url === "/c/q"), "not cancelled before it is confirmed");
asked[0].act();
assert.ok(el9.innerHTML.includes('data-label="' + queued.label + '" disabled>'), "disabled while the request runs");
answer("/c/q", { status: 400, responseJSON: { detail: "This job cannot be cancelled once it has started" } }, false);
assert.ok(el9.innerHTML.includes("This job cannot be cancelled once it has started")
&& el9.innerHTML.includes('class="alert alert-danger'), "the server's reason shows");
@ -238,7 +244,8 @@ click9({ target: { dataset: { dismissError: "1" } } });
assert.ok(!el9.innerHTML.includes("cannot be cancelled"), "the reason can be dismissed");
advance(3000);
answer("/r", { ...empty, jobs: [queued] });
click9({ target: { dataset: { cancel: "q" } } });
click9({ target: { dataset: { cancel: "q", label: queued.label } } });
asked[asked.length - 1].act();
answer("/c/q", { status: 0 }, false);
assert.ok(el9.innerHTML.includes("could not be reached"), "a network error shows");