The flow editor can now change a flow's shape on the canvas, not only through the inspector's fields: - drag a box onto another to move it and its branch there; a drop the save would refuse shows the target dashed red and gives the reason; - a palette of node kinds adds a node below the picked box on click, or below any box it is dragged onto; it offers what the controller lists; - arrow keys walk the tree, M picks a box up and Enter drops it under the focused one, Alt+Up/Down reorder a node among its siblings, Delete removes a branch; focus follows the edit; - each box with siblings says when it runs, and the inspector can move it earlier or later, since the router runs children in edge order; - request_reviewer is a second leaf kind beside todo, with a reviewer field; - leaving with unsaved edits asks first, also for in-app links and the back button (a router hook runs navigation past a page's guard).
28 lines
889 B
JavaScript
28 lines
889 B
JavaScript
// The guard a page holding unsaved work puts in front of in-app navigation.
|
|
// Run by `npm test`.
|
|
import assert from "node:assert/strict";
|
|
import { test } from "node:test";
|
|
import { mayNavigate, setNavGuard } from "../src/shell/navGuard.ts";
|
|
|
|
test("with no guard every move goes ahead", () => {
|
|
setNavGuard(null);
|
|
assert.equal(mayNavigate("/alerts"), true);
|
|
});
|
|
|
|
test("a guard that says no stops the move and is told where it was headed", () => {
|
|
const asked = [];
|
|
setNavGuard((to) => {
|
|
asked.push(to);
|
|
return false;
|
|
});
|
|
assert.equal(mayNavigate("/alerts"), false);
|
|
assert.deepEqual(asked, ["/alerts"]);
|
|
setNavGuard(null);
|
|
assert.equal(mayNavigate("/alerts"), true, "removing it lets moves through");
|
|
});
|
|
|
|
test("a guard that says yes lets the move through", () => {
|
|
setNavGuard(() => true);
|
|
assert.equal(mayNavigate("/jobs"), true);
|
|
setNavGuard(null);
|
|
});
|