@warlock.js/grimoire 5.57.0 → 5.59.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +44 -0
- package/esm/apps/check-apps.mjs +11 -5
- package/esm/apps/check-apps.mjs.map +1 -1
- package/esm/book/build.d.mts.map +1 -1
- package/esm/book/build.mjs +2 -1
- package/esm/book/build.mjs.map +1 -1
- package/esm/book/render.mjs +10 -0
- package/esm/book/render.mjs.map +1 -1
- package/esm/bookmap/build.d.mts.map +1 -1
- package/esm/bookmap/build.mjs +7 -5
- package/esm/bookmap/build.mjs.map +1 -1
- package/esm/bookmap/steps.mjs +85 -39
- package/esm/bookmap/steps.mjs.map +1 -1
- package/esm/check/check-grimoire.d.mts.map +1 -1
- package/esm/check/check-grimoire.mjs +4 -1
- package/esm/check/check-grimoire.mjs.map +1 -1
- package/esm/check/rules/criteria.mjs +21 -2
- package/esm/check/rules/criteria.mjs.map +1 -1
- package/esm/check/rules/screenshots.mjs +57 -0
- package/esm/check/rules/screenshots.mjs.map +1 -0
- package/esm/codes/codes.d.mts +12 -0
- package/esm/codes/codes.d.mts.map +1 -1
- package/esm/codes/codes.mjs +6 -0
- package/esm/codes/codes.mjs.map +1 -1
- package/esm/contracts/adapter.d.mts +28 -1
- package/esm/contracts/adapter.d.mts.map +1 -1
- package/esm/contracts/book.d.mts +2 -0
- package/esm/contracts/book.d.mts.map +1 -1
- package/esm/contracts/book.mjs.map +1 -1
- package/esm/contracts/bookmap.d.mts +19 -1
- package/esm/contracts/bookmap.d.mts.map +1 -1
- package/esm/contracts/scry.d.mts +26 -6
- package/esm/contracts/scry.d.mts.map +1 -1
- package/esm/contracts/snapshot.d.mts +14 -1
- package/esm/contracts/snapshot.d.mts.map +1 -1
- package/esm/contracts/test-results.d.mts +34 -0
- package/esm/contracts/test-results.d.mts.map +1 -1
- package/esm/contracts/written.d.mts +44 -0
- package/esm/contracts/written.d.mts.map +1 -1
- package/esm/contracts/written.mjs.map +1 -1
- package/esm/devtools/data.mjs +116 -5
- package/esm/devtools/data.mjs.map +1 -1
- package/esm/devtools/feature-map.mjs +149 -0
- package/esm/devtools/feature-map.mjs.map +1 -0
- package/esm/devtools/index.d.mts +28 -2
- package/esm/devtools/index.d.mts.map +1 -1
- package/esm/devtools/index.mjs +111 -7
- package/esm/devtools/index.mjs.map +1 -1
- package/esm/devtools/product-map.d.mts +14 -0
- package/esm/devtools/product-map.d.mts.map +1 -0
- package/esm/devtools/product-map.mjs +460 -0
- package/esm/devtools/product-map.mjs.map +1 -0
- package/esm/devtools/site.d.mts +43 -1
- package/esm/devtools/site.d.mts.map +1 -1
- package/esm/devtools/site.mjs +190 -22
- package/esm/devtools/site.mjs.map +1 -1
- package/esm/devtools/snapshot-source.mjs +24 -7
- package/esm/devtools/snapshot-source.mjs.map +1 -1
- package/esm/graph/index.d.mts +10 -1
- package/esm/graph/index.d.mts.map +1 -1
- package/esm/graph/index.mjs +3 -2
- package/esm/graph/index.mjs.map +1 -1
- package/esm/index.d.mts +5 -5
- package/esm/ownership/index.d.mts.map +1 -1
- package/esm/ownership/index.mjs +60 -1
- package/esm/ownership/index.mjs.map +1 -1
- package/esm/paths/index.d.mts +2 -0
- package/esm/paths/index.d.mts.map +1 -1
- package/esm/paths/index.mjs +3 -1
- package/esm/paths/index.mjs.map +1 -1
- package/esm/scry/compact.mjs +170 -0
- package/esm/scry/compact.mjs.map +1 -0
- package/esm/scry/format.d.mts.map +1 -1
- package/esm/scry/format.mjs +19 -2
- package/esm/scry/format.mjs.map +1 -1
- package/esm/scry/query.d.mts.map +1 -1
- package/esm/scry/query.mjs +159 -24
- package/esm/scry/query.mjs.map +1 -1
- package/esm/test-results/index.d.mts +7 -2
- package/esm/test-results/index.d.mts.map +1 -1
- package/esm/test-results/index.mjs +79 -12
- package/esm/test-results/index.mjs.map +1 -1
- package/esm/vitest/index.d.mts +6 -0
- package/esm/vitest/index.d.mts.map +1 -1
- package/esm/vitest/index.mjs +22 -6
- package/esm/vitest/index.mjs.map +1 -1
- package/esm/warlock/actions.mjs +15 -7
- package/esm/warlock/actions.mjs.map +1 -1
- package/esm/warlock/adapter.d.mts.map +1 -1
- package/esm/warlock/adapter.mjs +42 -4
- package/esm/warlock/adapter.mjs.map +1 -1
- package/esm/warlock/commands.mjs +7 -2
- package/esm/warlock/commands.mjs.map +1 -1
- package/esm/warlock/logo.mjs +12 -0
- package/esm/warlock/logo.mjs.map +1 -0
- package/esm/warlock/mcp-tools.mjs +51 -15
- package/esm/warlock/mcp-tools.mjs.map +1 -1
- package/esm/workspace/cache.mjs +194 -0
- package/esm/workspace/cache.mjs.map +1 -0
- package/esm/workspace/index.d.mts.map +1 -1
- package/esm/workspace/index.mjs +7 -3
- package/esm/workspace/index.mjs.map +1 -1
- package/esm/written/apps.mjs +4 -2
- package/esm/written/apps.mjs.map +1 -1
- package/esm/written/features.mjs +119 -6
- package/esm/written/features.mjs.map +1 -1
- package/esm/written/markdown.mjs +66 -1
- package/esm/written/markdown.mjs.map +1 -1
- package/esm/written/parse-grimoire.d.mts.map +1 -1
- package/esm/written/parse-grimoire.mjs +1 -1
- package/esm/written/parse-grimoire.mjs.map +1 -1
- package/llms-full.txt +108 -12
- package/package.json +3 -3
- package/skills/backfill-a-grimoire/SKILL.md +5 -0
- package/skills/describe-an-app/SKILL.md +12 -0
- package/skills/record-a-change/SKILL.md +10 -0
- package/skills/use-the-grimoire/SKILL.md +44 -10
- package/skills/write-a-feature/SKILL.md +37 -2
- package/ui/grimoire-static.js +61 -6
- package/ui/grimoire-view.js +2133 -316
- package/ui/grimoire.css +1030 -24
- package/ui/product-map.css +785 -0
- package/ui/product-map.js +1265 -0
package/ui/grimoire-view.js
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
/** The tabs: `[route, label]`. */
|
|
11
11
|
const TABS = [
|
|
12
|
+
["product", "Product map"],
|
|
12
13
|
["", "Overview"],
|
|
13
14
|
["features", "Features"],
|
|
14
15
|
["apps", "Apps"],
|
|
@@ -46,9 +47,11 @@ function plural(count, word) {
|
|
|
46
47
|
|
|
47
48
|
/** Which tab a hash route belongs to; `null` when it belongs to none. */
|
|
48
49
|
function tabOf(route) {
|
|
49
|
-
const type = route.split("/")[0] ?? "";
|
|
50
|
+
const type = (route.split("?")[0] ?? "").split("/")[0] ?? "";
|
|
50
51
|
|
|
51
52
|
switch (type) {
|
|
53
|
+
case "product":
|
|
54
|
+
return "product";
|
|
52
55
|
case "features":
|
|
53
56
|
case "feature":
|
|
54
57
|
case "flow":
|
|
@@ -148,6 +151,19 @@ function link(ctx, text, target, attrs = {}) {
|
|
|
148
151
|
return ctx.el("a", { href: ctx.href(target), text, ...attrs });
|
|
149
152
|
}
|
|
150
153
|
|
|
154
|
+
/** The words for the state of the route facts, shared by Overview and Check. */
|
|
155
|
+
function routeFactsState(state) {
|
|
156
|
+
const value = state ?? "cached";
|
|
157
|
+
const sub = {
|
|
158
|
+
fresh: "read from the running app",
|
|
159
|
+
cached: "from the last build",
|
|
160
|
+
stale: "older than the code. Run warlock grimoire build to refresh them",
|
|
161
|
+
missing: "none yet: route, mail and notification steps are not checked",
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
return { value, sub: sub[value] ?? "", stale: value === "stale" || value === "missing" };
|
|
165
|
+
}
|
|
166
|
+
|
|
151
167
|
/** The tone (`good`, `info`, `warn`, `bad`, or none) a status word is shown in. */
|
|
152
168
|
function toneOf(status) {
|
|
153
169
|
switch (status) {
|
|
@@ -158,6 +174,7 @@ function toneOf(status) {
|
|
|
158
174
|
case "done":
|
|
159
175
|
case "fresh":
|
|
160
176
|
case "cached":
|
|
177
|
+
case "clean":
|
|
161
178
|
return "good";
|
|
162
179
|
case "building":
|
|
163
180
|
case "open":
|
|
@@ -169,6 +186,8 @@ function toneOf(status) {
|
|
|
169
186
|
case "stale":
|
|
170
187
|
case "missing":
|
|
171
188
|
case "untested":
|
|
189
|
+
case "not-run":
|
|
190
|
+
case "no-test":
|
|
172
191
|
return "warn";
|
|
173
192
|
case "failing":
|
|
174
193
|
case "fail":
|
|
@@ -191,6 +210,88 @@ function muted(ctx, text) {
|
|
|
191
210
|
return ctx.el("span", { class: "grimoire-muted", text });
|
|
192
211
|
}
|
|
193
212
|
|
|
213
|
+
/** "Warlock.js v5.58.0" with the framework logo, from the adapter's host; nothing when the adapter reports none. */
|
|
214
|
+
function grimoireBrand(ctx, host) {
|
|
215
|
+
if (!host || !host.name) return null;
|
|
216
|
+
|
|
217
|
+
return ctx.el("div", { class: "grimoire-brand" }, [
|
|
218
|
+
host.logo
|
|
219
|
+
? ctx.el("img", {
|
|
220
|
+
class: "grimoire-brand-logo",
|
|
221
|
+
src: host.logo,
|
|
222
|
+
alt: "",
|
|
223
|
+
width: "24",
|
|
224
|
+
height: "24",
|
|
225
|
+
})
|
|
226
|
+
: "",
|
|
227
|
+
ctx.el("span", { class: "grimoire-brand-name", text: host.name }),
|
|
228
|
+
host.version
|
|
229
|
+
? ctx.el("span", { class: "grimoire-brand-version", text: `v${host.version}` })
|
|
230
|
+
: "",
|
|
231
|
+
]);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/** The app's own name and version ("shop 1.4.0") for the bottom of the view; `null` when unknown. */
|
|
235
|
+
function grimoireAppLine(ctx, host) {
|
|
236
|
+
const app = host && host.app;
|
|
237
|
+
|
|
238
|
+
if (!app || !app.name) return null;
|
|
239
|
+
|
|
240
|
+
return ctx.el("p", { class: "grimoire-appline" }, [
|
|
241
|
+
ctx.el("span", { class: "grimoire-muted", text: "App " }),
|
|
242
|
+
ctx.el("span", {
|
|
243
|
+
class: "grimoire-mono",
|
|
244
|
+
text: app.version ? `${app.name} ${app.version}` : app.name,
|
|
245
|
+
}),
|
|
246
|
+
]);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/** One flow card: the heading as the title, the id under it, the status, and the counts that are known. */
|
|
250
|
+
function grimoireFlowCard(ctx, feature, flow) {
|
|
251
|
+
const { el } = ctx;
|
|
252
|
+
const count = (value, one, many = `${one}s`) =>
|
|
253
|
+
typeof value === "number" ? `${value} ${value === 1 ? one : many}` : null;
|
|
254
|
+
const metrics = [
|
|
255
|
+
count(flow.steps, "step"),
|
|
256
|
+
count(flow.cases, "case"),
|
|
257
|
+
typeof flow.criteria === "number"
|
|
258
|
+
? typeof flow.tested === "number"
|
|
259
|
+
? `${flow.tested}/${flow.criteria} criteria tested`
|
|
260
|
+
: count(flow.criteria, "criterion", "criteria")
|
|
261
|
+
: null,
|
|
262
|
+
].filter(Boolean);
|
|
263
|
+
const findings = typeof flow.findings === "number" ? flow.findings : 0;
|
|
264
|
+
|
|
265
|
+
return el("li", { class: "grimoire-flowcard" }, [
|
|
266
|
+
el("div", { class: "grimoire-flowcard-top" }, [
|
|
267
|
+
pill(ctx, flow.status, toneOf(flow.status)),
|
|
268
|
+
el("span", { class: "grimoire-muted", text: `since ${flow.since}` }),
|
|
269
|
+
]),
|
|
270
|
+
el("h4", { class: "grimoire-flowcard-title" }, [
|
|
271
|
+
link(
|
|
272
|
+
ctx,
|
|
273
|
+
flow.heading ?? flow.id,
|
|
274
|
+
`flow/${encodeURIComponent(feature)}/${encodeURIComponent(flow.id)}`,
|
|
275
|
+
{ class: "grimoire-flowcard-link" },
|
|
276
|
+
),
|
|
277
|
+
]),
|
|
278
|
+
flow.heading ? el("span", { class: "grimoire-mono grimoire-muted", text: flow.id }) : "",
|
|
279
|
+
metrics.length
|
|
280
|
+
? el(
|
|
281
|
+
"ul",
|
|
282
|
+
{ class: "grimoire-flowcard-metrics" },
|
|
283
|
+
metrics.map((text) => el("li", { text })),
|
|
284
|
+
)
|
|
285
|
+
: "",
|
|
286
|
+
findings > 0
|
|
287
|
+
? el("span", {
|
|
288
|
+
class: "grimoire-pill is-warn grimoire-flowcard-findings",
|
|
289
|
+
text: `${findings} ${findings === 1 ? "finding" : "findings"}`,
|
|
290
|
+
})
|
|
291
|
+
: "",
|
|
292
|
+
]);
|
|
293
|
+
}
|
|
294
|
+
|
|
194
295
|
function list(ctx, items) {
|
|
195
296
|
return ctx.el(
|
|
196
297
|
"ul",
|
|
@@ -217,7 +318,7 @@ function table(ctx, headings, rows) {
|
|
|
217
318
|
ctx.el(
|
|
218
319
|
"tr",
|
|
219
320
|
{},
|
|
220
|
-
row.map((cell) => ctx.el("td", {}, cell)),
|
|
321
|
+
row.map((cell, column) => ctx.el("td", { "data-label": headings[column] ?? "" }, cell)),
|
|
221
322
|
),
|
|
222
323
|
),
|
|
223
324
|
),
|
|
@@ -317,6 +418,218 @@ function routeLink(ctx, method, path) {
|
|
|
317
418
|
);
|
|
318
419
|
}
|
|
319
420
|
|
|
421
|
+
/** Split a hash route into its path and its query (`check?code=GR3006&feature=cart`). */
|
|
422
|
+
function parseRoute(route) {
|
|
423
|
+
const at = route.indexOf("?");
|
|
424
|
+
const query = {};
|
|
425
|
+
|
|
426
|
+
if (at >= 0) {
|
|
427
|
+
for (const [key, value] of new URLSearchParams(route.slice(at + 1))) query[key] = value;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
return { path: at < 0 ? route : route.slice(0, at), query };
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
/** The hash route of the Check tab for a filter; empty values are left out. */
|
|
434
|
+
function checkTarget(filter) {
|
|
435
|
+
const params = new URLSearchParams();
|
|
436
|
+
|
|
437
|
+
for (const key of ["code", "feature", "flow", "severity", "state", "offset", "limit"]) {
|
|
438
|
+
const value = filter[key];
|
|
439
|
+
|
|
440
|
+
if (value !== undefined && value !== null && value !== "") params.set(key, String(value));
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
const text = params.toString();
|
|
444
|
+
|
|
445
|
+
return text ? `check?${text}` : "check";
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* Text with `` `code` `` spans as nodes: plain strings and `<code>` elements.
|
|
450
|
+
* Every part is set as text. Unbalanced backticks stay as written.
|
|
451
|
+
*/
|
|
452
|
+
function codeText(ctx, text) {
|
|
453
|
+
const value = String(text ?? "");
|
|
454
|
+
|
|
455
|
+
if (!value.includes("`")) return value;
|
|
456
|
+
|
|
457
|
+
const parts = value.split("`");
|
|
458
|
+
|
|
459
|
+
if (parts.length % 2 === 0) return value;
|
|
460
|
+
|
|
461
|
+
return parts
|
|
462
|
+
.map((part, index) =>
|
|
463
|
+
index % 2 === 1 ? ctx.el("code", { class: "grimoire-code", text: part }) : part,
|
|
464
|
+
)
|
|
465
|
+
.filter((part) => part !== "");
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
/** The reason of a "does not apply" case, without the words the view groups it under. */
|
|
469
|
+
function stripDoesNotApply(answer) {
|
|
470
|
+
const rest = String(answer ?? "")
|
|
471
|
+
.replace(/^does not apply\b[:\s—-]*/i, "")
|
|
472
|
+
.trim();
|
|
473
|
+
|
|
474
|
+
return rest || "no reason written";
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
/** Select a node's text so the reader can copy it by hand. */
|
|
478
|
+
function selectNode(node, done) {
|
|
479
|
+
try {
|
|
480
|
+
const selection = globalThis.getSelection?.();
|
|
481
|
+
const range = globalThis.document?.createRange?.();
|
|
482
|
+
|
|
483
|
+
if (selection && range) {
|
|
484
|
+
range.selectNodeContents(node);
|
|
485
|
+
selection.removeAllRanges();
|
|
486
|
+
selection.addRange(range);
|
|
487
|
+
done("Selected. Press Ctrl+C to copy.");
|
|
488
|
+
return;
|
|
489
|
+
}
|
|
490
|
+
} catch {
|
|
491
|
+
// Fall through to the plain message.
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
done("Select the line and copy it by hand.");
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
/** Copy text with the clipboard API; fall back to selecting `node`. Never throws. */
|
|
498
|
+
function copyText(text, node, done) {
|
|
499
|
+
try {
|
|
500
|
+
const clipboard = globalThis.navigator?.clipboard;
|
|
501
|
+
|
|
502
|
+
if (clipboard && typeof clipboard.writeText === "function") {
|
|
503
|
+
Promise.resolve(clipboard.writeText(text)).then(
|
|
504
|
+
() => done("Copied."),
|
|
505
|
+
() => selectNode(node, done),
|
|
506
|
+
);
|
|
507
|
+
return;
|
|
508
|
+
}
|
|
509
|
+
} catch {
|
|
510
|
+
// Fall through to selecting.
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
selectNode(node, done);
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
const STEP_ICONS = {
|
|
517
|
+
page: [
|
|
518
|
+
["rect", { x: "3", y: "4", width: "18", height: "14", rx: "2" }],
|
|
519
|
+
["path", { d: "M3 9h18" }],
|
|
520
|
+
],
|
|
521
|
+
route: [["path", { d: "M5 12h14M13 6l6 6-6 6" }]],
|
|
522
|
+
mail: [
|
|
523
|
+
["rect", { x: "3", y: "5", width: "18", height: "14", rx: "2" }],
|
|
524
|
+
["path", { d: "M3 7l9 6 9-6" }],
|
|
525
|
+
],
|
|
526
|
+
notification: [["path", { d: "M6 16v-5a6 6 0 0 1 12 0v5l2 2H4zM10 21h4" }]],
|
|
527
|
+
job: [
|
|
528
|
+
["circle", { cx: "12", cy: "12", r: "9" }],
|
|
529
|
+
["path", { d: "M12 7v5l3 2" }],
|
|
530
|
+
],
|
|
531
|
+
event: [["path", { d: "M13 2L4 14h7l-1 8 9-12h-7z" }]],
|
|
532
|
+
"outside service": [["path", { d: "M7 18a4 4 0 0 1 0-8 5 5 0 0 1 9.6-1.2A4 4 0 0 1 17 18z" }]],
|
|
533
|
+
affects: [
|
|
534
|
+
[
|
|
535
|
+
"path",
|
|
536
|
+
{
|
|
537
|
+
d: "M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1",
|
|
538
|
+
},
|
|
539
|
+
],
|
|
540
|
+
],
|
|
541
|
+
};
|
|
542
|
+
|
|
543
|
+
/** A small icon for a flow step type. */
|
|
544
|
+
function stepIcon(ctx, type, size = 18) {
|
|
545
|
+
const { svg } = ctx;
|
|
546
|
+
const shapes = STEP_ICONS[type] ?? STEP_ICONS.route;
|
|
547
|
+
|
|
548
|
+
return svg(
|
|
549
|
+
"svg",
|
|
550
|
+
{
|
|
551
|
+
viewBox: "0 0 24 24",
|
|
552
|
+
width: String(size),
|
|
553
|
+
height: String(size),
|
|
554
|
+
fill: "none",
|
|
555
|
+
stroke: "currentColor",
|
|
556
|
+
"stroke-width": "1.8",
|
|
557
|
+
"stroke-linecap": "round",
|
|
558
|
+
"stroke-linejoin": "round",
|
|
559
|
+
"aria-hidden": "true",
|
|
560
|
+
class: "grimoire-step-icon",
|
|
561
|
+
},
|
|
562
|
+
shapes.map(([tag, attrs]) => svg(tag, attrs)),
|
|
563
|
+
);
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
/** Show a node's children only while open; the content is built on the first open. */
|
|
567
|
+
function expander(ctx, label, make) {
|
|
568
|
+
const panel = ctx.el("div", { class: "grimoire-expand" });
|
|
569
|
+
let node = null;
|
|
570
|
+
let open = false;
|
|
571
|
+
const button = ctx.el("button", {
|
|
572
|
+
type: "button",
|
|
573
|
+
class: "grimoire-more",
|
|
574
|
+
"aria-expanded": "false",
|
|
575
|
+
text: label,
|
|
576
|
+
onclick: () => {
|
|
577
|
+
open = !open;
|
|
578
|
+
if (open && node === null) node = make();
|
|
579
|
+
panel.replaceChildren(...(open && node ? [node] : []));
|
|
580
|
+
button.setAttribute("aria-expanded", String(open));
|
|
581
|
+
button.textContent = open ? "Hide" : label;
|
|
582
|
+
},
|
|
583
|
+
});
|
|
584
|
+
|
|
585
|
+
return { button, panel };
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
/**
|
|
589
|
+
* Findings loaded page by page from the check route: `filter` is a
|
|
590
|
+
* `GrimoireCheckFilter`; "Load more" appends the next page.
|
|
591
|
+
*/
|
|
592
|
+
function pagedFindings(ctx, filter, options = {}) {
|
|
593
|
+
const { el } = ctx;
|
|
594
|
+
const size = options.size ?? 20;
|
|
595
|
+
const list = el("ul", { class: "grimoire-findings" });
|
|
596
|
+
const status = el("p", { class: "grimoire-muted", role: "status" });
|
|
597
|
+
const more = el("button", { type: "button", class: "grimoire-filter", text: "Load more" });
|
|
598
|
+
const holder = el("div", { class: "grimoire-paged" });
|
|
599
|
+
let offset = 0;
|
|
600
|
+
let busy = false;
|
|
601
|
+
|
|
602
|
+
function paint(total, failed) {
|
|
603
|
+
status.textContent = failed
|
|
604
|
+
? `Could not load the findings: ${failed}. Try again.`
|
|
605
|
+
: `Showing ${offset} of ${total}`;
|
|
606
|
+
more.textContent = failed ? "Try again" : `Load ${Math.min(size, total - offset)} more`;
|
|
607
|
+
holder.replaceChildren(list, status, failed || offset < total ? more : "");
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
async function load() {
|
|
611
|
+
if (busy) return;
|
|
612
|
+
busy = true;
|
|
613
|
+
|
|
614
|
+
try {
|
|
615
|
+
const page = await ctx.api(checkTarget({ ...filter, offset, limit: size }));
|
|
616
|
+
|
|
617
|
+
for (const finding of page.findings) list.append(findingItem(ctx, finding, options));
|
|
618
|
+
offset += page.findings.length;
|
|
619
|
+
paint(page.total, null);
|
|
620
|
+
} catch (error) {
|
|
621
|
+
paint(0, error && error.message ? error.message : String(error));
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
busy = false;
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
more.addEventListener("click", load);
|
|
628
|
+
holder.append(el("p", { class: "grimoire-muted", role: "status", text: "Loading findings…" }));
|
|
629
|
+
load();
|
|
630
|
+
return holder;
|
|
631
|
+
}
|
|
632
|
+
|
|
320
633
|
/**
|
|
321
634
|
* A filterable, sortable listing: a text box, status buttons with counts, an
|
|
322
635
|
* optional sort menu and an "N of M" line. `render(shown)` returns the one
|
|
@@ -427,32 +740,28 @@ function listing(ctx, options) {
|
|
|
427
740
|
return el("div", { class: "grimoire-listing" }, [bar, count, body]);
|
|
428
741
|
}
|
|
429
742
|
|
|
430
|
-
/**
|
|
431
|
-
function
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
? ctx
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
: "",
|
|
453
|
-
]);
|
|
454
|
-
}),
|
|
455
|
-
);
|
|
743
|
+
/** One finding: severity, code, message, what to do (unless `hints` is `false`), and where. */
|
|
744
|
+
function findingItem(ctx, finding, options = {}) {
|
|
745
|
+
const place = finding.at ? `${finding.at.file}:${finding.at.line}` : null;
|
|
746
|
+
const file = finding.subject.file;
|
|
747
|
+
|
|
748
|
+
return ctx.el("li", { class: "grimoire-finding" }, [
|
|
749
|
+
ctx.el("div", { class: "grimoire-finding-head" }, [
|
|
750
|
+
pill(ctx, finding.severity, toneOf(finding.severity)),
|
|
751
|
+
finding.expected ? pill(ctx, "expected") : "",
|
|
752
|
+
mono(ctx, finding.code),
|
|
753
|
+
]),
|
|
754
|
+
ctx.el("p", { class: "grimoire-finding-message" }, codeText(ctx, finding.message)),
|
|
755
|
+
finding.hint && options.hints !== false
|
|
756
|
+
? ctx.el("p", { class: "grimoire-muted" }, codeText(ctx, finding.hint))
|
|
757
|
+
: "",
|
|
758
|
+
place || file
|
|
759
|
+
? ctx.el("div", { class: "grimoire-chips" }, [
|
|
760
|
+
place ? mono(ctx, place) : "",
|
|
761
|
+
file && file !== finding.at?.file ? fileLink(ctx, file) : "",
|
|
762
|
+
])
|
|
763
|
+
: "",
|
|
764
|
+
]);
|
|
456
765
|
}
|
|
457
766
|
|
|
458
767
|
function changesView(ctx, changes) {
|
|
@@ -463,7 +772,7 @@ function changesView(ctx, changes) {
|
|
|
463
772
|
pill(ctx, change.word),
|
|
464
773
|
` ${plain(change.version)} `,
|
|
465
774
|
change.flow ? [flowLink(ctx, `${change.feature}/${change.flow}`), " "] : "",
|
|
466
|
-
change.text,
|
|
775
|
+
codeText(ctx, change.text),
|
|
467
776
|
change.release
|
|
468
777
|
? ` (release ${change.release}${change.date ? `, ${change.date}` : ""})`
|
|
469
778
|
: " (not released)",
|
|
@@ -531,7 +840,11 @@ function graphView(ctx, graph, title) {
|
|
|
531
840
|
);
|
|
532
841
|
}
|
|
533
842
|
|
|
534
|
-
|
|
843
|
+
// Labels overlap on a crowded ring: stagger them, and past 40 nodes name only the centre
|
|
844
|
+
// (every node keeps its tooltip, and the module list sits under the graph).
|
|
845
|
+
const labelled = graph.nodes.length <= 40;
|
|
846
|
+
|
|
847
|
+
for (const [position, node] of graph.nodes.entries()) {
|
|
535
848
|
const at = place.get(node.id);
|
|
536
849
|
if (!at) continue;
|
|
537
850
|
const target = nodeTarget(node.id);
|
|
@@ -543,17 +856,33 @@ function graphView(ctx, graph, title) {
|
|
|
543
856
|
});
|
|
544
857
|
const label = svg("text", {
|
|
545
858
|
x: at[0].toFixed(1),
|
|
546
|
-
y: (at[1] + (node.type === "center" ? 24 : 18)).toFixed(1),
|
|
859
|
+
y: (at[1] + (node.type === "center" ? 24 : 18 + (position % 2) * 12)).toFixed(1),
|
|
547
860
|
"text-anchor": "middle",
|
|
548
861
|
fill: "var(--foreground)",
|
|
549
862
|
"font-size": "11",
|
|
550
|
-
text: shorten(node.label),
|
|
863
|
+
text: shorten(node.label, node.type === "center" ? 26 : 16),
|
|
551
864
|
});
|
|
552
|
-
const group = svg(
|
|
865
|
+
const group = svg(
|
|
866
|
+
"g",
|
|
867
|
+
{},
|
|
868
|
+
[
|
|
869
|
+
svg("title", { text: node.label }),
|
|
870
|
+
circle,
|
|
871
|
+
labelled || node.type === "center" ? label : "",
|
|
872
|
+
].filter((child) => child !== ""),
|
|
873
|
+
);
|
|
553
874
|
canvas.append(target === null ? group : svg("a", { href: href(target) }, [group]));
|
|
554
875
|
}
|
|
555
876
|
|
|
556
|
-
card.append(canvas);
|
|
877
|
+
card.append(el("div", { class: "grimoire-scroll" }, [canvas]));
|
|
878
|
+
if (!labelled) {
|
|
879
|
+
card.append(
|
|
880
|
+
el("p", {
|
|
881
|
+
class: "grimoire-muted",
|
|
882
|
+
text: "Too many nodes to label. Point at a node for its name; every module is listed below.",
|
|
883
|
+
}),
|
|
884
|
+
);
|
|
885
|
+
}
|
|
557
886
|
return card;
|
|
558
887
|
}
|
|
559
888
|
|
|
@@ -577,7 +906,7 @@ const STATUS_ORDER = ["shipped", "building", "proposed", "retired"];
|
|
|
577
906
|
async function overviewView(ctx, summaryRequest) {
|
|
578
907
|
const [data, check, releases] = await Promise.all([
|
|
579
908
|
summaryRequest,
|
|
580
|
-
ctx.api("check").catch(() => null),
|
|
909
|
+
ctx.api("check/groups").catch(() => null),
|
|
581
910
|
ctx.api("releases").catch(() => null),
|
|
582
911
|
]);
|
|
583
912
|
const { el } = ctx;
|
|
@@ -593,7 +922,8 @@ async function overviewView(ctx, summaryRequest) {
|
|
|
593
922
|
.join(", ");
|
|
594
923
|
const waiting = data.tasks.waiting.length;
|
|
595
924
|
const open = data.tasks.open.length - waiting;
|
|
596
|
-
const
|
|
925
|
+
const routeFacts = routeFactsState(data.routes);
|
|
926
|
+
const stale = routeFacts.stale;
|
|
597
927
|
const out = el("div", { class: "grimoire-view" });
|
|
598
928
|
|
|
599
929
|
out.append(
|
|
@@ -634,8 +964,8 @@ async function overviewView(ctx, summaryRequest) {
|
|
|
634
964
|
}),
|
|
635
965
|
stat(ctx, {
|
|
636
966
|
label: "Route facts",
|
|
637
|
-
value:
|
|
638
|
-
sub:
|
|
967
|
+
value: routeFacts.value,
|
|
968
|
+
sub: routeFacts.sub,
|
|
639
969
|
target: "check",
|
|
640
970
|
tone: toneOf(data.routes),
|
|
641
971
|
}),
|
|
@@ -646,7 +976,7 @@ async function overviewView(ctx, summaryRequest) {
|
|
|
646
976
|
out.append(
|
|
647
977
|
el("p", {
|
|
648
978
|
class: "grimoire-note",
|
|
649
|
-
text:
|
|
979
|
+
text: `Route facts: ${routeFacts.value}, ${routeFacts.sub}.`,
|
|
650
980
|
}),
|
|
651
981
|
);
|
|
652
982
|
}
|
|
@@ -661,7 +991,16 @@ async function overviewView(ctx, summaryRequest) {
|
|
|
661
991
|
);
|
|
662
992
|
}
|
|
663
993
|
|
|
664
|
-
|
|
994
|
+
// Errors first, then the biggest groups; each leads to the Check tab filtered to its code.
|
|
995
|
+
const problems = (check?.groups ?? [])
|
|
996
|
+
.filter((group) => group.count > 0)
|
|
997
|
+
.sort(
|
|
998
|
+
(left, right) =>
|
|
999
|
+
(left.severity === "error" ? 0 : 1) - (right.severity === "error" ? 0 : 1) ||
|
|
1000
|
+
right.count - left.count ||
|
|
1001
|
+
left.code.localeCompare(right.code),
|
|
1002
|
+
)
|
|
1003
|
+
.slice(0, 5);
|
|
665
1004
|
const recent = [...(releases?.releases ?? [])]
|
|
666
1005
|
.sort((left, right) => right.date.localeCompare(left.date))
|
|
667
1006
|
.slice(0, 5);
|
|
@@ -671,7 +1010,20 @@ async function overviewView(ctx, summaryRequest) {
|
|
|
671
1010
|
section(ctx, "Top problems", [
|
|
672
1011
|
check
|
|
673
1012
|
? problems.length
|
|
674
|
-
?
|
|
1013
|
+
? list(
|
|
1014
|
+
ctx,
|
|
1015
|
+
problems.map((group) => [
|
|
1016
|
+
pill(ctx, group.severity, toneOf(group.severity)),
|
|
1017
|
+
" ",
|
|
1018
|
+
link(ctx, group.code, checkTarget({ code: group.code }), {
|
|
1019
|
+
class: "grimoire-mono",
|
|
1020
|
+
}),
|
|
1021
|
+
" ",
|
|
1022
|
+
...[codeText(ctx, group.title)].flat(),
|
|
1023
|
+
" ",
|
|
1024
|
+
pill(ctx, String(group.count)),
|
|
1025
|
+
]),
|
|
1026
|
+
)
|
|
675
1027
|
: el("p", {}, [pill(ctx, "clean", "good"), " Nothing to fix."])
|
|
676
1028
|
: ctx.empty("The check report could not be loaded."),
|
|
677
1029
|
check ? el("p", {}, [link(ctx, "Open the check report", "check")]) : "",
|
|
@@ -804,247 +1156,1397 @@ async function featuresView(ctx) {
|
|
|
804
1156
|
]);
|
|
805
1157
|
}
|
|
806
1158
|
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
1159
|
+
// ── Tabs, groups and the feature map ────────────────────────────────────────
|
|
1160
|
+
|
|
1161
|
+
/** Move the address bar to `route` without reloading the view (the tab is already shown). */
|
|
1162
|
+
function rememberRoute(ctx, route) {
|
|
1163
|
+
try {
|
|
1164
|
+
globalThis.history?.replaceState?.(null, "", ctx.href(route));
|
|
1165
|
+
} catch {
|
|
1166
|
+
// A host that keeps its own history leaves the address as it is.
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
/**
|
|
1171
|
+
* Real tab buttons over lazily built panels. `tabs` is
|
|
1172
|
+
* `[{ id, label, count?, make }]`; `make()` runs the first time a tab opens, so
|
|
1173
|
+
* a long list in a closed tab costs nothing. `route(id)` is the hash route the
|
|
1174
|
+
* tab owns; the first tab is the default.
|
|
1175
|
+
*/
|
|
1176
|
+
function tabbed(ctx, { tabs, active, label, prefix, route }) {
|
|
812
1177
|
const { el } = ctx;
|
|
813
|
-
const
|
|
814
|
-
const
|
|
815
|
-
const
|
|
816
|
-
|
|
817
|
-
heading(ctx, plain(readme.title), [
|
|
818
|
-
mono(ctx, plain(readme.id)),
|
|
819
|
-
pill(ctx, status, toneOf(status)),
|
|
820
|
-
pill(ctx, `version ${plain(readme.version)}`),
|
|
821
|
-
readme.origin ? pill(ctx, plain(readme.origin), toneOf(plain(readme.origin))) : "",
|
|
822
|
-
muted(ctx, `updated ${plain(readme.updated)}`),
|
|
823
|
-
]),
|
|
824
|
-
]);
|
|
1178
|
+
const strip = el("div", { class: "grimoire-pagetabs", role: "tablist", "aria-label": label });
|
|
1179
|
+
const panel = el("div", { class: "grimoire-tabpanel", role: "tabpanel", tabindex: "0" });
|
|
1180
|
+
const buttons = new Map();
|
|
1181
|
+
const built = new Map();
|
|
825
1182
|
|
|
826
|
-
|
|
1183
|
+
function show(id, user) {
|
|
1184
|
+
const tab = tabs.find((item) => item.id === id) ?? tabs[0];
|
|
827
1185
|
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
1186
|
+
for (const [key, button] of buttons) {
|
|
1187
|
+
const on = key === tab.id;
|
|
1188
|
+
|
|
1189
|
+
button.setAttribute("aria-selected", String(on));
|
|
1190
|
+
button.setAttribute("tabindex", on ? "0" : "-1");
|
|
1191
|
+
button.setAttribute("class", on ? "grimoire-pagetab is-active" : "grimoire-pagetab");
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
if (!built.has(tab.id)) built.set(tab.id, tab.make());
|
|
1195
|
+
|
|
1196
|
+
panel.setAttribute("aria-labelledby", `${prefix}-tab-${tab.id}`);
|
|
1197
|
+
panel.replaceChildren(built.get(tab.id));
|
|
1198
|
+
if (user) rememberRoute(ctx, route(tab.id));
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
function move(from, step) {
|
|
1202
|
+
const next = tabs[(from + step + tabs.length) % tabs.length];
|
|
1203
|
+
|
|
1204
|
+
show(next.id, true);
|
|
1205
|
+
buttons.get(next.id)?.focus?.();
|
|
1206
|
+
}
|
|
1207
|
+
|
|
1208
|
+
tabs.forEach((tab, index) => {
|
|
1209
|
+
const button = el(
|
|
1210
|
+
"button",
|
|
1211
|
+
{
|
|
1212
|
+
type: "button",
|
|
1213
|
+
role: "tab",
|
|
1214
|
+
id: `${prefix}-tab-${tab.id}`,
|
|
1215
|
+
class: "grimoire-pagetab",
|
|
1216
|
+
"aria-selected": "false",
|
|
1217
|
+
"aria-controls": `${prefix}-panel`,
|
|
1218
|
+
tabindex: "-1",
|
|
1219
|
+
onclick: () => show(tab.id, true),
|
|
1220
|
+
onkeydown: (event) => {
|
|
1221
|
+
const keys = {
|
|
1222
|
+
ArrowRight: () => move(index, 1),
|
|
1223
|
+
ArrowLeft: () => move(index, -1),
|
|
1224
|
+
Home: () => move(0, 0),
|
|
1225
|
+
End: () => move(tabs.length - 1, 0),
|
|
1226
|
+
};
|
|
1227
|
+
const act = keys[event.key];
|
|
1228
|
+
|
|
1229
|
+
if (!act) return;
|
|
1230
|
+
event.preventDefault?.();
|
|
1231
|
+
act();
|
|
1232
|
+
},
|
|
1233
|
+
},
|
|
1234
|
+
[
|
|
1235
|
+
tab.label,
|
|
1236
|
+
typeof tab.count === "number"
|
|
1237
|
+
? el("span", { class: "grimoire-tab-count", text: String(tab.count) })
|
|
1238
|
+
: "",
|
|
1239
|
+
],
|
|
1240
|
+
);
|
|
1241
|
+
|
|
1242
|
+
buttons.set(tab.id, button);
|
|
1243
|
+
strip.append(button);
|
|
1244
|
+
});
|
|
1245
|
+
|
|
1246
|
+
panel.setAttribute("id", `${prefix}-panel`);
|
|
1247
|
+
show(active, false);
|
|
1248
|
+
|
|
1249
|
+
return el("div", { class: "grimoire-tabbed" }, [strip, panel]);
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1252
|
+
/**
|
|
1253
|
+
* A group that is closed until opened. `make()` builds the body on the first
|
|
1254
|
+
* open, so a closed group costs one row.
|
|
1255
|
+
*/
|
|
1256
|
+
function group(ctx, { title, count, tone = "", lead = [], make, open = false, className = "" }) {
|
|
1257
|
+
const { el } = ctx;
|
|
1258
|
+
const body = el("div", { class: "grimoire-group-body" });
|
|
1259
|
+
let built = false;
|
|
1260
|
+
let isOpen = false;
|
|
1261
|
+
const button = el(
|
|
1262
|
+
"button",
|
|
1263
|
+
{
|
|
1264
|
+
type: "button",
|
|
1265
|
+
class: "grimoire-group-head",
|
|
1266
|
+
"aria-expanded": "false",
|
|
1267
|
+
onclick: () => toggle(!isOpen),
|
|
1268
|
+
},
|
|
1269
|
+
[
|
|
1270
|
+
el("span", { class: "grimoire-group-caret", "aria-hidden": "true", text: "▸" }),
|
|
1271
|
+
...lead,
|
|
1272
|
+
el("span", { class: "grimoire-group-title", text: title }),
|
|
1273
|
+
typeof count === "number"
|
|
1274
|
+
? el("span", { class: "grimoire-tab-count", text: String(count) })
|
|
1275
|
+
: "",
|
|
1276
|
+
],
|
|
849
1277
|
);
|
|
850
1278
|
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
fileLink(ctx, item.file),
|
|
868
|
-
]),
|
|
869
|
-
)
|
|
870
|
-
: muted(ctx, "none"),
|
|
871
|
-
el("h4", { text: "Pages and screens" }),
|
|
872
|
-
Object.keys(map.pages).length
|
|
873
|
-
? list(
|
|
874
|
-
ctx,
|
|
875
|
-
Object.entries(map.pages).flatMap(([app, pages]) =>
|
|
876
|
-
pages.map((item) => [
|
|
877
|
-
link(
|
|
878
|
-
ctx,
|
|
879
|
-
`${app} ${item.route}`,
|
|
880
|
-
`page/${encodeURIComponent(app)}/${encodeURIComponent(item.route)}`,
|
|
881
|
-
),
|
|
882
|
-
]),
|
|
883
|
-
),
|
|
884
|
-
)
|
|
885
|
-
: muted(ctx, "none"),
|
|
886
|
-
el("h4", { text: "Own files" }),
|
|
887
|
-
fileChips(ctx, map.own, 12),
|
|
888
|
-
el("h4", { text: "Files no flow reaches" }),
|
|
889
|
-
fileChips(ctx, map.unreached, 12),
|
|
890
|
-
]),
|
|
1279
|
+
function toggle(next) {
|
|
1280
|
+
isOpen = next;
|
|
1281
|
+
|
|
1282
|
+
if (isOpen && !built) {
|
|
1283
|
+
built = true;
|
|
1284
|
+
body.append(make());
|
|
1285
|
+
}
|
|
1286
|
+
|
|
1287
|
+
button.setAttribute("aria-expanded", String(isOpen));
|
|
1288
|
+
body.setAttribute("class", isOpen ? "grimoire-group-body is-open" : "grimoire-group-body");
|
|
1289
|
+
}
|
|
1290
|
+
|
|
1291
|
+
const node = el(
|
|
1292
|
+
"div",
|
|
1293
|
+
{ class: `grimoire-group ${tone ? `is-${tone}` : ""} ${className}`.trim() },
|
|
1294
|
+
[button, body],
|
|
891
1295
|
);
|
|
892
1296
|
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
1297
|
+
node.toggle = toggle;
|
|
1298
|
+
if (open) toggle(true);
|
|
1299
|
+
|
|
1300
|
+
return node;
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1303
|
+
/** A long list shown a slice at a time: `make(item)` builds one row; "Show more" adds the next slice. */
|
|
1304
|
+
function slicedList(ctx, items, make, options = {}) {
|
|
1305
|
+
const { el } = ctx;
|
|
1306
|
+
const size = options.size ?? 30;
|
|
1307
|
+
const tag = options.tag ?? "ul";
|
|
1308
|
+
const list = el(tag, { class: options.className ?? "grimoire-list" });
|
|
1309
|
+
const more = el("button", { type: "button", class: "grimoire-more" });
|
|
1310
|
+
const holder = el("div", {}, [list, more]);
|
|
1311
|
+
let shown = 0;
|
|
1312
|
+
|
|
1313
|
+
function paint() {
|
|
1314
|
+
const next = items.slice(shown, shown + size);
|
|
1315
|
+
|
|
1316
|
+
for (const item of next) list.append(make(item));
|
|
1317
|
+
shown += next.length;
|
|
1318
|
+
more.textContent = `Show ${Math.min(size, items.length - shown)} more (${items.length - shown} left)`;
|
|
1319
|
+
more.setAttribute("class", shown >= items.length ? "grimoire-more is-hidden" : "grimoire-more");
|
|
1320
|
+
more.setAttribute("aria-hidden", String(shown >= items.length));
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
more.addEventListener("click", paint);
|
|
1324
|
+
paint();
|
|
1325
|
+
return holder;
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1328
|
+
/** What a feature-map chip leads to: the written page, the route, or the entry file. */
|
|
1329
|
+
function mapChipTarget(chip) {
|
|
1330
|
+
if (chip.type === "page" && chip.app && chip.page) {
|
|
1331
|
+
return `page/${encodeURIComponent(chip.app)}/${encodeURIComponent(chip.page)}`;
|
|
1332
|
+
}
|
|
1333
|
+
if (chip.type === "route" && chip.method && chip.path) {
|
|
1334
|
+
return `route/${encodeURIComponent(chip.method)}/${encodeURIComponent(chip.path)}`;
|
|
1335
|
+
}
|
|
1336
|
+
return chip.file ? `file/${encodeURIComponent(chip.file)}` : null;
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1339
|
+
/** One chip of the feature map: a glyph and the name; a dashed look when the step matched nothing. */
|
|
1340
|
+
function mapChip(ctx, chip) {
|
|
1341
|
+
const target = mapChipTarget(chip);
|
|
1342
|
+
const missing = chip.found === false;
|
|
1343
|
+
const attrs = {
|
|
1344
|
+
class: `grimoire-mapchip is-${chip.type.replace(/\s+/g, "-")}${missing ? " is-missing" : ""}`,
|
|
1345
|
+
title: `${chip.type}, step ${chip.step}${missing ? ", not found in the book" : ""}: ${chip.label}`,
|
|
1346
|
+
};
|
|
1347
|
+
const inner = [
|
|
1348
|
+
stepIcon(ctx, chip.type, 14),
|
|
1349
|
+
ctx.el("span", { class: "grimoire-mapchip-label", text: chip.label }),
|
|
1350
|
+
];
|
|
1351
|
+
|
|
1352
|
+
return target
|
|
1353
|
+
? ctx.el("a", { ...attrs, href: ctx.href(target) }, inner)
|
|
1354
|
+
: ctx.el("span", attrs, inner);
|
|
1355
|
+
}
|
|
1356
|
+
|
|
1357
|
+
/** The feature map: flows as rows, the places they run as columns. */
|
|
1358
|
+
function featureMapView(ctx, feature, map) {
|
|
1359
|
+
const { el } = ctx;
|
|
1360
|
+
|
|
1361
|
+
if (!map)
|
|
1362
|
+
return ctx.empty("This answer has no feature map. Update the Grimoire package and reload.");
|
|
1363
|
+
if (!map.rows.length) return ctx.empty("This feature has no flows yet.");
|
|
1364
|
+
if (!map.columns.length) {
|
|
1365
|
+
return ctx.empty(
|
|
1366
|
+
"No step of any flow resolves to a page, screen, route or background job yet.",
|
|
905
1367
|
);
|
|
906
1368
|
}
|
|
907
1369
|
|
|
908
|
-
|
|
1370
|
+
return el("div", { class: "grimoire-scroll grimoire-featuremap" }, [
|
|
1371
|
+
el("table", { class: "grimoire-table grimoire-mapgrid" }, [
|
|
1372
|
+
el("caption", { class: "grimoire-sr", text: "Flows and the places they run" }),
|
|
1373
|
+
el("thead", {}, [
|
|
1374
|
+
el("tr", {}, [
|
|
1375
|
+
el("th", { scope: "col", text: "Flow" }),
|
|
1376
|
+
...map.columns.map((column) =>
|
|
1377
|
+
el("th", { scope: "col", class: `is-${column.type}` }, [
|
|
1378
|
+
el("span", {
|
|
1379
|
+
class: "grimoire-maptype",
|
|
1380
|
+
text:
|
|
1381
|
+
column.type === "site" ? "site" : column.type === "mobile" ? "mobile app" : "",
|
|
1382
|
+
}),
|
|
1383
|
+
el("span", { text: column.title }),
|
|
1384
|
+
]),
|
|
1385
|
+
),
|
|
1386
|
+
]),
|
|
1387
|
+
]),
|
|
1388
|
+
el(
|
|
1389
|
+
"tbody",
|
|
1390
|
+
{},
|
|
1391
|
+
map.rows.map((row) =>
|
|
1392
|
+
el("tr", {}, [
|
|
1393
|
+
el("th", { scope: "row", class: "grimoire-maprow" }, [
|
|
1394
|
+
link(
|
|
1395
|
+
ctx,
|
|
1396
|
+
row.heading ?? row.flow,
|
|
1397
|
+
`flow/${encodeURIComponent(feature)}/${encodeURIComponent(row.flow)}`,
|
|
1398
|
+
),
|
|
1399
|
+
row.heading
|
|
1400
|
+
? el("span", { class: "grimoire-mono grimoire-muted", text: row.flow })
|
|
1401
|
+
: "",
|
|
1402
|
+
]),
|
|
1403
|
+
...map.columns.map((column) => {
|
|
1404
|
+
const chips = row.cells[column.id] ?? [];
|
|
1405
|
+
|
|
1406
|
+
return el(
|
|
1407
|
+
"td",
|
|
1408
|
+
{ "data-label": column.title, class: chips.length ? "" : "is-empty" },
|
|
1409
|
+
chips.length
|
|
1410
|
+
? el(
|
|
1411
|
+
"div",
|
|
1412
|
+
{ class: "grimoire-mapcell" },
|
|
1413
|
+
chips.map((chip) => mapChip(ctx, chip)),
|
|
1414
|
+
)
|
|
1415
|
+
: el("span", { class: "grimoire-muted", "aria-label": "none", text: "–" }),
|
|
1416
|
+
);
|
|
1417
|
+
}),
|
|
1418
|
+
]),
|
|
1419
|
+
),
|
|
1420
|
+
),
|
|
1421
|
+
]),
|
|
1422
|
+
]);
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1425
|
+
/** The criteria of a feature, counted from its proofs. */
|
|
1426
|
+
function featureCriteria(data) {
|
|
1427
|
+
const byStatus = {};
|
|
1428
|
+
let total = 0;
|
|
1429
|
+
|
|
1430
|
+
for (const item of data.proofs ?? []) {
|
|
1431
|
+
for (const criterion of item.criteria) {
|
|
1432
|
+
total += 1;
|
|
1433
|
+
byStatus[criterion.status] = (byStatus[criterion.status] ?? 0) + 1;
|
|
1434
|
+
}
|
|
1435
|
+
}
|
|
1436
|
+
|
|
1437
|
+
return {
|
|
1438
|
+
total,
|
|
1439
|
+
proven: byStatus.pass ?? 0,
|
|
1440
|
+
failing: byStatus.fail ?? 0,
|
|
1441
|
+
noTest: byStatus["no-test"] ?? 0,
|
|
1442
|
+
};
|
|
1443
|
+
}
|
|
1444
|
+
|
|
1445
|
+
/** The feature's health tiles. */
|
|
1446
|
+
function featureHealthStrip(ctx, id, data, unexpected) {
|
|
1447
|
+
const criteria = featureCriteria(data);
|
|
1448
|
+
const flows = data.flows;
|
|
1449
|
+
const shipped = flows.filter((flow) => flow.status === "shipped").length;
|
|
1450
|
+
const errors = unexpected.filter((finding) => finding.severity === "error").length;
|
|
1451
|
+
|
|
1452
|
+
return ctx.el("div", { class: "grimoire-stats grimoire-health" }, [
|
|
1453
|
+
tile(ctx, { label: "Flows", value: flows.length, sub: `${shipped} shipped` }),
|
|
1454
|
+
tile(ctx, {
|
|
1455
|
+
label: "Criteria proven",
|
|
1456
|
+
value: `${criteria.proven}/${criteria.total}`,
|
|
1457
|
+
sub: criteria.failing
|
|
1458
|
+
? `${plural(criteria.failing, "criterion")} failing`
|
|
1459
|
+
: criteria.noTest
|
|
1460
|
+
? `${criteria.noTest} without a test`
|
|
1461
|
+
: criteria.total
|
|
1462
|
+
? "by passing tests"
|
|
1463
|
+
: "none written",
|
|
1464
|
+
tone: criteria.failing
|
|
1465
|
+
? "bad"
|
|
1466
|
+
: criteria.total && criteria.proven === criteria.total
|
|
1467
|
+
? "good"
|
|
1468
|
+
: criteria.total
|
|
1469
|
+
? "warn"
|
|
1470
|
+
: "",
|
|
1471
|
+
}),
|
|
1472
|
+
stat(ctx, {
|
|
1473
|
+
label: "Findings",
|
|
1474
|
+
value: unexpected.length,
|
|
1475
|
+
sub: `${plural(errors, "error")}, ${plural(unexpected.length - errors, "warning")}`,
|
|
1476
|
+
target: checkTarget({ feature: id }),
|
|
1477
|
+
tone: errors ? "bad" : unexpected.length ? "warn" : "good",
|
|
1478
|
+
}),
|
|
1479
|
+
tile(ctx, {
|
|
1480
|
+
label: "Own files",
|
|
1481
|
+
value: data.bookmap.own.length,
|
|
1482
|
+
sub: `${data.bookmap.unreached.length} not reached by a flow`,
|
|
1483
|
+
}),
|
|
1484
|
+
]);
|
|
1485
|
+
}
|
|
1486
|
+
|
|
1487
|
+
/** Findings grouped by code, each group closed; the check's titles come with the first open. */
|
|
1488
|
+
function findingGroups(ctx, findings, options = {}) {
|
|
1489
|
+
const { el } = ctx;
|
|
1490
|
+
|
|
1491
|
+
if (!findings.length) {
|
|
1492
|
+
return el("p", {}, [pill(ctx, "clean", "good"), " No findings."]);
|
|
1493
|
+
}
|
|
1494
|
+
|
|
1495
|
+
const byCode = new Map();
|
|
1496
|
+
|
|
1497
|
+
for (const finding of findings)
|
|
1498
|
+
byCode.set(finding.code, [...(byCode.get(finding.code) ?? []), finding]);
|
|
1499
|
+
|
|
1500
|
+
const titles = ctx.api("check/groups").then(
|
|
1501
|
+
(answer) => new Map((answer.groups ?? []).map((item) => [item.code, item.title])),
|
|
1502
|
+
() => new Map(),
|
|
1503
|
+
);
|
|
1504
|
+
const groups = [...byCode.entries()]
|
|
1505
|
+
.map(([code, items]) => ({
|
|
1506
|
+
code,
|
|
1507
|
+
items,
|
|
1508
|
+
severity: items.some((item) => item.severity === "error") ? "error" : "warning",
|
|
1509
|
+
}))
|
|
1510
|
+
.sort(
|
|
1511
|
+
(left, right) =>
|
|
1512
|
+
(left.severity === "error" ? 0 : 1) - (right.severity === "error" ? 0 : 1) ||
|
|
1513
|
+
right.items.length - left.items.length ||
|
|
1514
|
+
left.code.localeCompare(right.code),
|
|
1515
|
+
);
|
|
1516
|
+
|
|
1517
|
+
return el(
|
|
1518
|
+
"div",
|
|
1519
|
+
{ class: "grimoire-groups" },
|
|
1520
|
+
groups.map((item) => {
|
|
1521
|
+
const title = el("span", { class: "grimoire-muted grimoire-group-note" });
|
|
1522
|
+
|
|
1523
|
+
titles.then((known) => {
|
|
1524
|
+
const text = known.get(item.code);
|
|
1525
|
+
|
|
1526
|
+
if (text) title.textContent = text;
|
|
1527
|
+
});
|
|
1528
|
+
|
|
1529
|
+
return group(ctx, {
|
|
1530
|
+
title: item.code,
|
|
1531
|
+
count: item.items.length,
|
|
1532
|
+
tone: toneOf(item.severity),
|
|
1533
|
+
lead: [pill(ctx, item.severity, toneOf(item.severity))],
|
|
1534
|
+
make: () =>
|
|
1535
|
+
el("div", {}, [
|
|
1536
|
+
title,
|
|
1537
|
+
slicedList(ctx, item.items, (finding) => findingItem(ctx, finding, options), {
|
|
1538
|
+
className: "grimoire-findings",
|
|
1539
|
+
size: 25,
|
|
1540
|
+
}),
|
|
1541
|
+
]),
|
|
1542
|
+
});
|
|
1543
|
+
}),
|
|
1544
|
+
);
|
|
1545
|
+
}
|
|
1546
|
+
|
|
1547
|
+
/** Files grouped by module with a filter box; each group is closed and built when opened. */
|
|
1548
|
+
function fileGroupsView(ctx, groups, extras) {
|
|
1549
|
+
const { el } = ctx;
|
|
1550
|
+
const holder = el("div", { class: "grimoire-groups" });
|
|
1551
|
+
const status = el("p", { class: "grimoire-muted", role: "status", "aria-live": "polite" });
|
|
1552
|
+
const input = el("input", {
|
|
1553
|
+
type: "search",
|
|
1554
|
+
class: "grimoire-filterbox",
|
|
1555
|
+
placeholder: "Filter files and modules",
|
|
1556
|
+
"aria-label": "Filter files",
|
|
1557
|
+
oninput: (event) => paint(String(event.target.value ?? "")),
|
|
1558
|
+
});
|
|
1559
|
+
|
|
1560
|
+
function paint(text) {
|
|
1561
|
+
const needle = text.trim().toLowerCase();
|
|
1562
|
+
let files = 0;
|
|
1563
|
+
let shown = 0;
|
|
1564
|
+
const nodes = [];
|
|
1565
|
+
|
|
1566
|
+
for (const item of groups) {
|
|
1567
|
+
const matches = needle
|
|
1568
|
+
? item.module.toLowerCase().includes(needle)
|
|
1569
|
+
? item.files
|
|
1570
|
+
: item.files.filter((file) => file.toLowerCase().includes(needle))
|
|
1571
|
+
: item.files;
|
|
1572
|
+
|
|
1573
|
+
files += item.files.length;
|
|
1574
|
+
if (!matches.length) continue;
|
|
1575
|
+
|
|
1576
|
+
shown += matches.length;
|
|
1577
|
+
nodes.push(
|
|
1578
|
+
group(ctx, {
|
|
1579
|
+
title: item.module || "(no module)",
|
|
1580
|
+
count: matches.length,
|
|
1581
|
+
open: needle !== "" && matches.length <= 40,
|
|
1582
|
+
make: () =>
|
|
1583
|
+
el(
|
|
1584
|
+
"div",
|
|
1585
|
+
{ class: "grimoire-chips" },
|
|
1586
|
+
matches.map((file) => fileLink(ctx, file)),
|
|
1587
|
+
),
|
|
1588
|
+
}),
|
|
1589
|
+
);
|
|
1590
|
+
}
|
|
1591
|
+
|
|
1592
|
+
status.textContent = needle
|
|
1593
|
+
? `${shown} of ${files} files match`
|
|
1594
|
+
: `${plural(files, "file")} in ${plural(groups.length, "module")}`;
|
|
1595
|
+
holder.replaceChildren(...(needle ? [] : extras), ...nodes);
|
|
1596
|
+
}
|
|
1597
|
+
|
|
1598
|
+
paint("");
|
|
1599
|
+
return el("div", {}, [el("div", { class: "grimoire-toolbar" }, [input, status]), holder]);
|
|
1600
|
+
}
|
|
1601
|
+
|
|
1602
|
+
/** The extra groups of the Files tab: routes, pages and screens, borrowed files, files no flow reaches. */
|
|
1603
|
+
function featureCodeGroups(ctx, map) {
|
|
1604
|
+
const { el } = ctx;
|
|
1605
|
+
const pages = Object.entries(map.pages).flatMap(([app, items]) =>
|
|
1606
|
+
items.map((item) => ({ app, ...item })),
|
|
1607
|
+
);
|
|
1608
|
+
|
|
1609
|
+
return [
|
|
1610
|
+
map.routes.length
|
|
1611
|
+
? group(ctx, {
|
|
1612
|
+
title: "Routes",
|
|
1613
|
+
count: map.routes.length,
|
|
1614
|
+
make: () =>
|
|
1615
|
+
slicedList(ctx, map.routes, (item) =>
|
|
1616
|
+
el("li", {}, [
|
|
1617
|
+
routeLink(ctx, item.method, item.path),
|
|
1618
|
+
" in ",
|
|
1619
|
+
fileLink(ctx, item.file),
|
|
1620
|
+
]),
|
|
1621
|
+
),
|
|
1622
|
+
})
|
|
1623
|
+
: "",
|
|
1624
|
+
pages.length
|
|
1625
|
+
? group(ctx, {
|
|
1626
|
+
title: "Pages and screens",
|
|
1627
|
+
count: pages.length,
|
|
1628
|
+
make: () =>
|
|
1629
|
+
slicedList(ctx, pages, (item) =>
|
|
1630
|
+
el("li", {}, [
|
|
1631
|
+
link(
|
|
1632
|
+
ctx,
|
|
1633
|
+
`${item.app} ${item.route}`,
|
|
1634
|
+
`page/${encodeURIComponent(item.app)}/${encodeURIComponent(item.route)}`,
|
|
1635
|
+
),
|
|
1636
|
+
]),
|
|
1637
|
+
),
|
|
1638
|
+
})
|
|
1639
|
+
: "",
|
|
1640
|
+
map.borrowed.length
|
|
1641
|
+
? group(ctx, {
|
|
1642
|
+
title: "Borrowed from other features",
|
|
1643
|
+
count: map.borrowed.length,
|
|
1644
|
+
make: () =>
|
|
1645
|
+
el(
|
|
1646
|
+
"div",
|
|
1647
|
+
{ class: "grimoire-chips" },
|
|
1648
|
+
map.borrowed.map((item) => fileLink(ctx, item.file)),
|
|
1649
|
+
),
|
|
1650
|
+
})
|
|
1651
|
+
: "",
|
|
1652
|
+
map.unreached.length
|
|
1653
|
+
? group(ctx, {
|
|
1654
|
+
title: "Not reached by a flow",
|
|
1655
|
+
count: map.unreached.length,
|
|
1656
|
+
tone: "warn",
|
|
1657
|
+
make: () =>
|
|
1658
|
+
el(
|
|
1659
|
+
"div",
|
|
1660
|
+
{ class: "grimoire-chips" },
|
|
1661
|
+
map.unreached.map((file) => fileLink(ctx, file)),
|
|
1662
|
+
),
|
|
1663
|
+
})
|
|
1664
|
+
: "",
|
|
1665
|
+
];
|
|
1666
|
+
}
|
|
1667
|
+
|
|
1668
|
+
/** The criteria of each flow with the tests behind them. */
|
|
1669
|
+
function testsView(ctx, feature, proofs) {
|
|
1670
|
+
const { el } = ctx;
|
|
1671
|
+
const filled = proofs.filter((item) => item.criteria.length);
|
|
1672
|
+
|
|
1673
|
+
if (!filled.length) return ctx.empty("No flow of this feature has acceptance criteria yet.");
|
|
1674
|
+
|
|
1675
|
+
return el(
|
|
1676
|
+
"div",
|
|
1677
|
+
{ class: "grimoire-groups" },
|
|
1678
|
+
filled.map((item) => {
|
|
1679
|
+
const proven = item.criteria.filter((criterion) => criterion.status === "pass").length;
|
|
1680
|
+
const failing = item.criteria.some((criterion) => criterion.status === "fail");
|
|
1681
|
+
|
|
1682
|
+
return group(ctx, {
|
|
1683
|
+
title: item.heading ?? item.flow,
|
|
1684
|
+
count: item.criteria.length,
|
|
1685
|
+
tone: failing ? "bad" : proven === item.criteria.length ? "good" : "warn",
|
|
1686
|
+
lead: [muted(ctx, `${proven}/${item.criteria.length} proven`)],
|
|
1687
|
+
make: () =>
|
|
1688
|
+
el("div", {}, [
|
|
1689
|
+
el("p", {}, [
|
|
1690
|
+
link(
|
|
1691
|
+
ctx,
|
|
1692
|
+
"Open the flow",
|
|
1693
|
+
`flow/${encodeURIComponent(feature)}/${encodeURIComponent(item.flow)}/proof`,
|
|
1694
|
+
),
|
|
1695
|
+
]),
|
|
1696
|
+
el(
|
|
1697
|
+
"ul",
|
|
1698
|
+
{ class: "grimoire-proofs" },
|
|
1699
|
+
item.criteria.map((criterion) => proofRow(ctx, criterion, false)),
|
|
1700
|
+
),
|
|
1701
|
+
]),
|
|
1702
|
+
});
|
|
1703
|
+
}),
|
|
1704
|
+
);
|
|
1705
|
+
}
|
|
1706
|
+
|
|
1707
|
+
/** The Flows tab: one row per flow with its counts. */
|
|
1708
|
+
function flowsTable(ctx, feature, flows) {
|
|
1709
|
+
if (!flows.length) return ctx.empty("This feature has no flows yet.");
|
|
1710
|
+
|
|
1711
|
+
return table(
|
|
1712
|
+
ctx,
|
|
1713
|
+
["Flow", "Status", "Steps", "Cases", "Criteria tested", "Findings"],
|
|
1714
|
+
flows.map((flow) => [
|
|
1715
|
+
[
|
|
1716
|
+
link(
|
|
1717
|
+
ctx,
|
|
1718
|
+
flow.heading ?? flow.id,
|
|
1719
|
+
`flow/${encodeURIComponent(feature)}/${encodeURIComponent(flow.id)}`,
|
|
1720
|
+
),
|
|
1721
|
+
flow.heading ? [" ", mono(ctx, flow.id)] : "",
|
|
1722
|
+
],
|
|
1723
|
+
[pill(ctx, flow.status, toneOf(flow.status))],
|
|
1724
|
+
[String(flow.steps)],
|
|
1725
|
+
[String(flow.cases)],
|
|
1726
|
+
[`${flow.tested}/${flow.criteria}`],
|
|
1727
|
+
[flow.findings ? pill(ctx, String(flow.findings), "warn") : muted(ctx, "0")],
|
|
1728
|
+
]),
|
|
1729
|
+
);
|
|
1730
|
+
}
|
|
1731
|
+
|
|
1732
|
+
async function featureView(ctx, id, tab = "") {
|
|
1733
|
+
const [data, graph] = await Promise.all([
|
|
1734
|
+
ctx.api(`features/${encodeURIComponent(id)}`),
|
|
1735
|
+
ctx.api(`graph/feature/${encodeURIComponent(id)}`).catch(() => null),
|
|
1736
|
+
]);
|
|
1737
|
+
const { el } = ctx;
|
|
1738
|
+
const readme = data.readme;
|
|
1739
|
+
const status = plain(readme.status);
|
|
1740
|
+
const featureId = String(plain(readme.id));
|
|
1741
|
+
const unexpected = data.findings.filter((finding) => !finding.expected);
|
|
1742
|
+
const criteria = featureCriteria(data);
|
|
1743
|
+
const base = `feature/${encodeURIComponent(id)}`;
|
|
1744
|
+
const map = data.bookmap;
|
|
1745
|
+
const out = el("div", { class: "grimoire-view" }, [
|
|
1746
|
+
crumbs(ctx, [["Features", "features"], [featureId]]),
|
|
1747
|
+
heading(ctx, plain(readme.title), [
|
|
1748
|
+
mono(ctx, featureId),
|
|
1749
|
+
pill(ctx, status, toneOf(status)),
|
|
1750
|
+
pill(ctx, `version ${plain(readme.version)}`),
|
|
1751
|
+
readme.origin ? pill(ctx, plain(readme.origin), toneOf(plain(readme.origin))) : "",
|
|
1752
|
+
muted(ctx, `updated ${plain(readme.updated)}`),
|
|
1753
|
+
]),
|
|
1754
|
+
]);
|
|
1755
|
+
|
|
1756
|
+
const overview = () => {
|
|
1757
|
+
const box = el("div", { class: "grimoire-tabstack" });
|
|
1758
|
+
|
|
1759
|
+
if (readme.summary) box.append(el("p", { class: "grimoire-lede", text: readme.summary }));
|
|
1760
|
+
|
|
1761
|
+
box.append(featureHealthStrip(ctx, featureId, data, unexpected));
|
|
1762
|
+
box.append(section(ctx, "Feature map", [featureMapView(ctx, featureId, data.map)]));
|
|
1763
|
+
box.append(
|
|
1764
|
+
section(ctx, "Flows", [
|
|
1765
|
+
data.flows.length
|
|
1766
|
+
? el(
|
|
1767
|
+
"ul",
|
|
1768
|
+
{ class: "grimoire-flowcards" },
|
|
1769
|
+
data.flows.map((flow) => grimoireFlowCard(ctx, featureId, flow)),
|
|
1770
|
+
)
|
|
1771
|
+
: ctx.empty("This feature has no flows yet."),
|
|
1772
|
+
]),
|
|
1773
|
+
);
|
|
1774
|
+
|
|
1775
|
+
if (graph) box.append(graphView(ctx, graph, "The feature and its neighbours"));
|
|
1776
|
+
|
|
1777
|
+
if (data.tasks.length) {
|
|
1778
|
+
box.append(
|
|
1779
|
+
section(ctx, "Open tasks", [
|
|
1780
|
+
list(
|
|
1781
|
+
ctx,
|
|
1782
|
+
data.tasks.map((task) => [
|
|
1783
|
+
link(ctx, task.id, `task/${encodeURIComponent(task.id)}`, {
|
|
1784
|
+
class: "grimoire-nowrap",
|
|
1785
|
+
}),
|
|
1786
|
+
" ",
|
|
1787
|
+
codeText(ctx, task.title),
|
|
1788
|
+
" ",
|
|
1789
|
+
pill(ctx, task.status, toneOf(task.status)),
|
|
1790
|
+
]),
|
|
1791
|
+
),
|
|
1792
|
+
]),
|
|
1793
|
+
);
|
|
1794
|
+
}
|
|
1795
|
+
|
|
1796
|
+
box.append(section(ctx, "Recent changes", [changesView(ctx, data.changes)]));
|
|
1797
|
+
return box;
|
|
1798
|
+
};
|
|
1799
|
+
|
|
1800
|
+
out.append(
|
|
1801
|
+
tabbed(ctx, {
|
|
1802
|
+
label: "This feature",
|
|
1803
|
+
prefix: "grimoire-feature",
|
|
1804
|
+
active: tab,
|
|
1805
|
+
route: (key) => (key === "overview" ? base : `${base}/${key}`),
|
|
1806
|
+
tabs: [
|
|
1807
|
+
{ id: "overview", label: "Overview", make: overview },
|
|
1808
|
+
{
|
|
1809
|
+
id: "flows",
|
|
1810
|
+
label: "Flows",
|
|
1811
|
+
count: data.flows.length,
|
|
1812
|
+
make: () => section(ctx, "Flows", [flowsTable(ctx, featureId, data.flows)]),
|
|
1813
|
+
},
|
|
1814
|
+
{
|
|
1815
|
+
id: "files",
|
|
1816
|
+
label: "Files",
|
|
1817
|
+
count: map.own.length,
|
|
1818
|
+
make: () =>
|
|
1819
|
+
section(ctx, "Files", [
|
|
1820
|
+
fileGroupsView(
|
|
1821
|
+
ctx,
|
|
1822
|
+
data.fileGroups ?? [{ module: "", files: map.own }],
|
|
1823
|
+
featureCodeGroups(ctx, map),
|
|
1824
|
+
),
|
|
1825
|
+
]),
|
|
1826
|
+
},
|
|
1827
|
+
{
|
|
1828
|
+
id: "findings",
|
|
1829
|
+
label: "Findings",
|
|
1830
|
+
count: unexpected.length,
|
|
1831
|
+
make: () => section(ctx, "Findings", [findingGroups(ctx, data.findings)]),
|
|
1832
|
+
},
|
|
1833
|
+
{
|
|
1834
|
+
id: "tests",
|
|
1835
|
+
label: "Tests",
|
|
1836
|
+
count: criteria.total,
|
|
1837
|
+
make: () => section(ctx, "Tests", [testsView(ctx, featureId, data.proofs ?? [])]),
|
|
1838
|
+
},
|
|
1839
|
+
],
|
|
1840
|
+
}),
|
|
1841
|
+
);
|
|
1842
|
+
|
|
1843
|
+
return out;
|
|
1844
|
+
}
|
|
1845
|
+
|
|
1846
|
+
const STEP_FILE_SETS = [
|
|
1847
|
+
["direct", "Direct imports", "direct"],
|
|
1848
|
+
["feature", "In this feature", "feature"],
|
|
1849
|
+
["reachable", "All reachable", "reachable"],
|
|
1850
|
+
["type-only", "Type-only", "typeOnly"],
|
|
1851
|
+
];
|
|
1852
|
+
|
|
1853
|
+
/** The files behind one step, loaded a page at a time from the step files route. */
|
|
1854
|
+
function stepFilesPanel(ctx, feature, flowId, step) {
|
|
1855
|
+
const { el } = ctx;
|
|
1856
|
+
const counts = step.counts ?? { direct: 0, feature: 0, reachable: 0, typeOnly: 0 };
|
|
1857
|
+
const sets = STEP_FILE_SETS.filter(([, , key]) => key !== "typeOnly" || counts[key] > 0);
|
|
1858
|
+
const body = el("div", { class: "grimoire-step-files-body" });
|
|
1859
|
+
const tabs = el("div", { class: "grimoire-subtabs", role: "tablist", "aria-label": "File set" });
|
|
1860
|
+
const loaded = new Map();
|
|
1861
|
+
const buttons = [];
|
|
1862
|
+
|
|
1863
|
+
function paint(state) {
|
|
1864
|
+
const groups = new Map();
|
|
1865
|
+
|
|
1866
|
+
for (const item of state.files)
|
|
1867
|
+
groups.set(item.module, [...(groups.get(item.module) ?? []), item]);
|
|
1868
|
+
|
|
1869
|
+
state.box.replaceChildren(
|
|
1870
|
+
...[...groups.entries()].map(([name, items]) =>
|
|
1871
|
+
el("div", { class: "grimoire-module-group" }, [
|
|
1872
|
+
el("h5", { text: `${name || "(no module)"} (${items.length})` }),
|
|
1873
|
+
el(
|
|
1874
|
+
"div",
|
|
1875
|
+
{ class: "grimoire-chips" },
|
|
1876
|
+
items.map((item) => fileLink(ctx, item.file)),
|
|
1877
|
+
),
|
|
1878
|
+
]),
|
|
1879
|
+
),
|
|
1880
|
+
state.files.length || state.error ? "" : muted(ctx, "No files in this set."),
|
|
1881
|
+
state.error
|
|
1882
|
+
? el("p", {
|
|
1883
|
+
class: "grimoire-error-title",
|
|
1884
|
+
text: `Could not load the files: ${state.error}. Try again.`,
|
|
1885
|
+
})
|
|
1886
|
+
: "",
|
|
1887
|
+
state.files.length < state.total || state.error
|
|
1888
|
+
? el("button", {
|
|
1889
|
+
type: "button",
|
|
1890
|
+
class: "grimoire-filter",
|
|
1891
|
+
text: state.error
|
|
1892
|
+
? "Try again"
|
|
1893
|
+
: `Load ${Math.min(STEP_FILES_PAGE, state.total - state.files.length)} more`,
|
|
1894
|
+
onclick: () => fetchPage(state),
|
|
1895
|
+
})
|
|
1896
|
+
: "",
|
|
1897
|
+
);
|
|
1898
|
+
}
|
|
1899
|
+
|
|
1900
|
+
async function fetchPage(state) {
|
|
1901
|
+
if (state.busy) return;
|
|
1902
|
+
state.busy = true;
|
|
1903
|
+
|
|
1904
|
+
try {
|
|
1905
|
+
const answer = await ctx.api(
|
|
1906
|
+
`flows/${encodeURIComponent(feature)}/${encodeURIComponent(flowId)}/steps/${step.index}/files?set=${state.set}&offset=${state.files.length}`,
|
|
1907
|
+
);
|
|
1908
|
+
|
|
1909
|
+
state.files.push(...answer.files);
|
|
1910
|
+
state.total = answer.total;
|
|
1911
|
+
state.error = null;
|
|
1912
|
+
} catch (error) {
|
|
1913
|
+
state.error = error && error.message ? error.message : String(error);
|
|
1914
|
+
}
|
|
1915
|
+
|
|
1916
|
+
state.busy = false;
|
|
1917
|
+
paint(state);
|
|
1918
|
+
}
|
|
1919
|
+
|
|
1920
|
+
function open(set) {
|
|
1921
|
+
let state = loaded.get(set);
|
|
1922
|
+
|
|
1923
|
+
if (!state) {
|
|
1924
|
+
state = { set, files: [], total: 0, error: null, busy: false, box: el("div", {}) };
|
|
1925
|
+
state.box.append(muted(ctx, "Loading files…"));
|
|
1926
|
+
loaded.set(set, state);
|
|
1927
|
+
fetchPage(state);
|
|
1928
|
+
}
|
|
1929
|
+
|
|
1930
|
+
for (const [button, key] of buttons) {
|
|
1931
|
+
button.setAttribute("aria-selected", String(key === set));
|
|
1932
|
+
button.setAttribute("class", key === set ? "grimoire-subtab is-active" : "grimoire-subtab");
|
|
1933
|
+
}
|
|
1934
|
+
|
|
1935
|
+
body.replaceChildren(state.box);
|
|
1936
|
+
}
|
|
1937
|
+
|
|
1938
|
+
for (const [key, label, countKey] of sets) {
|
|
1939
|
+
const button = el("button", {
|
|
1940
|
+
type: "button",
|
|
1941
|
+
role: "tab",
|
|
1942
|
+
class: "grimoire-subtab",
|
|
1943
|
+
"aria-selected": "false",
|
|
1944
|
+
text: `${label} ${counts[countKey]}`,
|
|
1945
|
+
onclick: () => open(key),
|
|
1946
|
+
});
|
|
1947
|
+
|
|
1948
|
+
buttons.push([button, key]);
|
|
1949
|
+
tabs.append(button);
|
|
1950
|
+
}
|
|
1951
|
+
|
|
1952
|
+
open("direct");
|
|
1953
|
+
return el("div", { class: "grimoire-step-files" }, [tabs, body]);
|
|
1954
|
+
}
|
|
1955
|
+
|
|
1956
|
+
const STEP_FILES_PAGE = 200;
|
|
1957
|
+
|
|
1958
|
+
/** A number tile that leads nowhere. */
|
|
1959
|
+
function tile(ctx, { label, value, sub, tone = "" }) {
|
|
1960
|
+
return ctx.el("div", { class: tone ? `grimoire-stat is-${tone}` : "grimoire-stat" }, [
|
|
1961
|
+
ctx.el("span", { class: "grimoire-stat-label", text: label }),
|
|
1962
|
+
ctx.el("span", { class: "grimoire-stat-value", text: String(value) }),
|
|
1963
|
+
ctx.el("span", { class: "grimoire-stat-sub", text: sub }),
|
|
1964
|
+
]);
|
|
1965
|
+
}
|
|
1966
|
+
|
|
1967
|
+
/** How many files a step reaches, in words. */
|
|
1968
|
+
function countsLine(counts) {
|
|
1969
|
+
const parts = [
|
|
1970
|
+
`${counts.direct} direct`,
|
|
1971
|
+
`${counts.feature} in feature`,
|
|
1972
|
+
`${counts.reachable} reachable`,
|
|
1973
|
+
];
|
|
1974
|
+
|
|
1975
|
+
if (counts.typeOnly > 0) parts.push(`${counts.typeOnly} type-only`);
|
|
1976
|
+
|
|
1977
|
+
return parts.join(" · ");
|
|
1978
|
+
}
|
|
1979
|
+
|
|
1980
|
+
/** The health numbers; older answers have none, so they are counted from the criteria. */
|
|
1981
|
+
function flowHealth(data) {
|
|
1982
|
+
if (data.health) return data.health;
|
|
1983
|
+
|
|
1984
|
+
const criteria = data.bookmap.criteria;
|
|
1985
|
+
const byStatus = { pass: 0, fail: 0, stale: 0, "not-run": 0, "no-test": 0 };
|
|
1986
|
+
|
|
1987
|
+
for (const item of criteria) byStatus[item.status] = (byStatus[item.status] ?? 0) + 1;
|
|
1988
|
+
|
|
1989
|
+
return {
|
|
1990
|
+
criteria: { total: criteria.length, proven: byStatus.pass, byStatus },
|
|
1991
|
+
steps: {
|
|
1992
|
+
total: data.bookmap.steps.length,
|
|
1993
|
+
resolved: data.bookmap.steps.filter((step) => step.found === true).length,
|
|
1994
|
+
unchecked: data.bookmap.steps.filter((step) => step.found === null).length,
|
|
1995
|
+
},
|
|
1996
|
+
findings: { errors: 0, warnings: 0, expected: 0 },
|
|
1997
|
+
};
|
|
1998
|
+
}
|
|
1999
|
+
|
|
2000
|
+
/** The first criterion to work on: failing, then without a test, then not run or stale. */
|
|
2001
|
+
function fixNextCriterion(criteria) {
|
|
2002
|
+
for (const status of ["fail", "no-test", "not-run", "stale"]) {
|
|
2003
|
+
const found = criteria.find((item) => item.status === status);
|
|
2004
|
+
|
|
2005
|
+
if (found) return found;
|
|
2006
|
+
}
|
|
2007
|
+
|
|
2008
|
+
return null;
|
|
2009
|
+
}
|
|
2010
|
+
|
|
2011
|
+
/** The "Fix next" box. */
|
|
2012
|
+
function fixNextBox(ctx, ref, criterion) {
|
|
2013
|
+
const { el } = ctx;
|
|
2014
|
+
|
|
2015
|
+
if (!criterion) {
|
|
2016
|
+
return el("section", { class: "grimoire-card grimoire-fixnext is-good" }, [
|
|
2017
|
+
el("h3", { text: "Fix next" }),
|
|
2018
|
+
el("p", {}, [pill(ctx, "done", "good"), " Every criterion is proven by a passing test."]),
|
|
2019
|
+
]);
|
|
2020
|
+
}
|
|
2021
|
+
|
|
2022
|
+
const status = criterion.status;
|
|
2023
|
+
const first = criterion.tests[0];
|
|
2024
|
+
const line = `// @proves ${ref} ${criterion.id}`;
|
|
2025
|
+
const lead =
|
|
2026
|
+
status === "fail"
|
|
2027
|
+
? `${criterion.id} fails${first ? ` in ${first.file}:${first.line}` : ""}. Fix the code or the test, then run the tests again.`
|
|
2028
|
+
: status === "no-test"
|
|
2029
|
+
? `${criterion.id} has no test. Put this line directly above the test that proves it.`
|
|
2030
|
+
: status === "stale"
|
|
2031
|
+
? `${criterion.id} has a result older than its test file. Run the tests again.`
|
|
2032
|
+
: `${criterion.id} has a test that has not run. Run the tests with the Grimoire reporter.`;
|
|
2033
|
+
const code = el("code", { class: "grimoire-code grimoire-proof-line", text: line });
|
|
2034
|
+
const note = el("span", { class: "grimoire-muted", role: "status" });
|
|
2035
|
+
const body = [
|
|
2036
|
+
el("p", { class: "grimoire-fixnext-lead" }, [
|
|
2037
|
+
pill(ctx, status, toneOf(status)),
|
|
2038
|
+
" ",
|
|
2039
|
+
codeText(ctx, lead),
|
|
2040
|
+
]),
|
|
2041
|
+
el("p", { class: "grimoire-muted" }, codeText(ctx, criterion.text)),
|
|
2042
|
+
];
|
|
2043
|
+
|
|
2044
|
+
if (status === "no-test") {
|
|
2045
|
+
body.push(
|
|
2046
|
+
el("div", { class: "grimoire-copyline" }, [
|
|
2047
|
+
code,
|
|
2048
|
+
el("button", {
|
|
2049
|
+
type: "button",
|
|
2050
|
+
class: "grimoire-filter",
|
|
2051
|
+
text: "Copy",
|
|
2052
|
+
onclick: () => copyText(line, code, (message) => (note.textContent = message)),
|
|
2053
|
+
}),
|
|
2054
|
+
note,
|
|
2055
|
+
]),
|
|
2056
|
+
);
|
|
2057
|
+
}
|
|
2058
|
+
|
|
2059
|
+
return el("section", { class: "grimoire-card grimoire-fixnext" }, [
|
|
2060
|
+
el("h3", { text: "Fix next" }),
|
|
2061
|
+
...body,
|
|
2062
|
+
]);
|
|
2063
|
+
}
|
|
2064
|
+
|
|
2065
|
+
/** One criterion with one status pill and the tests behind it. */
|
|
2066
|
+
function proofRow(ctx, criterion, untracked) {
|
|
2067
|
+
const { el } = ctx;
|
|
2068
|
+
// Tagged tests with no results file read "tagged", not "not-run".
|
|
2069
|
+
const label = (status) => (untracked && status === "not-run" ? "tagged" : status);
|
|
2070
|
+
const tone = (status) => (untracked && status === "not-run" ? "" : toneOf(status));
|
|
2071
|
+
|
|
2072
|
+
return el("li", { class: "grimoire-proof", id: `grimoire-ac-${criterion.id}` }, [
|
|
2073
|
+
el("div", { class: "grimoire-proof-head" }, [
|
|
2074
|
+
mono(ctx, criterion.id),
|
|
2075
|
+
criterion.app ? pill(ctx, criterion.app) : "",
|
|
2076
|
+
pill(ctx, label(criterion.status), tone(criterion.status)),
|
|
2077
|
+
]),
|
|
2078
|
+
el("p", { class: "grimoire-proof-text" }, codeText(ctx, criterion.text)),
|
|
2079
|
+
criterion.tests.length
|
|
2080
|
+
? el(
|
|
2081
|
+
"ul",
|
|
2082
|
+
{ class: "grimoire-proof-tests" },
|
|
2083
|
+
criterion.tests.map((test) =>
|
|
2084
|
+
el("li", {}, [
|
|
2085
|
+
fileLink(ctx, test.file),
|
|
2086
|
+
mono(ctx, `:${test.line}`),
|
|
2087
|
+
test.name ? el("span", {}, [" ", test.name]) : "",
|
|
2088
|
+
" ",
|
|
2089
|
+
pill(
|
|
2090
|
+
ctx,
|
|
2091
|
+
test.stale ? `${label(test.result)}, stale` : label(test.result),
|
|
2092
|
+
test.stale ? "warn" : tone(test.result),
|
|
2093
|
+
),
|
|
2094
|
+
]),
|
|
2095
|
+
),
|
|
2096
|
+
)
|
|
2097
|
+
: "",
|
|
2098
|
+
]);
|
|
2099
|
+
}
|
|
2100
|
+
|
|
2101
|
+
/** A flow's neighbours in the README order. */
|
|
2102
|
+
function neighbours(ctx, feature, data, className) {
|
|
2103
|
+
const make = (item, arrow) =>
|
|
2104
|
+
item
|
|
2105
|
+
? link(
|
|
2106
|
+
ctx,
|
|
2107
|
+
arrow === "prev" ? `‹ ${item.heading ?? item.id}` : `${item.heading ?? item.id} ›`,
|
|
2108
|
+
`flow/${encodeURIComponent(feature)}/${encodeURIComponent(item.id)}`,
|
|
2109
|
+
{
|
|
2110
|
+
class: `grimoire-neighbour is-${arrow}`,
|
|
2111
|
+
rel: arrow,
|
|
2112
|
+
},
|
|
2113
|
+
)
|
|
2114
|
+
: "";
|
|
2115
|
+
|
|
2116
|
+
if (!data.previous && !data.next) return "";
|
|
2117
|
+
|
|
2118
|
+
return ctx.el("nav", { class: className, "aria-label": "Other flows of this feature" }, [
|
|
2119
|
+
make(data.previous, "prev"),
|
|
2120
|
+
make(data.next, "next"),
|
|
2121
|
+
]);
|
|
2122
|
+
}
|
|
2123
|
+
|
|
2124
|
+
/** The label a journey node shows for a step. */
|
|
2125
|
+
function nodeLabel(step) {
|
|
2126
|
+
const tail = step.target.indexOf(" [");
|
|
2127
|
+
|
|
2128
|
+
return tail > 0 ? step.target.slice(0, tail) : step.target;
|
|
2129
|
+
}
|
|
2130
|
+
|
|
2131
|
+
/** Why a node looks the way it does, in words. */
|
|
2132
|
+
function nodeState(step) {
|
|
2133
|
+
if (step.found === false) return "not found in the book";
|
|
2134
|
+
if (step.found === null) return "not checked by the book";
|
|
2135
|
+
return "found in the book";
|
|
2136
|
+
}
|
|
2137
|
+
|
|
2138
|
+
/** What a selected journey node shows: its note, link, entry file and the files it reaches. */
|
|
2139
|
+
function journeyDetail(ctx, feature, flowId, flow, step) {
|
|
2140
|
+
const { el } = ctx;
|
|
2141
|
+
const written = (flow.steps ?? []).find((item) => item.index === step.index);
|
|
2142
|
+
const note = written && written.note ? written.note : null;
|
|
2143
|
+
const counts = step.counts ?? { direct: 0, feature: 0, reachable: 0, typeOnly: 0 };
|
|
2144
|
+
const shown = expander(ctx, "Show files", () => stepFilesPanel(ctx, feature, flowId, step));
|
|
2145
|
+
const space = step.target.indexOf(" ");
|
|
2146
|
+
|
|
2147
|
+
return el("div", { class: "grimoire-jdetail" }, [
|
|
2148
|
+
el("div", { class: "grimoire-step-head" }, [
|
|
2149
|
+
mono(ctx, `${step.index}`),
|
|
2150
|
+
pill(ctx, step.type),
|
|
2151
|
+
step.type === "route" && space > 0
|
|
2152
|
+
? routeLink(ctx, step.target.slice(0, space), step.target.slice(space + 1))
|
|
2153
|
+
: el("span", { class: "grimoire-step-target", text: step.target }),
|
|
2154
|
+
step.found === false ? pill(ctx, "not found in the book", "bad") : "",
|
|
2155
|
+
]),
|
|
2156
|
+
note ? el("p", { class: "grimoire-muted" }, codeText(ctx, note)) : "",
|
|
2157
|
+
step.linked
|
|
2158
|
+
? el("p", { class: "grimoire-linked" }, [
|
|
2159
|
+
"Affects ",
|
|
2160
|
+
flowLink(ctx, step.linked.ref),
|
|
2161
|
+
step.linked.heading ? ` (${step.linked.heading})` : "",
|
|
2162
|
+
step.linked.summary
|
|
2163
|
+
? el("span", { class: "grimoire-muted" }, [" ", step.linked.summary])
|
|
2164
|
+
: "",
|
|
2165
|
+
])
|
|
2166
|
+
: "",
|
|
2167
|
+
step.entry ? el("p", {}, [muted(ctx, "Starts at "), fileLink(ctx, step.entry)]) : "",
|
|
2168
|
+
counts.reachable || counts.direct
|
|
2169
|
+
? el("div", { class: "grimoire-step-counts" }, [muted(ctx, countsLine(counts)), shown.button])
|
|
2170
|
+
: "",
|
|
2171
|
+
shown.panel,
|
|
2172
|
+
]);
|
|
2173
|
+
}
|
|
2174
|
+
|
|
2175
|
+
/**
|
|
2176
|
+
* The journey: the written steps drawn in order as connected nodes (a row
|
|
2177
|
+
* that wraps; one column on a phone). Each node is a button; the one picked
|
|
2178
|
+
* opens its panel under the drawing.
|
|
2179
|
+
*/
|
|
2180
|
+
function journeyView(ctx, feature, flowId, flow, steps) {
|
|
2181
|
+
const { el } = ctx;
|
|
2182
|
+
|
|
2183
|
+
if (!steps.length) return ctx.empty("This flow has no steps.");
|
|
2184
|
+
|
|
2185
|
+
const detail = el("div", {
|
|
2186
|
+
class: "grimoire-jpanel",
|
|
2187
|
+
id: `grimoire-jpanel-${flowId}`,
|
|
2188
|
+
role: "region",
|
|
2189
|
+
"aria-label": "Step detail",
|
|
2190
|
+
});
|
|
2191
|
+
const nodes = new Map();
|
|
2192
|
+
let current = null;
|
|
2193
|
+
|
|
2194
|
+
function pick(step) {
|
|
2195
|
+
const same = current === step.index;
|
|
2196
|
+
|
|
2197
|
+
current = same ? null : step.index;
|
|
2198
|
+
|
|
2199
|
+
for (const [index, button] of nodes) {
|
|
2200
|
+
const on = index === current;
|
|
2201
|
+
|
|
2202
|
+
button.setAttribute("aria-expanded", String(on));
|
|
2203
|
+
button.setAttribute("class", `${button.baseClass}${on ? " is-selected" : ""}`);
|
|
2204
|
+
}
|
|
2205
|
+
|
|
2206
|
+
detail.replaceChildren(...(same ? [] : [journeyDetail(ctx, feature, flowId, flow, step)]));
|
|
2207
|
+
}
|
|
2208
|
+
|
|
2209
|
+
const list = el(
|
|
2210
|
+
"ol",
|
|
2211
|
+
{ class: "grimoire-jny", "aria-label": "Steps in order" },
|
|
2212
|
+
steps.map((step) => {
|
|
2213
|
+
const state = step.found === false ? " is-missing" : step.found === null ? " is-unknown" : "";
|
|
2214
|
+
const baseClass = `grimoire-jnode is-${step.type.replace(/\s+/g, "-")}${state}`;
|
|
2215
|
+
const button = el(
|
|
2216
|
+
"button",
|
|
2217
|
+
{
|
|
2218
|
+
type: "button",
|
|
2219
|
+
class: baseClass,
|
|
2220
|
+
"aria-expanded": "false",
|
|
2221
|
+
"aria-controls": `grimoire-jpanel-${flowId}`,
|
|
2222
|
+
title: `Step ${step.index}, ${step.type}: ${nodeLabel(step)} (${nodeState(step)})`,
|
|
2223
|
+
onclick: () => pick(step),
|
|
2224
|
+
},
|
|
2225
|
+
[
|
|
2226
|
+
el("span", { class: "grimoire-jnode-top" }, [
|
|
2227
|
+
stepIcon(ctx, step.type, 16),
|
|
2228
|
+
el("span", { class: "grimoire-jnode-type", text: step.type }),
|
|
2229
|
+
el("span", { class: "grimoire-jnode-index", text: String(step.index) }),
|
|
2230
|
+
]),
|
|
2231
|
+
el("span", { class: "grimoire-jnode-label", text: nodeLabel(step) }),
|
|
2232
|
+
step.found === false
|
|
2233
|
+
? el("span", { class: "grimoire-jnode-flag", text: "not found" })
|
|
2234
|
+
: "",
|
|
2235
|
+
],
|
|
2236
|
+
);
|
|
2237
|
+
|
|
2238
|
+
button.baseClass = baseClass;
|
|
2239
|
+
nodes.set(step.index, button);
|
|
2240
|
+
|
|
2241
|
+
return el("li", { class: "grimoire-jstep" }, [button]);
|
|
2242
|
+
}),
|
|
2243
|
+
);
|
|
2244
|
+
|
|
2245
|
+
return el("div", { class: "grimoire-journey" }, [list, detail]);
|
|
2246
|
+
}
|
|
909
2247
|
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
2248
|
+
/** The "What if…" lane: each handled case as a small card; no card is tied to a step, the data does not say which. */
|
|
2249
|
+
function whatIfLane(ctx, feature, flowId, flow) {
|
|
2250
|
+
const { el } = ctx;
|
|
2251
|
+
const cases = flow.cases ?? [];
|
|
2252
|
+
const handled = cases.filter((item) => !item.doesNotApply);
|
|
2253
|
+
const skipped = cases.filter((item) => item.doesNotApply);
|
|
2254
|
+
|
|
2255
|
+
if (!cases.length) return "";
|
|
2256
|
+
|
|
2257
|
+
return section(ctx, "What if…", [
|
|
2258
|
+
handled.length
|
|
2259
|
+
? el(
|
|
2260
|
+
"ul",
|
|
2261
|
+
{ class: "grimoire-whatif" },
|
|
2262
|
+
handled.map((item) =>
|
|
2263
|
+
el("li", { class: "grimoire-whatif-card" }, [
|
|
2264
|
+
el("strong", { class: "grimoire-whatif-q", text: `What if ${item.question}?` }),
|
|
2265
|
+
el("p", {}, codeText(ctx, item.answer)),
|
|
2266
|
+
(item.criteria ?? []).length
|
|
2267
|
+
? el("span", { class: "grimoire-chips" }, [
|
|
2268
|
+
muted(ctx, "proven by "),
|
|
2269
|
+
...item.criteria.map((id) =>
|
|
2270
|
+
link(
|
|
2271
|
+
ctx,
|
|
2272
|
+
id,
|
|
2273
|
+
`flow/${encodeURIComponent(feature)}/${encodeURIComponent(flowId)}/proof`,
|
|
2274
|
+
{
|
|
2275
|
+
class: "grimoire-chip",
|
|
2276
|
+
title: `Open the Proof tab for ${id}`,
|
|
2277
|
+
},
|
|
2278
|
+
),
|
|
2279
|
+
),
|
|
2280
|
+
])
|
|
2281
|
+
: "",
|
|
2282
|
+
]),
|
|
2283
|
+
),
|
|
2284
|
+
)
|
|
2285
|
+
: muted(ctx, "No handled cases written."),
|
|
2286
|
+
skipped.length
|
|
2287
|
+
? el("details", { class: "grimoire-details" }, [
|
|
2288
|
+
el("summary", { text: `Does not apply (${skipped.length})` }),
|
|
2289
|
+
list(
|
|
2290
|
+
ctx,
|
|
2291
|
+
skipped.map((item) => [
|
|
2292
|
+
el("strong", { text: item.question }),
|
|
2293
|
+
" ",
|
|
2294
|
+
codeText(ctx, stripDoesNotApply(item.answer)),
|
|
2295
|
+
]),
|
|
2296
|
+
),
|
|
2297
|
+
])
|
|
2298
|
+
: "",
|
|
2299
|
+
]);
|
|
913
2300
|
}
|
|
914
2301
|
|
|
915
|
-
async function flowView(ctx, feature, flowId) {
|
|
2302
|
+
async function flowView(ctx, feature, flowId, tab = "") {
|
|
916
2303
|
const data = await ctx.api(`flows/${encodeURIComponent(feature)}/${encodeURIComponent(flowId)}`);
|
|
917
2304
|
const { el } = ctx;
|
|
918
2305
|
const flow = data.flow;
|
|
919
2306
|
const map = data.bookmap;
|
|
2307
|
+
const ref = `${feature}/${flowId}`;
|
|
920
2308
|
const status = plain(flow.status);
|
|
921
|
-
const
|
|
2309
|
+
const origin = flow.origin ? plain(flow.origin) : null;
|
|
2310
|
+
const title = plain(flow.heading) ?? plain(flow.id);
|
|
2311
|
+
const summary = plain(flow.summary) ?? null;
|
|
2312
|
+
const health = flowHealth(data);
|
|
2313
|
+
const results = data.results ?? null;
|
|
2314
|
+
const untracked = Boolean(results && results.recorded === false && results.proofs > 0);
|
|
2315
|
+
const apps = data.feature && data.feature.apps ? data.feature.apps : [];
|
|
2316
|
+
const problems = health.findings.errors + health.findings.warnings;
|
|
2317
|
+
const proven = health.criteria.proven;
|
|
2318
|
+
const total = health.criteria.total;
|
|
2319
|
+
const failing = health.criteria.byStatus.fail ?? 0;
|
|
2320
|
+
const base = `flow/${encodeURIComponent(feature)}/${encodeURIComponent(flowId)}`;
|
|
2321
|
+
// Missing tests are already shown per criterion in the Proof tab, so they are not listed twice.
|
|
2322
|
+
const rest = data.findings.filter((finding) => finding.code !== "GR4001");
|
|
2323
|
+
const out = el("div", { class: "grimoire-view grimoire-flow" }, [
|
|
2324
|
+
el("div", { class: "grimoire-minihead" }, [
|
|
2325
|
+
el("strong", { text: title }),
|
|
2326
|
+
pill(ctx, status, toneOf(status)),
|
|
2327
|
+
muted(ctx, `${proven}/${total} proven`),
|
|
2328
|
+
]),
|
|
922
2329
|
crumbs(ctx, [
|
|
923
2330
|
["Features", "features"],
|
|
924
|
-
[feature, `feature/${encodeURIComponent(feature)}`],
|
|
925
|
-
[
|
|
2331
|
+
[(data.feature && data.feature.title) || feature, `feature/${encodeURIComponent(feature)}`],
|
|
2332
|
+
[title],
|
|
926
2333
|
]),
|
|
927
|
-
heading(ctx,
|
|
928
|
-
mono(ctx,
|
|
2334
|
+
heading(ctx, title, [
|
|
2335
|
+
mono(ctx, ref),
|
|
929
2336
|
pill(ctx, status, toneOf(status)),
|
|
2337
|
+
origin ? pill(ctx, origin, toneOf(origin)) : "",
|
|
930
2338
|
muted(ctx, `since ${plain(flow.since)}, for ${plain(flow.who)}`),
|
|
931
|
-
|
|
2339
|
+
...apps.map((app) => pill(ctx, app)),
|
|
2340
|
+
neighbours(ctx, feature, data, "grimoire-switcher"),
|
|
2341
|
+
]),
|
|
2342
|
+
summary
|
|
2343
|
+
? el("p", { class: "grimoire-lede" }, codeText(ctx, summary))
|
|
2344
|
+
: el("p", {
|
|
2345
|
+
class: "grimoire-muted",
|
|
2346
|
+
text: "No summary yet. Add one sentence under the title of the flow file.",
|
|
2347
|
+
}),
|
|
2348
|
+
el("div", { class: "grimoire-stats grimoire-health" }, [
|
|
2349
|
+
tile(ctx, {
|
|
2350
|
+
label: "Criteria proven",
|
|
2351
|
+
value: `${proven}/${total}`,
|
|
2352
|
+
sub: failing
|
|
2353
|
+
? `${plural(failing, "criterion")} failing`
|
|
2354
|
+
: total
|
|
2355
|
+
? "passing tests"
|
|
2356
|
+
: "none written",
|
|
2357
|
+
tone: failing ? "bad" : total && proven === total ? "good" : total ? "warn" : "",
|
|
2358
|
+
}),
|
|
2359
|
+
el("div", { class: "grimoire-stat" }, [
|
|
2360
|
+
el("span", { class: "grimoire-stat-label", text: "Last test run" }),
|
|
2361
|
+
el("span", {
|
|
2362
|
+
class: "grimoire-stat-value grimoire-stat-small",
|
|
2363
|
+
text:
|
|
2364
|
+
results && results.recorded && results.updatedAt
|
|
2365
|
+
? results.updatedAt.slice(0, 10)
|
|
2366
|
+
: "none",
|
|
2367
|
+
}),
|
|
2368
|
+
el("span", {
|
|
2369
|
+
class: "grimoire-stat-sub",
|
|
2370
|
+
text: results && results.recorded ? "results recorded" : "no results recorded",
|
|
2371
|
+
}),
|
|
2372
|
+
]),
|
|
2373
|
+
stat(ctx, {
|
|
2374
|
+
label: "Findings",
|
|
2375
|
+
value: problems,
|
|
2376
|
+
sub: `${plural(health.findings.errors, "error")}, ${plural(health.findings.warnings, "warning")}`,
|
|
2377
|
+
target: checkTarget({ flow: ref }),
|
|
2378
|
+
tone: health.findings.errors ? "bad" : problems ? "warn" : "good",
|
|
2379
|
+
}),
|
|
2380
|
+
el("div", { class: "grimoire-stat" }, [
|
|
2381
|
+
el("span", { class: "grimoire-stat-label", text: "Steps resolved" }),
|
|
2382
|
+
el("span", {
|
|
2383
|
+
class: "grimoire-stat-value",
|
|
2384
|
+
text: `${health.steps.resolved}/${health.steps.total - (health.steps.unchecked ?? 0)}`,
|
|
2385
|
+
}),
|
|
2386
|
+
el("span", {
|
|
2387
|
+
class: "grimoire-stat-sub",
|
|
2388
|
+
text: health.steps.unchecked
|
|
2389
|
+
? `found in the book; ${health.steps.unchecked} not checked`
|
|
2390
|
+
: "found in the book",
|
|
2391
|
+
}),
|
|
2392
|
+
]),
|
|
932
2393
|
]),
|
|
933
2394
|
]);
|
|
934
2395
|
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
2396
|
+
if (untracked) {
|
|
2397
|
+
out.append(
|
|
2398
|
+
el("div", { class: "grimoire-note", role: "note" }, [
|
|
2399
|
+
el("strong", { text: "No test results recorded yet. " }),
|
|
2400
|
+
codeText(
|
|
2401
|
+
ctx,
|
|
2402
|
+
`${results.proofs} tagged ${results.proofs === 1 ? "test is" : "tests are"} waiting for a result. Add \`grimoireReporter()\` to the Vitest config and run the tests, or set the panel option \`testResultsFile\`. Looking in ${results.file}.`,
|
|
2403
|
+
),
|
|
2404
|
+
]),
|
|
2405
|
+
);
|
|
2406
|
+
}
|
|
2407
|
+
|
|
2408
|
+
const journeyTab = () => {
|
|
2409
|
+
const box = el("div", { class: "grimoire-tabstack" });
|
|
2410
|
+
|
|
2411
|
+
if ((flow.story ?? []).length) {
|
|
2412
|
+
box.append(
|
|
2413
|
+
section(ctx, "Story", [
|
|
2414
|
+
el(
|
|
2415
|
+
"ol",
|
|
2416
|
+
{ class: "grimoire-story" },
|
|
2417
|
+
flow.story.map((item) => el("li", {}, codeText(ctx, item.text))),
|
|
2418
|
+
),
|
|
2419
|
+
]),
|
|
2420
|
+
);
|
|
2421
|
+
}
|
|
2422
|
+
|
|
2423
|
+
box.append(section(ctx, "Journey", [journeyView(ctx, feature, flowId, flow, map.steps)]));
|
|
2424
|
+
box.append(whatIfLane(ctx, feature, flowId, flow));
|
|
2425
|
+
|
|
2426
|
+
if ((flow.differs ?? []).length) {
|
|
2427
|
+
box.append(
|
|
2428
|
+
section(ctx, "Differs by app", [
|
|
2429
|
+
list(
|
|
939
2430
|
ctx,
|
|
940
|
-
[
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
step.type === "route" && step.target.includes(" ")
|
|
946
|
-
? routeLink(
|
|
947
|
-
ctx,
|
|
948
|
-
step.target.split(" ")[0],
|
|
949
|
-
step.target.slice(step.target.indexOf(" ") + 1),
|
|
950
|
-
)
|
|
951
|
-
: step.target,
|
|
952
|
-
],
|
|
953
|
-
[
|
|
954
|
-
step.found === null
|
|
955
|
-
? ""
|
|
956
|
-
: pill(ctx, step.found ? "yes" : "no", step.found ? "good" : "bad"),
|
|
957
|
-
],
|
|
958
|
-
[step.files.length ? fileChips(ctx, step.files, 6) : ""],
|
|
959
|
-
]),
|
|
960
|
-
)
|
|
961
|
-
: ctx.empty("This flow has no steps."),
|
|
962
|
-
]),
|
|
963
|
-
);
|
|
2431
|
+
flow.differs.map((item) => [mono(ctx, item.name), " ", codeText(ctx, item.text)]),
|
|
2432
|
+
),
|
|
2433
|
+
]),
|
|
2434
|
+
);
|
|
2435
|
+
}
|
|
964
2436
|
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
2437
|
+
if ((flow.notHandled ?? []).length) {
|
|
2438
|
+
box.append(
|
|
2439
|
+
section(ctx, "Not handled", [
|
|
2440
|
+
list(
|
|
969
2441
|
ctx,
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
[criterion.text],
|
|
975
|
-
[pill(ctx, criterion.status, toneOf(criterion.status))],
|
|
976
|
-
[
|
|
977
|
-
criterion.tests.length
|
|
978
|
-
? list(
|
|
979
|
-
ctx,
|
|
980
|
-
criterion.tests.map((test) => [
|
|
981
|
-
fileLink(ctx, test.file),
|
|
982
|
-
`:${test.line} `,
|
|
983
|
-
test.name ?? "",
|
|
984
|
-
" ",
|
|
985
|
-
pill(
|
|
986
|
-
ctx,
|
|
987
|
-
test.stale ? `${test.result}, stale` : test.result,
|
|
988
|
-
test.stale ? "warn" : toneOf(test.result),
|
|
989
|
-
),
|
|
990
|
-
]),
|
|
991
|
-
)
|
|
992
|
-
: muted(ctx, "no test"),
|
|
993
|
-
],
|
|
2442
|
+
flow.notHandled.map((item) => [
|
|
2443
|
+
el("strong", { text: item.name }),
|
|
2444
|
+
" ",
|
|
2445
|
+
codeText(ctx, item.text),
|
|
994
2446
|
]),
|
|
995
|
-
)
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
2447
|
+
),
|
|
2448
|
+
]),
|
|
2449
|
+
);
|
|
2450
|
+
}
|
|
999
2451
|
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
2452
|
+
if (flow.unknowns.length) {
|
|
2453
|
+
box.append(
|
|
2454
|
+
section(ctx, "Unknowns", [
|
|
2455
|
+
list(
|
|
1004
2456
|
ctx,
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
`${shown.app} ${shown.type} ${shown.id}`,
|
|
1011
|
-
`page/${encodeURIComponent(shown.app)}/${encodeURIComponent(shown.id)}`,
|
|
1012
|
-
),
|
|
1013
|
-
` as block ${shown.block}`,
|
|
1014
|
-
]),
|
|
1015
|
-
)
|
|
1016
|
-
: ctx.empty("No app page shows this flow."),
|
|
1017
|
-
]),
|
|
1018
|
-
);
|
|
2457
|
+
flow.unknowns.map((item) => [codeText(ctx, item.text)]),
|
|
2458
|
+
),
|
|
2459
|
+
]),
|
|
2460
|
+
);
|
|
2461
|
+
}
|
|
1019
2462
|
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
2463
|
+
box.append(
|
|
2464
|
+
section(ctx, "Where users see it", [
|
|
2465
|
+
map.shownBy.length
|
|
2466
|
+
? list(
|
|
2467
|
+
ctx,
|
|
2468
|
+
map.shownBy.map((shown) => [
|
|
2469
|
+
shown.type === "layout"
|
|
2470
|
+
? `${shown.app} layout ${shown.id}`
|
|
2471
|
+
: link(
|
|
2472
|
+
ctx,
|
|
2473
|
+
`${shown.app} ${shown.type} ${shown.id}`,
|
|
2474
|
+
`page/${encodeURIComponent(shown.app)}/${encodeURIComponent(shown.id)}`,
|
|
2475
|
+
),
|
|
2476
|
+
` as block ${shown.block}`,
|
|
2477
|
+
]),
|
|
2478
|
+
)
|
|
2479
|
+
: ctx.empty("No app page shows this flow."),
|
|
1031
2480
|
]),
|
|
1032
2481
|
);
|
|
1033
|
-
|
|
2482
|
+
box.append(section(ctx, "History", [changesView(ctx, data.history)]));
|
|
2483
|
+
box.append(neighbours(ctx, feature, data, "grimoire-pager"));
|
|
2484
|
+
return box;
|
|
2485
|
+
};
|
|
1034
2486
|
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
2487
|
+
const proofTab = () =>
|
|
2488
|
+
el("div", { class: "grimoire-tabstack" }, [
|
|
2489
|
+
fixNextBox(ctx, ref, fixNextCriterion(map.criteria)),
|
|
2490
|
+
section(ctx, "Proof", [
|
|
2491
|
+
map.criteria.length
|
|
2492
|
+
? el(
|
|
2493
|
+
"ul",
|
|
2494
|
+
{ class: "grimoire-proofs" },
|
|
2495
|
+
map.criteria.map((criterion) => proofRow(ctx, criterion, untracked)),
|
|
2496
|
+
)
|
|
2497
|
+
: ctx.empty("No criteria written."),
|
|
1042
2498
|
]),
|
|
1043
|
-
);
|
|
1044
|
-
|
|
2499
|
+
]);
|
|
2500
|
+
|
|
2501
|
+
const filesTab = () =>
|
|
2502
|
+
section(ctx, "Files per step", [
|
|
2503
|
+
map.steps.length
|
|
2504
|
+
? el(
|
|
2505
|
+
"div",
|
|
2506
|
+
{ class: "grimoire-groups" },
|
|
2507
|
+
map.steps.map((step) => {
|
|
2508
|
+
const counts = step.counts ?? { direct: 0, feature: 0, reachable: 0, typeOnly: 0 };
|
|
2509
|
+
|
|
2510
|
+
return group(ctx, {
|
|
2511
|
+
title: `${step.index}. ${nodeLabel(step)}`,
|
|
2512
|
+
count: counts.reachable,
|
|
2513
|
+
tone: step.found === false ? "warn" : "",
|
|
2514
|
+
lead: [pill(ctx, step.type)],
|
|
2515
|
+
make: () =>
|
|
2516
|
+
counts.reachable || counts.direct
|
|
2517
|
+
? stepFilesPanel(ctx, feature, flowId, step)
|
|
2518
|
+
: muted(
|
|
2519
|
+
ctx,
|
|
2520
|
+
step.found === false
|
|
2521
|
+
? "The step matched nothing in the book."
|
|
2522
|
+
: "This step reaches no files.",
|
|
2523
|
+
),
|
|
2524
|
+
});
|
|
2525
|
+
}),
|
|
2526
|
+
)
|
|
2527
|
+
: ctx.empty("This flow has no steps."),
|
|
2528
|
+
]);
|
|
2529
|
+
|
|
2530
|
+
out.append(
|
|
2531
|
+
tabbed(ctx, {
|
|
2532
|
+
label: "This flow",
|
|
2533
|
+
prefix: "grimoire-flowtab",
|
|
2534
|
+
active: tab,
|
|
2535
|
+
route: (key) => (key === "journey" ? base : `${base}/${key}`),
|
|
2536
|
+
tabs: [
|
|
2537
|
+
{ id: "journey", label: "Journey", count: map.steps.length, make: journeyTab },
|
|
2538
|
+
{ id: "proof", label: "Proof", count: map.criteria.length, make: proofTab },
|
|
2539
|
+
{ id: "files", label: "Files", make: filesTab },
|
|
2540
|
+
{
|
|
2541
|
+
id: "findings",
|
|
2542
|
+
label: "Findings",
|
|
2543
|
+
count: rest.length,
|
|
2544
|
+
make: () => section(ctx, "Findings", [findingGroups(ctx, rest)]),
|
|
2545
|
+
},
|
|
2546
|
+
],
|
|
2547
|
+
}),
|
|
2548
|
+
);
|
|
1045
2549
|
|
|
1046
|
-
out.append(section(ctx, "History", [changesView(ctx, data.history)]));
|
|
1047
|
-
if (data.findings.length) out.append(section(ctx, "Findings", [findingList(ctx, data.findings)]));
|
|
1048
2550
|
return out;
|
|
1049
2551
|
}
|
|
1050
2552
|
|
|
@@ -1303,7 +2805,7 @@ async function appsView(ctx) {
|
|
|
1303
2805
|
function taskCard(ctx, task) {
|
|
1304
2806
|
return section(ctx, task.id, [
|
|
1305
2807
|
facts(ctx, [
|
|
1306
|
-
["Title", task.title],
|
|
2808
|
+
["Title", codeText(ctx, task.title)],
|
|
1307
2809
|
["Type", task.type],
|
|
1308
2810
|
["Status", pill(ctx, task.status, toneOf(task.status))],
|
|
1309
2811
|
[
|
|
@@ -1369,8 +2871,12 @@ async function tasksView(ctx, only) {
|
|
|
1369
2871
|
ctx,
|
|
1370
2872
|
["Task", "Title", "Type", "Status", "Feature", "Decision needed"],
|
|
1371
2873
|
tasks.map((task) => [
|
|
1372
|
-
[
|
|
1373
|
-
|
|
2874
|
+
[
|
|
2875
|
+
link(ctx, task.id, `task/${encodeURIComponent(task.id)}`, {
|
|
2876
|
+
class: "grimoire-nowrap",
|
|
2877
|
+
}),
|
|
2878
|
+
],
|
|
2879
|
+
[codeText(ctx, task.title)],
|
|
1374
2880
|
[task.type],
|
|
1375
2881
|
[pill(ctx, task.status, toneOf(group))],
|
|
1376
2882
|
[
|
|
@@ -1448,60 +2954,237 @@ async function releaseView(ctx, id) {
|
|
|
1448
2954
|
]);
|
|
1449
2955
|
}
|
|
1450
2956
|
|
|
1451
|
-
|
|
1452
|
-
|
|
2957
|
+
/** One link of a filter row; the active one is marked. */
|
|
2958
|
+
function filterLink(ctx, label, target, active) {
|
|
2959
|
+
return ctx.el("a", {
|
|
2960
|
+
href: ctx.href(target),
|
|
2961
|
+
class: active ? "grimoire-filter is-active" : "grimoire-filter",
|
|
2962
|
+
...(active ? { "aria-current": "true" } : {}),
|
|
2963
|
+
text: label,
|
|
2964
|
+
});
|
|
2965
|
+
}
|
|
2966
|
+
|
|
2967
|
+
/** A select that opens the Check tab with one more filter set. */
|
|
2968
|
+
function filterSelect(ctx, label, key, options, query) {
|
|
2969
|
+
return ctx.el(
|
|
2970
|
+
"select",
|
|
2971
|
+
{
|
|
2972
|
+
class: "grimoire-sort",
|
|
2973
|
+
"aria-label": label,
|
|
2974
|
+
onchange: (event) => ctx.navigate(checkTarget({ ...query, [key]: event.target.value })),
|
|
2975
|
+
},
|
|
2976
|
+
[
|
|
2977
|
+
ctx.el("option", { value: "", text: `${label}: all` }),
|
|
2978
|
+
...options.map((option) =>
|
|
2979
|
+
ctx.el("option", {
|
|
2980
|
+
value: option,
|
|
2981
|
+
text: option,
|
|
2982
|
+
...(query[key] === option ? { selected: "selected" } : {}),
|
|
2983
|
+
}),
|
|
2984
|
+
),
|
|
2985
|
+
],
|
|
2986
|
+
);
|
|
2987
|
+
}
|
|
2988
|
+
|
|
2989
|
+
/** One code of the check: its title, the fix once, and its features with a count and "Show". */
|
|
2990
|
+
function checkGroupCard(ctx, group, mode, query) {
|
|
2991
|
+
const { el } = ctx;
|
|
2992
|
+
const count = mode === "expected" ? group.expected : group.count;
|
|
2993
|
+
const filter = { state: mode, ...(query.severity ? { severity: query.severity } : {}) };
|
|
2994
|
+
// Files no flow reaches are one finding per file: shown one row per feature, files on request.
|
|
2995
|
+
const perFeature = group.code === "GR3006";
|
|
2996
|
+
const features = group.features;
|
|
2997
|
+
|
|
2998
|
+
return el("section", { class: "grimoire-card grimoire-check-group" }, [
|
|
2999
|
+
el("header", { class: "grimoire-check-head" }, [
|
|
3000
|
+
pill(ctx, group.severity, mode === "expected" ? "" : toneOf(group.severity)),
|
|
3001
|
+
mono(ctx, group.code),
|
|
3002
|
+
el("h3", {}, codeText(ctx, group.title)),
|
|
3003
|
+
pill(ctx, String(count)),
|
|
3004
|
+
]),
|
|
3005
|
+
group.fix ? el("p", { class: "grimoire-muted" }, codeText(ctx, group.fix)) : "",
|
|
3006
|
+
features.length
|
|
3007
|
+
? el(
|
|
3008
|
+
"ul",
|
|
3009
|
+
{ class: "grimoire-check-features" },
|
|
3010
|
+
features.map((item) => {
|
|
3011
|
+
const shown = expander(ctx, perFeature ? "Show files" : "Show", () =>
|
|
3012
|
+
pagedFindings(
|
|
3013
|
+
ctx,
|
|
3014
|
+
{
|
|
3015
|
+
...filter,
|
|
3016
|
+
code: group.code,
|
|
3017
|
+
...(item.feature === "(none)" ? {} : { feature: item.feature }),
|
|
3018
|
+
},
|
|
3019
|
+
{ hints: false },
|
|
3020
|
+
),
|
|
3021
|
+
);
|
|
3022
|
+
|
|
3023
|
+
return el("li", { class: "grimoire-check-feature" }, [
|
|
3024
|
+
el("div", { class: "grimoire-check-feature-row" }, [
|
|
3025
|
+
item.feature === "(none)"
|
|
3026
|
+
? muted(ctx, "no feature")
|
|
3027
|
+
: link(
|
|
3028
|
+
ctx,
|
|
3029
|
+
item.feature,
|
|
3030
|
+
checkTarget({ ...filter, code: group.code, feature: item.feature }),
|
|
3031
|
+
),
|
|
3032
|
+
pill(ctx, plural(item.count, perFeature ? "file" : "finding")),
|
|
3033
|
+
shown.button,
|
|
3034
|
+
]),
|
|
3035
|
+
shown.panel,
|
|
3036
|
+
]);
|
|
3037
|
+
}),
|
|
3038
|
+
)
|
|
3039
|
+
: "",
|
|
3040
|
+
perFeature
|
|
3041
|
+
? ""
|
|
3042
|
+
: (() => {
|
|
3043
|
+
const all = expander(ctx, `Show all ${count}`, () =>
|
|
3044
|
+
pagedFindings(ctx, { ...filter, code: group.code }, { hints: false }),
|
|
3045
|
+
);
|
|
3046
|
+
|
|
3047
|
+
return el("div", {}, [all.button, all.panel]);
|
|
3048
|
+
})(),
|
|
3049
|
+
]);
|
|
3050
|
+
}
|
|
3051
|
+
|
|
3052
|
+
async function checkView(ctx, query = {}) {
|
|
3053
|
+
const report = await ctx.api("check/groups");
|
|
1453
3054
|
const { counts } = report;
|
|
1454
3055
|
const { el } = ctx;
|
|
1455
|
-
const
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
3056
|
+
const groups = report.groups ?? [];
|
|
3057
|
+
const kinds = groups.filter((group) => group.count > 0).length;
|
|
3058
|
+
const expectedMode = query.state === "expected";
|
|
3059
|
+
const matches = (group) =>
|
|
3060
|
+
(!query.code || group.code === query.code) &&
|
|
3061
|
+
(!query.severity || group.severity === query.severity) &&
|
|
3062
|
+
(!query.feature || group.features.some((item) => item.feature === query.feature));
|
|
3063
|
+
const main = expectedMode ? [] : groups.filter((group) => group.count > 0 && matches(group));
|
|
3064
|
+
const expected = groups.filter(
|
|
3065
|
+
(group) => group.expected > 0 && (expectedMode || group.count === 0) && matches(group),
|
|
3066
|
+
);
|
|
3067
|
+
const flat = Boolean(query.flow || query.feature);
|
|
3068
|
+
const names = [...new Set(groups.flatMap((group) => group.features.map((item) => item.feature)))]
|
|
3069
|
+
.filter((name) => name !== "(none)")
|
|
3070
|
+
.sort();
|
|
3071
|
+
const active = ["code", "feature", "flow", "severity", "state"].filter((key) => query[key]);
|
|
1459
3072
|
|
|
1460
|
-
|
|
1461
|
-
heading(ctx,
|
|
1462
|
-
pill(ctx, plural(counts.errors, "error")
|
|
3073
|
+
const out = el("div", { class: "grimoire-view" }, [
|
|
3074
|
+
heading(ctx, "Check", [
|
|
3075
|
+
pill(ctx, `${plural(counts.errors, "error")}`, counts.errors ? "bad" : "good"),
|
|
1463
3076
|
pill(ctx, plural(counts.warnings, "warning"), counts.warnings ? "warn" : ""),
|
|
1464
3077
|
pill(ctx, `${counts.expected} expected`),
|
|
1465
|
-
muted(
|
|
3078
|
+
muted(
|
|
3079
|
+
ctx,
|
|
3080
|
+
`Route facts: ${routeFactsState(report.routes).value}, ${routeFactsState(report.routes).sub}`,
|
|
3081
|
+
),
|
|
1466
3082
|
]),
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
3083
|
+
el("p", {
|
|
3084
|
+
class: "grimoire-headline",
|
|
3085
|
+
text: `${plural(counts.errors, "error")} · ${plural(counts.warnings, "warning")} in ${plural(kinds, "kind")}`,
|
|
3086
|
+
}),
|
|
3087
|
+
el("div", { class: "grimoire-toolbar grimoire-check-filters" }, [
|
|
3088
|
+
el("div", { class: "grimoire-filters", role: "group", "aria-label": "Severity" }, [
|
|
3089
|
+
filterLink(ctx, "all", checkTarget({ ...query, severity: "" }), !query.severity),
|
|
3090
|
+
filterLink(
|
|
3091
|
+
ctx,
|
|
3092
|
+
"errors",
|
|
3093
|
+
checkTarget({ ...query, severity: "error" }),
|
|
3094
|
+
query.severity === "error",
|
|
3095
|
+
),
|
|
3096
|
+
filterLink(
|
|
3097
|
+
ctx,
|
|
3098
|
+
"warnings",
|
|
3099
|
+
checkTarget({ ...query, severity: "warning" }),
|
|
3100
|
+
query.severity === "warning",
|
|
3101
|
+
),
|
|
3102
|
+
]),
|
|
3103
|
+
el("div", { class: "grimoire-filters", role: "group", "aria-label": "State" }, [
|
|
3104
|
+
filterLink(ctx, "to fix", checkTarget({ ...query, state: "" }), !query.state),
|
|
3105
|
+
filterLink(ctx, "expected", checkTarget({ ...query, state: "expected" }), expectedMode),
|
|
3106
|
+
]),
|
|
3107
|
+
filterSelect(
|
|
3108
|
+
ctx,
|
|
3109
|
+
"Code",
|
|
3110
|
+
"code",
|
|
3111
|
+
groups.map((group) => group.code),
|
|
3112
|
+
query,
|
|
3113
|
+
),
|
|
3114
|
+
filterSelect(ctx, "Feature", "feature", names, query),
|
|
3115
|
+
]),
|
|
3116
|
+
active.some((key) => key === "code" || key === "feature" || key === "flow")
|
|
3117
|
+
? el(
|
|
3118
|
+
"div",
|
|
3119
|
+
{ class: "grimoire-chips" },
|
|
3120
|
+
["code", "feature", "flow"]
|
|
3121
|
+
.filter((key) => query[key])
|
|
3122
|
+
.map((key) =>
|
|
3123
|
+
link(ctx, `${key}: ${query[key]} ×`, checkTarget({ ...query, [key]: "" }), {
|
|
3124
|
+
class: "grimoire-chip",
|
|
3125
|
+
title: `Clear the ${key} filter`,
|
|
3126
|
+
}),
|
|
3127
|
+
),
|
|
3128
|
+
)
|
|
3129
|
+
: "",
|
|
1504
3130
|
]);
|
|
3131
|
+
|
|
3132
|
+
if (flat) {
|
|
3133
|
+
out.append(
|
|
3134
|
+
section(ctx, "Findings", [
|
|
3135
|
+
pagedFindings(
|
|
3136
|
+
ctx,
|
|
3137
|
+
{
|
|
3138
|
+
code: query.code,
|
|
3139
|
+
feature: query.feature,
|
|
3140
|
+
flow: query.flow,
|
|
3141
|
+
severity: query.severity,
|
|
3142
|
+
state: query.state ?? "unexpected",
|
|
3143
|
+
},
|
|
3144
|
+
{ size: 50 },
|
|
3145
|
+
),
|
|
3146
|
+
]),
|
|
3147
|
+
);
|
|
3148
|
+
return out;
|
|
3149
|
+
}
|
|
3150
|
+
|
|
3151
|
+
if (!main.length && !expected.length) {
|
|
3152
|
+
out.append(
|
|
3153
|
+
ctx.empty(
|
|
3154
|
+
active.length
|
|
3155
|
+
? "No findings match these filters. Clear a filter to see more."
|
|
3156
|
+
: "No findings. The written files and the code agree.",
|
|
3157
|
+
),
|
|
3158
|
+
);
|
|
3159
|
+
return out;
|
|
3160
|
+
}
|
|
3161
|
+
|
|
3162
|
+
if (main.length) {
|
|
3163
|
+
out.append(
|
|
3164
|
+
el("div", { class: "grimoire-view-groups" }, [
|
|
3165
|
+
el("h3", { class: "grimoire-subhead", text: `To fix (${plural(main.length, "kind")})` }),
|
|
3166
|
+
...main.map((group) => checkGroupCard(ctx, group, "unexpected", query)),
|
|
3167
|
+
]),
|
|
3168
|
+
);
|
|
3169
|
+
}
|
|
3170
|
+
|
|
3171
|
+
if (expected.length) {
|
|
3172
|
+
out.append(
|
|
3173
|
+
el("div", { class: "grimoire-view-groups" }, [
|
|
3174
|
+
el("h3", {
|
|
3175
|
+
class: "grimoire-subhead",
|
|
3176
|
+
text: `Expected: proposed work (${plural(expected.length, "kind")})`,
|
|
3177
|
+
}),
|
|
3178
|
+
el("p", {
|
|
3179
|
+
class: "grimoire-muted",
|
|
3180
|
+
text: "These concern features or flows that are still proposed, so the code does not exist yet. They never fail the check.",
|
|
3181
|
+
}),
|
|
3182
|
+
...expected.map((group) => checkGroupCard(ctx, group, "expected", query)),
|
|
3183
|
+
]),
|
|
3184
|
+
);
|
|
3185
|
+
}
|
|
3186
|
+
|
|
3187
|
+
return out;
|
|
1505
3188
|
}
|
|
1506
3189
|
|
|
1507
3190
|
async function fileView(ctx, path) {
|
|
@@ -1642,18 +3325,41 @@ async function modulesView(ctx) {
|
|
|
1642
3325
|
|
|
1643
3326
|
// ── Shell ───────────────────────────────────────────────────────────────────
|
|
1644
3327
|
|
|
3328
|
+
/**
|
|
3329
|
+
* An asset URL `import()` accepts. A host may hand out a page-relative path
|
|
3330
|
+
* (`panels/grimoire/x.js`), which `import()` reads as a bare module specifier
|
|
3331
|
+
* and refuses; resolve it against the page first.
|
|
3332
|
+
*/
|
|
3333
|
+
function moduleUrl(url) {
|
|
3334
|
+
const base = globalThis.document?.baseURI ?? globalThis.location?.href;
|
|
3335
|
+
|
|
3336
|
+
try {
|
|
3337
|
+
return base ? new URL(url, base).href : url;
|
|
3338
|
+
} catch {
|
|
3339
|
+
return url;
|
|
3340
|
+
}
|
|
3341
|
+
}
|
|
3342
|
+
|
|
1645
3343
|
/** Pick the view for the hash route. */
|
|
1646
3344
|
async function body(ctx, summaryRequest) {
|
|
1647
|
-
const
|
|
3345
|
+
const { path, query } = parseRoute(ctx.route ?? "");
|
|
3346
|
+
const parts = path ? path.split("/").map(decodeSegment) : [];
|
|
1648
3347
|
const [type = "", first = "", second = ""] = parts;
|
|
1649
3348
|
|
|
1650
3349
|
switch (type) {
|
|
3350
|
+
case "product": {
|
|
3351
|
+
const map =
|
|
3352
|
+
globalThis.grimoireProductMap ??
|
|
3353
|
+
(await import(/* @vite-ignore */ moduleUrl(ctx.asset("product-map.js"))));
|
|
3354
|
+
|
|
3355
|
+
return map.productMapView(ctx, parts.slice(1));
|
|
3356
|
+
}
|
|
1651
3357
|
case "features":
|
|
1652
3358
|
return featuresView(ctx);
|
|
1653
3359
|
case "feature":
|
|
1654
|
-
return featureView(ctx, first);
|
|
3360
|
+
return featureView(ctx, first, second);
|
|
1655
3361
|
case "flow":
|
|
1656
|
-
return flowView(ctx, first, second);
|
|
3362
|
+
return flowView(ctx, first, second, parts[3] ?? "");
|
|
1657
3363
|
case "page":
|
|
1658
3364
|
return pageView(ctx, first, parts.slice(2).join("/"));
|
|
1659
3365
|
case "apps":
|
|
@@ -1667,7 +3373,7 @@ async function body(ctx, summaryRequest) {
|
|
|
1667
3373
|
case "release":
|
|
1668
3374
|
return releaseView(ctx, first);
|
|
1669
3375
|
case "check":
|
|
1670
|
-
return checkView(ctx);
|
|
3376
|
+
return checkView(ctx, query);
|
|
1671
3377
|
case "file":
|
|
1672
3378
|
return fileView(ctx, first);
|
|
1673
3379
|
case "route":
|
|
@@ -1681,8 +3387,9 @@ async function body(ctx, summaryRequest) {
|
|
|
1681
3387
|
|
|
1682
3388
|
/** What the view is about, for error messages, and the list to go back to. */
|
|
1683
3389
|
function describe(route) {
|
|
1684
|
-
const type = route.split("/")[0] ?? "";
|
|
3390
|
+
const type = (route.split("?")[0] ?? "").split("/")[0] ?? "";
|
|
1685
3391
|
const map = {
|
|
3392
|
+
product: ["the product map", null],
|
|
1686
3393
|
features: ["the features", null],
|
|
1687
3394
|
feature: ["the feature", ["Features", "features"]],
|
|
1688
3395
|
flow: ["the flow", ["Features", "features"]],
|
|
@@ -1701,29 +3408,103 @@ function describe(route) {
|
|
|
1701
3408
|
return map[type] ?? ["the overview", null];
|
|
1702
3409
|
}
|
|
1703
3410
|
|
|
1704
|
-
/** The
|
|
3411
|
+
/** The hint under the progress line: more specific the longer the book takes. */
|
|
3412
|
+
function loadingHint(seconds) {
|
|
3413
|
+
if (seconds >= 40)
|
|
3414
|
+
return "Still opening after 40 s. Check that the app is running and look at its server log; Retry appears if the request fails.";
|
|
3415
|
+
if (seconds >= 15)
|
|
3416
|
+
return "This is taking longer than usual. A very large book can need up to 30 s the first time; keep this tab open.";
|
|
3417
|
+
if (seconds >= 5) return "Large books take 5–15 s the first time; later opens are instant.";
|
|
3418
|
+
|
|
3419
|
+
return "Reading the book. The first open of a large book can take a few seconds.";
|
|
3420
|
+
}
|
|
3421
|
+
|
|
3422
|
+
// Inline, so the layout holds even when grimoire.css fails to load (tokens only).
|
|
3423
|
+
const SKEL_GRID =
|
|
3424
|
+
"display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,150px),1fr));gap:12px;margin-top:6px";
|
|
3425
|
+
const SKEL_BLOCK = "height:76px;border-radius:var(--radius,10px);background-color:var(--muted)";
|
|
3426
|
+
const SKEL_ROW =
|
|
3427
|
+
"height:34px;border-radius:calc(var(--radius,10px) - 4px);background-color:var(--muted)";
|
|
3428
|
+
const SKEL_TRACK =
|
|
3429
|
+
"height:4px;border-radius:2px;background:var(--muted);overflow:hidden;position:relative;max-width:260px";
|
|
3430
|
+
const SKEL_BAR = "height:100%;width:40%;border-radius:2px;background:var(--brand,var(--primary))";
|
|
3431
|
+
|
|
3432
|
+
/**
|
|
3433
|
+
* The loading state: a skeleton of the Overview with a progress line, a live
|
|
3434
|
+
* elapsed counter and a hint that grows more specific with time. `stop()` ends
|
|
3435
|
+
* the counter; call it once the view is filled in or failed.
|
|
3436
|
+
*/
|
|
1705
3437
|
function skeleton(ctx) {
|
|
1706
3438
|
const { el } = ctx;
|
|
3439
|
+
const started = Date.now();
|
|
3440
|
+
const counter = el("span", { class: "grimoire-load-elapsed", text: "0 s" });
|
|
3441
|
+
const hint = el("p", { class: "grimoire-muted grimoire-load-hint", text: loadingHint(0) });
|
|
3442
|
+
const timer =
|
|
3443
|
+
typeof setInterval === "function"
|
|
3444
|
+
? setInterval(() => {
|
|
3445
|
+
const seconds = Math.floor((Date.now() - started) / 1000);
|
|
3446
|
+
|
|
3447
|
+
counter.textContent = `${seconds} s`;
|
|
3448
|
+
hint.textContent = loadingHint(seconds);
|
|
3449
|
+
}, 1000)
|
|
3450
|
+
: null;
|
|
3451
|
+
|
|
3452
|
+
const node = el(
|
|
3453
|
+
"div",
|
|
3454
|
+
{
|
|
3455
|
+
class: "grimoire-skeleton",
|
|
3456
|
+
role: "status",
|
|
3457
|
+
"aria-live": "polite",
|
|
3458
|
+
style: "display:grid;gap:10px",
|
|
3459
|
+
},
|
|
3460
|
+
[
|
|
3461
|
+
el("p", {
|
|
3462
|
+
class: "grimoire-skeleton-title",
|
|
3463
|
+
style: "margin:0;font-weight:600",
|
|
3464
|
+
text: "Opening the book…",
|
|
3465
|
+
}),
|
|
3466
|
+
el("div", { class: "grimoire-load-progress", style: "display:grid;gap:6px" }, [
|
|
3467
|
+
el("div", { class: "grimoire-load-track", style: SKEL_TRACK, "aria-hidden": "true" }, [
|
|
3468
|
+
el("div", { class: "grimoire-load-bar", style: SKEL_BAR }),
|
|
3469
|
+
]),
|
|
3470
|
+
el("p", { class: "grimoire-muted", style: "margin:0" }, ["Elapsed ", counter]),
|
|
3471
|
+
]),
|
|
3472
|
+
hint,
|
|
3473
|
+
el(
|
|
3474
|
+
"div",
|
|
3475
|
+
{ class: "grimoire-skeleton-grid", style: SKEL_GRID, "aria-hidden": "true" },
|
|
3476
|
+
[1, 2, 3, 4, 5, 6].map(() =>
|
|
3477
|
+
el("div", { class: "grimoire-skeleton-block", style: SKEL_BLOCK }),
|
|
3478
|
+
),
|
|
3479
|
+
),
|
|
3480
|
+
el(
|
|
3481
|
+
"div",
|
|
3482
|
+
{
|
|
3483
|
+
class: "grimoire-skeleton-rows",
|
|
3484
|
+
style: "display:grid;gap:8px;margin-top:6px",
|
|
3485
|
+
"aria-hidden": "true",
|
|
3486
|
+
},
|
|
3487
|
+
[1, 2, 3, 4, 5].map(() => el("div", { class: "grimoire-skeleton-row", style: SKEL_ROW })),
|
|
3488
|
+
),
|
|
3489
|
+
],
|
|
3490
|
+
);
|
|
1707
3491
|
|
|
1708
|
-
return
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
el(
|
|
1715
|
-
"div",
|
|
1716
|
-
{ class: "grimoire-skeleton-grid", "aria-hidden": "true" },
|
|
1717
|
-
[1, 2, 3, 4, 5, 6].map(() => el("div", { class: "grimoire-skeleton-block" })),
|
|
1718
|
-
),
|
|
1719
|
-
]);
|
|
3492
|
+
return {
|
|
3493
|
+
node,
|
|
3494
|
+
stop: () => {
|
|
3495
|
+
if (timer !== null) clearInterval(timer);
|
|
3496
|
+
},
|
|
3497
|
+
};
|
|
1720
3498
|
}
|
|
1721
3499
|
|
|
1722
3500
|
/** A failed view: what failed, why, what to do, and a way to try again. */
|
|
1723
3501
|
function errorBox(ctx, route, error) {
|
|
1724
3502
|
const { el } = ctx;
|
|
1725
3503
|
const [what, back] = describe(route);
|
|
1726
|
-
const
|
|
3504
|
+
const base = error && error.message ? error.message : String(error);
|
|
3505
|
+
const status =
|
|
3506
|
+
error && typeof error.status === "number" && error.status > 0 ? ` (HTTP ${error.status})` : "";
|
|
3507
|
+
const message = base + status;
|
|
1727
3508
|
const needsApp = message.includes("running app");
|
|
1728
3509
|
|
|
1729
3510
|
return el("div", { class: "grimoire-error", role: "alert" }, [
|
|
@@ -1780,8 +3561,10 @@ function bindShortcut(input) {
|
|
|
1780
3561
|
function header(ctx, route, summaryRequest) {
|
|
1781
3562
|
const { el } = ctx;
|
|
1782
3563
|
const results = el("div", { class: "grimoire-results" });
|
|
3564
|
+
const brandSlot = el("div", { class: "grimoire-brand-slot" });
|
|
1783
3565
|
const active = tabOf(route);
|
|
1784
3566
|
const badges = new Map();
|
|
3567
|
+
let activeTab = null;
|
|
1785
3568
|
let token = 0;
|
|
1786
3569
|
let timer = null;
|
|
1787
3570
|
let rows = [];
|
|
@@ -1933,7 +3716,8 @@ function header(ctx, route, summaryRequest) {
|
|
|
1933
3716
|
const badge = el("span", { class: "grimoire-tab-count" });
|
|
1934
3717
|
|
|
1935
3718
|
badges.set(target, badge);
|
|
1936
|
-
|
|
3719
|
+
|
|
3720
|
+
const tab = el(
|
|
1937
3721
|
"a",
|
|
1938
3722
|
{
|
|
1939
3723
|
href: ctx.href(target),
|
|
@@ -1942,6 +3726,10 @@ function header(ctx, route, summaryRequest) {
|
|
|
1942
3726
|
},
|
|
1943
3727
|
[label, " ", badge],
|
|
1944
3728
|
);
|
|
3729
|
+
|
|
3730
|
+
if (target === active) activeTab = tab;
|
|
3731
|
+
|
|
3732
|
+
return tab;
|
|
1945
3733
|
}),
|
|
1946
3734
|
);
|
|
1947
3735
|
|
|
@@ -1959,17 +3747,30 @@ function header(ctx, route, summaryRequest) {
|
|
|
1959
3747
|
set("tasks", data.tasks ? data.tasks.open.length : undefined);
|
|
1960
3748
|
set("releases", data.releases);
|
|
1961
3749
|
set("check", data.counts ? data.counts.errors + data.counts.warnings : undefined);
|
|
3750
|
+
|
|
3751
|
+
const brand = grimoireBrand(ctx, data.host);
|
|
3752
|
+
|
|
3753
|
+
if (brand) brandSlot.replaceChildren(brand);
|
|
1962
3754
|
},
|
|
1963
3755
|
() => undefined,
|
|
1964
3756
|
);
|
|
1965
3757
|
|
|
1966
3758
|
return {
|
|
1967
3759
|
element: el("div", { class: "grimoire-header" }, [
|
|
3760
|
+
brandSlot,
|
|
1968
3761
|
nav,
|
|
1969
3762
|
el("div", { class: "grimoire-searchbox" }, [input, results]),
|
|
1970
3763
|
]),
|
|
1971
3764
|
run,
|
|
1972
3765
|
input,
|
|
3766
|
+
/** Bring the open tab into view in a scrolling tab bar (phones). */
|
|
3767
|
+
revealActive: () => {
|
|
3768
|
+
try {
|
|
3769
|
+
activeTab?.scrollIntoView?.({ inline: "center", block: "nearest" });
|
|
3770
|
+
} catch {
|
|
3771
|
+
// A host without scrollIntoView options keeps the bar where it is.
|
|
3772
|
+
}
|
|
3773
|
+
},
|
|
1973
3774
|
};
|
|
1974
3775
|
}
|
|
1975
3776
|
|
|
@@ -2000,8 +3801,22 @@ async function renderGrimoire(context) {
|
|
|
2000
3801
|
const top = header(ctx, route, summaryRequest);
|
|
2001
3802
|
const content = el("div", { class: "grimoire-body", "aria-busy": "true" });
|
|
2002
3803
|
|
|
2003
|
-
|
|
2004
|
-
|
|
3804
|
+
const loading = skeleton(ctx);
|
|
3805
|
+
|
|
3806
|
+
content.append(loading.node);
|
|
3807
|
+
top.input.disabled = true;
|
|
3808
|
+
const footer = el("footer", { class: "grimoire-footer" });
|
|
3809
|
+
|
|
3810
|
+
summaryRequest.then(
|
|
3811
|
+
(data) => {
|
|
3812
|
+
const line = grimoireAppLine(ctx, data.host);
|
|
3813
|
+
|
|
3814
|
+
if (line) footer.replaceChildren(line);
|
|
3815
|
+
},
|
|
3816
|
+
() => undefined,
|
|
3817
|
+
);
|
|
3818
|
+
root.append(el("div", { class: "grimoire-root" }, [top.element, content, footer]));
|
|
3819
|
+
top.revealActive();
|
|
2005
3820
|
|
|
2006
3821
|
const loaded = (async () => {
|
|
2007
3822
|
try {
|
|
@@ -2009,6 +3824,8 @@ async function renderGrimoire(context) {
|
|
|
2009
3824
|
} catch (error) {
|
|
2010
3825
|
content.replaceChildren(errorBox(ctx, route, error));
|
|
2011
3826
|
}
|
|
3827
|
+
loading.stop();
|
|
3828
|
+
top.input.disabled = false;
|
|
2012
3829
|
content.setAttribute("aria-busy", "false");
|
|
2013
3830
|
})();
|
|
2014
3831
|
|