cornfield 0.54.0 → 0.56.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/core/contrast.js +28 -0
- package/core/schema.js +24 -0
- package/explorer/css/page.css +0 -8
- package/explorer/css/work.css +3 -26
- package/explorer/deep-link.js +11 -24
- package/explorer/engine/layers.js +5 -2
- package/explorer/engine/map-style.js +8 -1
- package/explorer/engine/render.js +2 -1
- package/explorer/forge-panel-model.js +2 -36
- package/explorer/forge-panel.js +3 -7
- package/explorer/index.html +5 -11
- package/explorer/instance-state.js +0 -6
- package/explorer/instance.js +9 -5
- package/explorer/layer-model.js +1 -0
- package/explorer/page.js +8 -5
- package/explorer/pieces/layers.js +1 -1
- package/explorer/pieces/node-panel.js +26 -4
- package/explorer/pieces/search.js +9 -3
- package/explorer/pieces/work-agent.js +3 -2
- package/explorer/pieces/work-common.js +14 -15
- package/explorer/pieces/work-confirm.js +11 -10
- package/explorer/pieces/work-data.js +24 -31
- package/explorer/pieces/work-deploys.js +42 -41
- package/explorer/pieces/work-issues.js +32 -29
- package/explorer/pieces/work-list.js +406 -0
- package/explorer/pieces/work-markup.js +9 -15
- package/explorer/pieces/work-notes.js +0 -1
- package/explorer/pieces/work-paint.js +57 -67
- package/explorer/pieces/work-prs.js +25 -66
- package/explorer/pieces/work-runs.js +47 -57
- package/explorer/pieces/work-specs.js +19 -2
- package/explorer/pieces/work-threads.js +29 -49
- package/explorer/pieces/work.js +28 -28
- package/explorer/proposal-model.js +5 -5
- package/explorer/runs-view.js +10 -18
- package/explorer/scene.js +17 -10
- package/explorer/search-match.js +3 -2
- package/explorer/tokens.css +11 -0
- package/explorer/view.js +8 -1
- package/explorer/waiting-view.js +3 -3
- package/explorer/work-model.js +722 -0
- package/explorer/work-view.css +50 -0
- package/explorer/work-view.js +570 -0
- package/package.json +1 -1
- package/explorer/pieces/work-events.js +0 -285
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/* The Work view (explorer/work-view.js, spec 0012): the toggles at the top left of the stage (All work, Waiting on you, List), the line of what could not be read, and the node panel's work detail. */
|
|
2
|
+
.hx-work-bar { position: absolute; z-index: 4; left: var(--corn-space-4); top: var(--corn-space-4); display: flex; gap: var(--corn-space-2); }
|
|
3
|
+
.hx-work-bar { align-items: center; }
|
|
4
|
+
.hx-work-bar[hidden] { display: none; }
|
|
5
|
+
.hx-work-chip { box-sizing: border-box; min-height: 2rem; padding: 0 var(--corn-space-4); border: var(--corn-border) solid var(--corn-line); border-radius: var(--corn-radius-pill); background: var(--corn-surface-1); color: var(--corn-text-2); font-family: inherit; font-size: var(--corn-text-xs); font-weight: 600; cursor: pointer; }
|
|
6
|
+
.hx-work-chip[aria-pressed="true"], .hx-work-chip[aria-expanded="true"] { background: var(--corn-accent); border-color: var(--corn-accent); color: var(--corn-text-on-accent); }
|
|
7
|
+
.hx-work-chip[hidden] { display: none; }
|
|
8
|
+
.hx-work-chip:focus-visible { outline: var(--corn-focus-width) solid var(--corn-focus); outline-offset: var(--corn-focus-offset); }
|
|
9
|
+
.hx-work-note { position: absolute; z-index: 3; left: var(--corn-space-4); bottom: var(--corn-space-4); max-width: min(32rem, calc(100% - var(--corn-space-8))); margin: 0; padding: var(--corn-space-2) var(--corn-space-3); border-radius: var(--corn-radius); background: var(--corn-surface-1); color: var(--corn-text-2); font-size: var(--corn-text-xs); }
|
|
10
|
+
.hx-work-note[hidden] { display: none; }
|
|
11
|
+
.hx-view-badge { margin-left: var(--corn-space-2); }
|
|
12
|
+
.hx-work-links { list-style: none; margin: 0; padding: 0; }
|
|
13
|
+
.hx-work-links li { display: flex; align-items: center; gap: var(--corn-space-2); min-height: 2.25rem; border-bottom: var(--corn-border) solid var(--corn-line); }
|
|
14
|
+
.hx-work-rel { flex: none; width: 6.5rem; color: var(--corn-text-3); font-size: var(--corn-text-xs); }
|
|
15
|
+
.hx-work-dot { flex: none; width: 0.6rem; height: 0.6rem; border-radius: var(--corn-radius-sm); background: var(--corn-text-3); }
|
|
16
|
+
.hx-work-head, .hx-work-actions { display: flex; flex-direction: column; gap: var(--corn-space-2); margin: var(--corn-space-3) 0; }
|
|
17
|
+
.hx-work-pills { display: flex; flex-wrap: wrap; gap: var(--corn-space-2); margin: 0; }
|
|
18
|
+
.hx-work-actions .hx-foot-btn { align-self: flex-start; }
|
|
19
|
+
/* The lanes' titles: lines over the map, in screen space (work-view.js `paintLanes`), so they read at any zoom */
|
|
20
|
+
.hx-work-lanes { position: absolute; inset: 0; z-index: 2; overflow: hidden; pointer-events: none; }
|
|
21
|
+
.hx-work-lanes[hidden] { display: none; }
|
|
22
|
+
.hx-work-lane-title { position: absolute; display: flex; gap: var(--corn-space-2); align-items: baseline; max-width: 100%; overflow: hidden; white-space: nowrap; font-size: var(--corn-text-xs); font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--corn-text-2); }
|
|
23
|
+
.hx-work-lane-title.is-held { padding: 0 var(--corn-space-2); border-radius: var(--corn-radius-sm); background: color-mix(in srgb, var(--corn-surface-1) 85%, transparent); } /* held under the toggles over the lane's nodes: a ground of its own */
|
|
24
|
+
.hx-work-lane-title > :first-child { overflow: hidden; text-overflow: ellipsis; }
|
|
25
|
+
.hx-work-lane-count { flex: none; font-weight: 600; letter-spacing: 0; }
|
|
26
|
+
.hx-work-busy { margin-left: var(--corn-space-2); font-size: var(--corn-text-xs); color: var(--corn-text-2); }
|
|
27
|
+
.hx-work-busy[hidden] { display: none; }
|
|
28
|
+
/* While the first answer is on its way: the lanes, empty, with the words; nothing on the page waits for it */
|
|
29
|
+
.hx-work-loading { position: absolute; z-index: 2; inset: 0; pointer-events: none; }
|
|
30
|
+
.hx-work-loading[hidden] { display: none; }
|
|
31
|
+
.hx-work-skeleton { position: absolute; left: var(--corn-space-4); right: var(--corn-space-4); top: 3.5rem; bottom: var(--corn-space-6); display: grid; grid-template-columns: repeat(4, 1fr) 1.6fr; gap: var(--corn-space-3); }
|
|
32
|
+
.hx-work-skel-lane { display: flex; flex-direction: column; gap: var(--corn-space-4); padding: var(--corn-space-3); border: var(--corn-border) solid var(--corn-line); border-radius: var(--corn-radius); background: color-mix(in srgb, var(--corn-surface-1) 55%, transparent); }
|
|
33
|
+
.hx-work-skel-lane .hx-work-lane-title { position: static; }
|
|
34
|
+
.hx-work-skel-lane i { display: block; height: 2.25rem; border-radius: var(--corn-radius-sm); background: var(--corn-surface-3); opacity: 0.7; animation: hx-work-pulse 1.6s ease-in-out infinite; }
|
|
35
|
+
.hx-work-skel-lane i:nth-of-type(2) { animation-delay: 0.2s; width: 80%; }
|
|
36
|
+
.hx-work-skel-lane i:nth-of-type(3) { animation-delay: 0.4s; width: 65%; }
|
|
37
|
+
.hx-work-skel-lane i:nth-of-type(4) { animation-delay: 0.6s; width: 90%; }
|
|
38
|
+
@keyframes hx-work-pulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 0.8; } }
|
|
39
|
+
@media (prefers-reduced-motion: reduce) { .hx-work-skel-lane i { animation: none; opacity: 0.6; } }
|
|
40
|
+
.hx-work-loading-text { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(26rem, calc(100% - var(--corn-space-8))); margin: 0; padding: var(--corn-space-3) var(--corn-space-4); border-radius: var(--corn-radius); border: var(--corn-border) solid var(--corn-line); background: var(--corn-surface-1); color: var(--corn-text); font-size: var(--corn-text-sm); text-align: center; box-shadow: var(--corn-shadow); }
|
|
41
|
+
@container corn-box (max-width: 767px) {
|
|
42
|
+
/* The Layers chip and Fit sit on the map's top row (layers.css, header.css); the toggles go on the row under them, and the lanes run top to bottom */
|
|
43
|
+
.hx-work-bar { top: calc(var(--corn-space-4) + var(--hx-control-h) + var(--corn-space-3)); }
|
|
44
|
+
.hx-work-note { bottom: var(--corn-space-4); }
|
|
45
|
+
.hx-stage.is-work .hx-hint { display: none; } /* the toggles' row is where the hint would sit */
|
|
46
|
+
.hx-work-skeleton { grid-template-columns: 1fr; grid-auto-rows: min-content; top: calc(var(--corn-space-4) + var(--hx-control-h) * 2 + var(--corn-space-6)); overflow: hidden; }
|
|
47
|
+
.hx-work-skel-lane i:nth-of-type(n + 3) { display: none; }
|
|
48
|
+
}
|
|
49
|
+
/* The Layers menu in the Work view lists the Work view's rows; the map's keys (its kinds of line, the cloud's, the runs' and the proposal marks') are about the map */
|
|
50
|
+
body:has(.hx-stage.is-work) .hx-layers :is([data-corn="legend-key"], [data-corn="menu-section"]) { display: none; }
|
|
@@ -0,0 +1,570 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module explorer/work-view
|
|
3
|
+
*
|
|
4
|
+
* The Work view in cornfield's page (spec 0012 D1 to D5 and D8); its pure half is work-model.js, the server's half `GET /api/forge/work-graph`
|
|
5
|
+
* (server/work-graph.js). Page code, as house.js is for the House view: it reads `location` and listens on `document`.
|
|
6
|
+
*
|
|
7
|
+
* initWorkView({ offered }) once, after the config: the Work button of the view switch (shown when the config names a forge), the toggle, the clicks
|
|
8
|
+
* openWork({ select }) opens the view (the camera fits), asks the server for the work graph (once; again on Refresh and every minute while it is open),
|
|
9
|
+
* and selects a node of it when `select` names one; closeWork() goes back to the map
|
|
10
|
+
* followWorkAddress() `?view=work`, `?pr=`, `?issue=`, `?run=`, `?thread=` and `?spec=` (work-model.js `workAddress`): the node, or for work older than the graph's
|
|
11
|
+
* 14 days the Work list and the node panel (pieces/work-list.js `showRef`)
|
|
12
|
+
*
|
|
13
|
+
* What it puts on the page: the view switch's Work button, with "waiting on you" as its badge, the toggles at the top left of the stage ("All work", "Waiting on you" and
|
|
14
|
+
* **List**, which opens the Work list (pieces/work-list.js) where the side panel sat), the lanes' titles in screen space (the map draws the lanes' panels), the words
|
|
15
|
+
* and the empty lanes shown at once while the first answer is on its way (the page stays usable: the views, the Layers menu, search), "Updating…" while a refresh
|
|
16
|
+
* is (the last answer stays on the map, and a refresh that fails keeps it and says so), the map's own card when the answer is refused (signed out, not a maintainer,
|
|
17
|
+
* offline: pieces/status.js), and a quiet line naming what the server could not read (`problems`). It answers the node panel's `work:panel` ask with what a node says in
|
|
18
|
+
* the Work view (the Work piece draws the actions into it), the Work list's `work:pick` ask by selecting that row's node, and holds the keys of the view: N and P step through
|
|
19
|
+
* the lanes, an arrow goes to the nearest node that way. Every request goes through `credentialed`;
|
|
20
|
+
* every word that comes from the forge is escaped or set as text, every link goes through `safeUrl` (work-model.js).
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import { state, pageInstance } from './state.js';
|
|
24
|
+
import { setView } from './view.js';
|
|
25
|
+
import { closeDrawer } from './panels.js';
|
|
26
|
+
import { announce } from './engine/keyboard.js';
|
|
27
|
+
import { credentialed } from './engine/connection.js';
|
|
28
|
+
import { selectNode } from './engine/selection.js';
|
|
29
|
+
import { closeProposal, openProposal } from './engine/proposal.js';
|
|
30
|
+
import { signInUrl } from './engine/source.js';
|
|
31
|
+
import { mapStyleOf, workToken, workEdgeToken } from './engine/map-style.js';
|
|
32
|
+
import { t } from './engine/strings.js';
|
|
33
|
+
import { mount as mountStatus } from './pieces/status.js';
|
|
34
|
+
import { fitGraphToViewport, fitPadding, onPaint, render } from './render.js';
|
|
35
|
+
import { isPhone } from './sheets.js';
|
|
36
|
+
import { WORK_KINDS, WORK_THEMES, WORK_EDGES } from '../core/schema.js';
|
|
37
|
+
import { workButtonName } from './waiting-model.js';
|
|
38
|
+
import { stepFrom } from './keyboard-model.js';
|
|
39
|
+
import { RUNS_POLL_MS } from './pieces/work-common.js';
|
|
40
|
+
import { showWorkRef, openForge, closeForge } from './forge-panel.js';
|
|
41
|
+
import {
|
|
42
|
+
CODE_LAYER, DRAFT_LAYER, KIND_WORDS, applyFilters, arrowTarget, landingWords, applyWorkLayout, codePanelHtml, layerRowsOf, newWorkState, nodeForAddress, openedWords, panelOf, setWorkGraph, showWork, touchedBy, workAddress, workPanelHtml,
|
|
43
|
+
} from './work-model.js';
|
|
44
|
+
|
|
45
|
+
const GRAPH_URL = '/api/forge/work-graph';
|
|
46
|
+
const $ = (id) => document.getElementById(id);
|
|
47
|
+
|
|
48
|
+
let wired = false;
|
|
49
|
+
let offered = false;
|
|
50
|
+
let els = null; // { stage, bar, all, waiting, busy, note, lanes, loading }
|
|
51
|
+
let laneEls = []; // the lanes' titles on the stage, in screen space: [{ el, name, count }]
|
|
52
|
+
let laneKey = null; // the lanes they were made for
|
|
53
|
+
let offPaint = null;
|
|
54
|
+
let card = null; // the map's own card (pieces/status.js)
|
|
55
|
+
let timer = 0;
|
|
56
|
+
let seq = 0; // the answer that is waited for: an older one is dropped
|
|
57
|
+
let wasOn = false;
|
|
58
|
+
|
|
59
|
+
const inst = () => pageInstance();
|
|
60
|
+
const work = () => state.work || (state.work = newWorkState());
|
|
61
|
+
const on = () => state.view === 'work';
|
|
62
|
+
|
|
63
|
+
/** Starts the Work view's machinery. Nothing is asked of the server until the view opens. */
|
|
64
|
+
export function initWorkView(opts = {}) {
|
|
65
|
+
offered = opts.offered === true;
|
|
66
|
+
const btn = $('preset-work-btn');
|
|
67
|
+
if (btn) btn.hidden = !offered;
|
|
68
|
+
work();
|
|
69
|
+
mount();
|
|
70
|
+
paintEdgeColors();
|
|
71
|
+
if (!wired) {
|
|
72
|
+
wired = true;
|
|
73
|
+
const i = inst();
|
|
74
|
+
document.addEventListener('click', onClick);
|
|
75
|
+
document.addEventListener('keydown', onKey, true); // before the map's own keys: in this view N and P step through the lanes, and an arrow goes to the nearest node that way
|
|
76
|
+
i.on('view', syncWork);
|
|
77
|
+
i.on('layers', refilter);
|
|
78
|
+
i.on('work:open', ({ id }) => openWork({ select: id }));
|
|
79
|
+
i.on('search:more', () => (work().status === 'ok' && !on() ? work().nodes.filter((n) => n.work) : null));
|
|
80
|
+
i.on('work:waiting', ({ total }) => paintBadge(total));
|
|
81
|
+
i.on('work:available', ({ on: available }) => paintList(available));
|
|
82
|
+
i.on('work:panel', (node) => panelFor(node));
|
|
83
|
+
i.on('work:pick', (ref) => pickRef(ref));
|
|
84
|
+
mapStyleOf(i).onChange(() => { paintEdgeColors(); if (on()) { state.workRows = layerRowsOf(work().nodes).map(themed); i.emit('layers:redraw'); i.touchScene(); render(); } });
|
|
85
|
+
}
|
|
86
|
+
syncWork();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** The List toggle is shown while the Work piece is on (a forge in the config and somebody signed in); the piece says its own `aria-expanded` */
|
|
90
|
+
function paintList(available) {
|
|
91
|
+
if (els && els.list) els.list.hidden = !available;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** The colours the theme gives the Work view's lines (`--corn-work-edge-<name>`), for the scene: a name it does not set is drawn in its default (work-model.js `workEdge`) */
|
|
95
|
+
function paintEdgeColors() {
|
|
96
|
+
const values = mapStyleOf(inst()).get().values;
|
|
97
|
+
const colors = {};
|
|
98
|
+
for (const name of WORK_EDGES) if (values[workEdgeToken(name)]) colors[name] = values[workEdgeToken(name)];
|
|
99
|
+
state.workEdgeColors = colors;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** The Work button's badge and its spoken name: "Work, 3 waiting on you" (the Work panel's own words: waiting-model.js) */
|
|
103
|
+
function paintBadge(total) {
|
|
104
|
+
const btn = $('preset-work-btn');
|
|
105
|
+
if (!btn) return;
|
|
106
|
+
const n = Number.isFinite(total) ? total : 0;
|
|
107
|
+
const badge = btn.querySelector('[data-corn="waiting-badge"]');
|
|
108
|
+
if (badge) { badge.textContent = n ? String(n) : ''; badge.hidden = !n; }
|
|
109
|
+
btn.setAttribute('aria-label', workButtonName(t(inst(), 'issuesAndPrs'), n, (key) => t(inst(), key)));
|
|
110
|
+
if (els) paintBar();
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// ---------------------------------------------------------------------------
|
|
114
|
+
// The page's parts
|
|
115
|
+
// ---------------------------------------------------------------------------
|
|
116
|
+
function mount() {
|
|
117
|
+
const stage = state.canvas ? state.canvas.parentElement : null;
|
|
118
|
+
if (!stage || (els && els.stage === stage && stage.contains(els.bar))) return;
|
|
119
|
+
const bar = document.createElement('div');
|
|
120
|
+
bar.className = 'hx-work-bar';
|
|
121
|
+
bar.dataset.corn = 'work-bar';
|
|
122
|
+
bar.setAttribute('role', 'group');
|
|
123
|
+
bar.setAttribute('aria-label', 'Show');
|
|
124
|
+
bar.hidden = true;
|
|
125
|
+
bar.innerHTML = '<button type="button" class="hx-work-chip" data-corn="work-chip" data-corn-kind="quiet" data-work-show="all" aria-pressed="true">All work</button>'
|
|
126
|
+
+ '<button type="button" class="hx-work-chip" data-corn="work-chip" data-corn-kind="quiet" data-work-show="waiting" aria-pressed="false">Waiting on you</button>'
|
|
127
|
+
+ '<button type="button" class="hx-work-chip" data-corn="work-chip" data-corn-kind="quiet" data-action="toggle-forge" aria-expanded="false" aria-controls="forge-panel" aria-label="Work list" title="The lists of issues, pull requests, proposals, threads, runs and deploys" hidden>List</button>'
|
|
128
|
+
+ '<span class="hx-work-busy" hidden>Updating…</span>';
|
|
129
|
+
const note = document.createElement('p');
|
|
130
|
+
note.className = 'hx-work-note';
|
|
131
|
+
note.dataset.corn = 'work-note';
|
|
132
|
+
note.hidden = true;
|
|
133
|
+
// The lanes' titles: lines of the page over the map, in screen space, so they read at any zoom (the map draws the lanes' panels)
|
|
134
|
+
const lanes = document.createElement('div');
|
|
135
|
+
lanes.className = 'hx-work-lanes';
|
|
136
|
+
lanes.dataset.corn = 'work-lanes';
|
|
137
|
+
lanes.setAttribute('aria-hidden', 'true');
|
|
138
|
+
lanes.hidden = true;
|
|
139
|
+
// What the page shows while the first answer is on its way (a big repository takes seconds): the lanes, empty, and the words; the page stays usable under it
|
|
140
|
+
const loading = document.createElement('div');
|
|
141
|
+
loading.className = 'hx-work-loading';
|
|
142
|
+
loading.dataset.corn = 'work-loading';
|
|
143
|
+
loading.hidden = true;
|
|
144
|
+
loading.innerHTML = `<div class="hx-work-skeleton" aria-hidden="true">${['Talk', 'Decide', 'Build', 'Ship', 'Code it touches'].map((name) => `<div class="hx-work-skel-lane"><span class="hx-work-lane-title">${name}</span><i></i><i></i><i></i><i></i></div>`).join('')}</div>`
|
|
145
|
+
+ '<p class="hx-work-loading-text" role="status">Reading the work from the forge. A big repository can take several seconds the first time; the page works meanwhile.</p>';
|
|
146
|
+
stage.append(lanes, loading, bar, note);
|
|
147
|
+
els = { stage, bar, all: bar.children[0], waiting: bar.children[1], list: bar.children[2], busy: bar.children[3], note, lanes, loading };
|
|
148
|
+
paintList(!!inst().ask('work:on')); // the List toggle is there while the Work piece is on: a signed-in maintainer of a forge
|
|
149
|
+
if (offPaint) offPaint();
|
|
150
|
+
offPaint = onPaint(paintLanes);
|
|
151
|
+
watchSize(stage);
|
|
152
|
+
card = mountStatus(stage, inst(), { follow: false, onRetry: () => load({ again: true }), focusMap: () => { if (state.canvas) state.canvas.focus(); } });
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/** The map's box changed (a window resized, a phone turned): the lanes are laid out again for it, and fitted, as they were when the answer came */
|
|
156
|
+
let sizeKey = '';
|
|
157
|
+
let sizeTimer = 0;
|
|
158
|
+
function watchSize(stage) {
|
|
159
|
+
const Observer = typeof ResizeObserver === 'undefined' ? null : ResizeObserver;
|
|
160
|
+
if (!Observer) return;
|
|
161
|
+
sizeKey = `${stage.clientWidth}x${stage.clientHeight}`;
|
|
162
|
+
new Observer(() => {
|
|
163
|
+
const key = `${stage.clientWidth}x${stage.clientHeight}`;
|
|
164
|
+
if (key === sizeKey) return;
|
|
165
|
+
sizeKey = key;
|
|
166
|
+
clearTimeout(sizeTimer);
|
|
167
|
+
sizeTimer = setTimeout(() => {
|
|
168
|
+
if (!on() || work().status !== 'ok') return;
|
|
169
|
+
applyWorkLayout(state, { phone: isPhone() });
|
|
170
|
+
inst().touchScene();
|
|
171
|
+
fitGraphToViewport(fitPadding());
|
|
172
|
+
render();
|
|
173
|
+
}, 150);
|
|
174
|
+
}).observe(stage);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** The lanes' titles, over the map in screen space: centred over their lane and held under the toggles while the lane is in view (a phone's: at the lane's top left) */
|
|
178
|
+
function paintLanes(scene, camera) {
|
|
179
|
+
if (!els) return;
|
|
180
|
+
const w = work();
|
|
181
|
+
const show = on() && w.status === 'ok' && w.lanes.length > 0;
|
|
182
|
+
els.lanes.hidden = !show;
|
|
183
|
+
if (!show) return;
|
|
184
|
+
if (laneKey !== w.lanes) {
|
|
185
|
+
laneKey = w.lanes;
|
|
186
|
+
els.lanes.textContent = '';
|
|
187
|
+
laneEls = w.lanes.map((l) => {
|
|
188
|
+
const el = document.createElement('div');
|
|
189
|
+
el.className = 'hx-work-lane-title';
|
|
190
|
+
const name = document.createElement('span');
|
|
191
|
+
name.textContent = l.name;
|
|
192
|
+
const count = document.createElement('span');
|
|
193
|
+
count.className = 'hx-work-lane-count';
|
|
194
|
+
count.textContent = String(l.count);
|
|
195
|
+
el.append(name, count);
|
|
196
|
+
els.lanes.append(el);
|
|
197
|
+
return { el, lane: l };
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
const phone = isPhone();
|
|
201
|
+
const top = phone ? STICKY_TOP_PHONE : STICKY_TOP;
|
|
202
|
+
for (const { el, lane } of laneEls) {
|
|
203
|
+
const left = camera.x + lane.x * camera.zoom;
|
|
204
|
+
const right = left + lane.w * camera.zoom;
|
|
205
|
+
const topPx = camera.y + lane.y * camera.zoom;
|
|
206
|
+
const bottomPx = topPx + lane.h * camera.zoom;
|
|
207
|
+
// a phone's title stays at its lane's top and goes when that is under the toggles; a desktop's is held under them while the lane is in view
|
|
208
|
+
const seen = right > 0 && left < els.stage.clientWidth && bottomPx > 40 && topPx < els.stage.clientHeight && !(phone && topPx + 8 < top);
|
|
209
|
+
el.style.visibility = seen ? 'visible' : 'hidden';
|
|
210
|
+
if (!seen) continue;
|
|
211
|
+
const y = phone ? topPx + 8 : Math.min(Math.max(topPx + 10, top), bottomPx - 44);
|
|
212
|
+
el.classList.toggle('is-held', !phone && y > topPx + 12);
|
|
213
|
+
el.style.maxWidth = `${Math.max(40, right - left - 12)}px`;
|
|
214
|
+
el.style.top = `${Math.round(y)}px`;
|
|
215
|
+
if (phone) { el.style.left = `${Math.round(Math.max(left, 0) + 10)}px`; el.style.transform = 'none'; } else { el.style.left = `${Math.round((left + right) / 2)}px`; el.style.transform = 'translateX(-50%)'; }
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
/** The line the lanes' titles hold under, in px from the top of the stage: below the toggles (a phone's are on a second row, under the Layers chip) */
|
|
219
|
+
const STICKY_TOP = 58;
|
|
220
|
+
const STICKY_TOP_PHONE = 108;
|
|
221
|
+
|
|
222
|
+
function paintBar() {
|
|
223
|
+
if (!els) return;
|
|
224
|
+
const w = work();
|
|
225
|
+
const n = w.counts.waiting;
|
|
226
|
+
els.bar.hidden = !on();
|
|
227
|
+
els.all.setAttribute('aria-pressed', String(!w.waiting));
|
|
228
|
+
els.waiting.setAttribute('aria-pressed', String(w.waiting));
|
|
229
|
+
els.waiting.textContent = `Waiting on you · ${n}`;
|
|
230
|
+
els.busy.hidden = !(on() && w.status === 'ok' && w.updating);
|
|
231
|
+
els.loading.hidden = !(on() && w.status === 'loading');
|
|
232
|
+
const lines = [...(w.stale ? [w.stale] : []), ...(w.lastError ? [w.lastError] : []), ...w.problems.map((p) => p.text)];
|
|
233
|
+
els.note.hidden = !on() || !lines.length;
|
|
234
|
+
els.note.textContent = lines.length ? lines.slice(0, 2).join(' ') + (lines.length > 2 ? ` and ${lines.length - 2} more.` : '') : '';
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/** The view opened or closed: the button, the bar, the stage; the map's own layers are back when it closed (work-model.js `leaveWork`) */
|
|
238
|
+
function syncWork() {
|
|
239
|
+
const open = on();
|
|
240
|
+
const btn = $('preset-work-btn');
|
|
241
|
+
if (btn) btn.setAttribute('aria-pressed', String(open));
|
|
242
|
+
const stage = state.canvas ? state.canvas.parentElement : null;
|
|
243
|
+
if (stage) stage.classList.toggle('is-work', open);
|
|
244
|
+
paintBar();
|
|
245
|
+
if (open !== wasOn) {
|
|
246
|
+
if (open) { paintBadge(work().counts.waiting); inst().emit('layers:redraw'); } // the Layers menu lists the Work view's rows from the first moment, the answer here or not
|
|
247
|
+
wasOn = open;
|
|
248
|
+
clearTimeout(timer);
|
|
249
|
+
if (open) timer = setTimeout(poll, RUNS_POLL_MS);
|
|
250
|
+
else {
|
|
251
|
+
if (card) card.clear();
|
|
252
|
+
closeForge({ restoreFocus: false }); // the list is the Work view's
|
|
253
|
+
if (!state.selectedNode) inst().emit('node:close'); // a piece of work the node panel showed from the lists, with nothing selected
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function poll() {
|
|
259
|
+
clearTimeout(timer);
|
|
260
|
+
if (!on()) return;
|
|
261
|
+
if (document.visibilityState !== 'hidden') load({ again: true, quiet: true });
|
|
262
|
+
timer = setTimeout(poll, RUNS_POLL_MS);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// ---------------------------------------------------------------------------
|
|
266
|
+
// Opening, and the answer
|
|
267
|
+
// ---------------------------------------------------------------------------
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Opens the Work view, asks for the work graph (once per opening; again on Refresh and on the poll), and selects `select` (a node id) when the answer has it.
|
|
271
|
+
* @param {{ select?: string | null, ask?: { kind: string, key: string } | null }} [opts]
|
|
272
|
+
* @returns {Promise<boolean>} whether the answer arrived
|
|
273
|
+
*/
|
|
274
|
+
export async function openWork({ select = null, ask = null } = {}) {
|
|
275
|
+
const i = inst();
|
|
276
|
+
if (!on()) {
|
|
277
|
+
if (state.proposal) closeProposal(i); // a review holds the map: it ends before the view of work begins
|
|
278
|
+
closeDrawer();
|
|
279
|
+
setView('work');
|
|
280
|
+
}
|
|
281
|
+
syncWork();
|
|
282
|
+
const ok = await load({ select, ask });
|
|
283
|
+
return ok;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/** Back to the map (the Map button's way) */
|
|
287
|
+
export function closeWork() {
|
|
288
|
+
if (!on()) return;
|
|
289
|
+
closeDrawer();
|
|
290
|
+
setView('orbit');
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
async function load({ select = null, ask = null, again = false, quiet = false } = {}) {
|
|
294
|
+
const i = inst();
|
|
295
|
+
const mine = ++seq;
|
|
296
|
+
const w = work();
|
|
297
|
+
const have = w.status === 'ok';
|
|
298
|
+
if (!have) {
|
|
299
|
+
// The first answer: the page says so at once (the lanes, empty, and the words) and stays usable; the answer may take seconds on a big repository
|
|
300
|
+
w.status = 'loading';
|
|
301
|
+
card.clear();
|
|
302
|
+
paintBar();
|
|
303
|
+
announce(i, 'Work: reading the work from the forge.');
|
|
304
|
+
} else if (!quiet) { w.updating = true; paintBar(); } // a refresh keeps the last answer on the map until the new one is here
|
|
305
|
+
let res;
|
|
306
|
+
try {
|
|
307
|
+
res = await credentialed(i)(GRAPH_URL, { headers: { accept: 'application/json', ...(again && !quiet ? { 'cache-control': 'no-cache' } : {}) } }); // Refresh asks the forge again
|
|
308
|
+
} catch {
|
|
309
|
+
if (mine !== seq) return false;
|
|
310
|
+
return refuse(i.offline() ? { state: 'offline' } : { state: 'server', message: 'cornfield could not be reached.' }, quiet);
|
|
311
|
+
}
|
|
312
|
+
if (mine !== seq) return false;
|
|
313
|
+
if (res.status === 401 || res.status === 403) return refuse({ state: 'sign-in', status: res.status, signIn: signInUrl(location.origin, location.href) }, quiet);
|
|
314
|
+
let body = null;
|
|
315
|
+
try { body = await res.json(); } catch { body = null; }
|
|
316
|
+
if (mine !== seq) return false;
|
|
317
|
+
if (!res.ok || !body || body.ok === false || !Array.isArray(body.nodes)) {
|
|
318
|
+
const words = res.status === 404 ? 'This server does not answer for the map of work yet: update cornfield.' : body && typeof body.error === 'string' ? body.error.slice(0, 200) : `The server answered ${res.status}.`;
|
|
319
|
+
return refuse({ state: 'server', message: words }, quiet);
|
|
320
|
+
}
|
|
321
|
+
return arrive(body, { select, ask, quiet });
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* The answer could not be had. With nothing read yet, it is said in the map's own card. With an answer on the map, the map keeps it (a refresh that fails does not wipe
|
|
326
|
+
* what is drawn): the line under the toggles says what failed, except for a sign-in that ended, which the card says over the map.
|
|
327
|
+
*/
|
|
328
|
+
function refuse(detail, quiet) {
|
|
329
|
+
const w = work();
|
|
330
|
+
w.updating = false;
|
|
331
|
+
if (w.status === 'ok' && detail.state !== 'sign-in') {
|
|
332
|
+
if (!quiet) { w.lastError = `Could not update the work: ${detail.state === 'offline' ? 'you are offline' : detail.message || 'it could not be read'}. This is what was read earlier.`; announce(inst(), 'Work: it could not be updated. Showing what was read earlier.'); }
|
|
333
|
+
paintBar();
|
|
334
|
+
return false;
|
|
335
|
+
}
|
|
336
|
+
if (quiet && w.status === 'ok') return false;
|
|
337
|
+
const again = quiet && w.status === detail.state; // the minute's poll found the same refusal: the card stays, and nothing is said again
|
|
338
|
+
w.status = detail.state;
|
|
339
|
+
w.nodes = [];
|
|
340
|
+
w.edges = [];
|
|
341
|
+
w.counts = { work: 0, code: 0, waiting: 0 };
|
|
342
|
+
w.problems = [];
|
|
343
|
+
w.stale = '';
|
|
344
|
+
w.lastError = '';
|
|
345
|
+
if (on()) { showWork(state); applyWorkLayout(state, { phone: isPhone() }); inst().touchScene(); inst().emit('layers:redraw'); render(); }
|
|
346
|
+
card.show(detail);
|
|
347
|
+
paintBar();
|
|
348
|
+
paintBadge(0);
|
|
349
|
+
if (!again) announce(inst(), `Work: ${detail.state === 'sign-in' ? (detail.status === 403 ? 'this map is for the maintainers.' : 'sign in to see the work.') : detail.state === 'offline' ? 'you are offline.' : 'it could not be read.'}`);
|
|
350
|
+
return false;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
function arrive(body, { select, ask, quiet }) {
|
|
354
|
+
const i = inst();
|
|
355
|
+
const w = work();
|
|
356
|
+
const first = w.status !== 'ok';
|
|
357
|
+
const before = state.selectedNode ? state.selectedNode.id : null;
|
|
358
|
+
const base = state.baseNodes && state.baseNodes.length ? state.baseNodes : (w.saved ? w.saved.nodes : state.nodes);
|
|
359
|
+
setWorkGraph(state, body, base);
|
|
360
|
+
w.status = 'ok';
|
|
361
|
+
w.updating = false;
|
|
362
|
+
w.lastError = '';
|
|
363
|
+
w.stale = typeof body.stale === 'string' ? body.stale.slice(0, 200) : '';
|
|
364
|
+
card.clear();
|
|
365
|
+
if (on()) {
|
|
366
|
+
showWork(state);
|
|
367
|
+
applyWorkLayout(state, { phone: isPhone() });
|
|
368
|
+
state.workRows = layerRowsOf(w.nodes).map(themed);
|
|
369
|
+
i.touchScene();
|
|
370
|
+
i.emit('layers:redraw');
|
|
371
|
+
if (first || !quiet) fitGraphToViewport(fitPadding()); // the lanes under the toggles, the names at the edge on screen too (work-model.js `layoutWork`)
|
|
372
|
+
render();
|
|
373
|
+
if (before && !state.selectedNode) i.emit('node:close');
|
|
374
|
+
}
|
|
375
|
+
paintBar();
|
|
376
|
+
paintBadge(w.counts.waiting);
|
|
377
|
+
// One sentence: the live region says only the last thing it is given, so what the view opened on and the node an address asked for are said together
|
|
378
|
+
const opened = first || !quiet ? openedWords(w.counts) : '';
|
|
379
|
+
const id = select || nodeForAddress(ask, w.nodes);
|
|
380
|
+
if (id && pick(id)) {
|
|
381
|
+
const shown = shownInOrder();
|
|
382
|
+
const node = state.selectedNode;
|
|
383
|
+
announce(i, `${opened} ${landingWords(node, shown.indexOf(node), shown.length)}`.trim());
|
|
384
|
+
} else if (ask && ask.kind) {
|
|
385
|
+
// Work older than the graph's window (a link posted in chat weeks ago) is in the Work list: the list opens on its tab and the node panel shows it, as a row of the list does
|
|
386
|
+
if (ask.bad) announce(i, `${ask.bad} ${opened}`.trim());
|
|
387
|
+
else {
|
|
388
|
+
announce(i, `${KIND_WORDS[ask.kind]} ${ask.key} is not in the work drawn here: the Work list looks for it. ${opened}`.trim());
|
|
389
|
+
openForge({ tab: LIST_TAB[ask.kind], quiet: true }); // what the node panel shows is said, not the list's count
|
|
390
|
+
showWorkRef(ask.kind, ask.key).catch(() => {});
|
|
391
|
+
}
|
|
392
|
+
} else if (opened) announce(i, opened);
|
|
393
|
+
return true;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/** The Work list's tab for a kind of work (its names are the tabs': pieces/work-common.js TABS) */
|
|
397
|
+
const LIST_TAB = Object.freeze({ pull: 'pulls', issue: 'issues', thread: 'threads', run: 'work', deploy: 'deploys', proposal: 'specs' });
|
|
398
|
+
|
|
399
|
+
/** The nodes N and P step through, in the lanes' order: what is shown */
|
|
400
|
+
const shownInOrder = () => work().order.map((id) => state.nodes.find((n) => n.id === id)).filter((n) => n && !n.hidden);
|
|
401
|
+
|
|
402
|
+
/** The row's dot is the colour the map draws the kind in, the theme's token when it sets one */
|
|
403
|
+
function themed(row) {
|
|
404
|
+
const kind = WORK_KINDS.find((k) => `work-${k}` === row.key);
|
|
405
|
+
const values = mapStyleOf(inst()).get().values;
|
|
406
|
+
return kind && values[workToken(kind)] ? { ...row, color: values[workToken(kind)] } : row;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/** A layer went on or off: what is hidden is worked out again, the lanes are laid out for what is shown, and the camera fits them */
|
|
410
|
+
function refilter() {
|
|
411
|
+
if (!on()) return;
|
|
412
|
+
const w = work();
|
|
413
|
+
applyFilters(w.nodes, w.edges, { layers: w.layers, waiting: w.waiting });
|
|
414
|
+
const sel = state.selectedNode;
|
|
415
|
+
applyWorkLayout(state, { phone: isPhone() });
|
|
416
|
+
state.workRows = layerRowsOf(w.nodes).map(themed);
|
|
417
|
+
inst().touchScene();
|
|
418
|
+
if (sel && sel.hidden) inst().emit('node:close');
|
|
419
|
+
fitGraphToViewport(fitPadding());
|
|
420
|
+
render();
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/** Selects a node of the view by id: the panel opens, the camera follows (as a search's choice does) */
|
|
424
|
+
export function pick(id, { frame = true, source = 'link' } = {}) {
|
|
425
|
+
const node = state.nodes.find((n) => n.id === id);
|
|
426
|
+
if (!node) return false;
|
|
427
|
+
if (node.hidden) { work().layers[node.draft ? DRAFT_LAYER : node.work ? `work-${node.work}` : CODE_LAYER] = true; refilter(); }
|
|
428
|
+
selectNode(inst(), node, { frame, source });
|
|
429
|
+
return true;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/** "Waiting on you" on or off: everything that does not wait is dimmed (spec 0012 D3) */
|
|
433
|
+
function setWaiting(on_) {
|
|
434
|
+
const w = work();
|
|
435
|
+
if (w.waiting === on_) return;
|
|
436
|
+
w.waiting = on_;
|
|
437
|
+
applyFilters(w.nodes, w.edges, { layers: w.layers, waiting: w.waiting });
|
|
438
|
+
inst().touchScene();
|
|
439
|
+
paintBar();
|
|
440
|
+
render();
|
|
441
|
+
announce(inst(), on_ ? `Showing what waits on you: ${w.counts.waiting}.` : 'Showing all work.');
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
// ---------------------------------------------------------------------------
|
|
445
|
+
// The node panel's words for a node
|
|
446
|
+
// ---------------------------------------------------------------------------
|
|
447
|
+
/** The kind's colour as the map draws it: the theme's token, else the default (the style goes on through `data-style`, which a host's CSP allows) */
|
|
448
|
+
const colorOf = (kind) => { const v = mapStyleOf(inst()).get().values[workToken(kind)]; return /^#[0-9a-f]{3,8}$/i.test(v || '') ? v : WORK_THEMES[kind] ? WORK_THEMES[kind].color : ''; };
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* What the node panel shows for a node (`work:panel`): a piece of work, replaced (the Work piece draws its actions into it: pieces/work-paint.js `paintDetail`); a node of code in
|
|
452
|
+
* the Work view, with the work that touches it first (work-model.js builds the markup). A piece of work the graph does not hold (`old`, shown from the Work list or a link) is
|
|
453
|
+
* shown the same way in any view.
|
|
454
|
+
*/
|
|
455
|
+
function panelFor(node) {
|
|
456
|
+
if (!node) return undefined;
|
|
457
|
+
const w = work();
|
|
458
|
+
if (node.work && (on() || node.old)) {
|
|
459
|
+
const p = node.old ? panelOf(node, [], []) : panelOf(node, w.nodes, w.edges);
|
|
460
|
+
return { replace: true, badge: p.kind, title: p.title, html: workPanelHtml(p, node, { color: colorOf }) };
|
|
461
|
+
}
|
|
462
|
+
return on() ? { replace: false, html: codePanelHtml(node, touchedBy(node, w.nodes, w.edges), { color: colorOf }) } : undefined;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
/** A row of the Work list (or a link) names a piece of work: its node is selected on the map, with the camera on it, and the live region says where it is; false when the view does not draw it */
|
|
466
|
+
function pickRef(ref) {
|
|
467
|
+
if (!on() || work().status !== 'ok') return false;
|
|
468
|
+
const id = nodeForAddress(ref, work().nodes);
|
|
469
|
+
if (!id || !pick(id, { frame: true, source: 'link' })) return false;
|
|
470
|
+
const shown = shownInOrder();
|
|
471
|
+
const node = state.selectedNode;
|
|
472
|
+
if (node) announce(inst(), landingWords(node, shown.indexOf(node), shown.length));
|
|
473
|
+
return true;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
// ---------------------------------------------------------------------------
|
|
477
|
+
// Keys (the map's own are for the other views: Shift and an arrow still pan, the rest are the map's)
|
|
478
|
+
// ---------------------------------------------------------------------------
|
|
479
|
+
function onKey(e) {
|
|
480
|
+
if (!on() || e.defaultPrevented || e.ctrlKey || e.metaKey || e.altKey || !state.canvas || e.target !== state.canvas) return;
|
|
481
|
+
const shown = shownInOrder();
|
|
482
|
+
if (!shown.length) return;
|
|
483
|
+
const from = state.selectedNode;
|
|
484
|
+
let to = null;
|
|
485
|
+
if (e.key === 'n' || e.key === 'N' || e.key === ']') to = stepFrom(shown, from && from.id, 1);
|
|
486
|
+
else if (e.key === 'p' || e.key === 'P' || e.key === '[') to = stepFrom(shown, from && from.id, -1);
|
|
487
|
+
else if (e.key.startsWith('Arrow') && !e.shiftKey) to = from ? arrowTarget(state.nodes, from, e.key) : shown[0];
|
|
488
|
+
else return;
|
|
489
|
+
e.preventDefault();
|
|
490
|
+
e.stopImmediatePropagation();
|
|
491
|
+
if (!to) { announce(inst(), 'No node that way.'); return; }
|
|
492
|
+
selectNode(inst(), to, { frame: true, source: 'keyboard' });
|
|
493
|
+
announce(inst(), landingWords(to, shown.indexOf(to), shown.length));
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
// ---------------------------------------------------------------------------
|
|
497
|
+
// Clicks
|
|
498
|
+
// ---------------------------------------------------------------------------
|
|
499
|
+
function onClick(e) {
|
|
500
|
+
const t_ = e.target && e.target.closest ? e.target : null;
|
|
501
|
+
if (!t_) return;
|
|
502
|
+
if (t_.closest('[data-action="preset-work"]')) { if (on()) closeWork(); else openWork(); return; }
|
|
503
|
+
if (t_.closest('[data-action="refresh-forge"]') && on()) { load({ again: true }); return; }
|
|
504
|
+
const show = t_.closest('[data-work-show]');
|
|
505
|
+
if (show && on()) { setWaiting(show.dataset.workShow === 'waiting'); return; }
|
|
506
|
+
const act = t_.closest('[data-work-action]');
|
|
507
|
+
if (!act) return;
|
|
508
|
+
if (act.dataset.workAction === 'review') { reviewSpec(act.dataset.slug, act.dataset.source); return; }
|
|
509
|
+
const node = state.nodes.find((n) => n.id === act.dataset.id);
|
|
510
|
+
if (node && act.dataset.workAction === 'show-on-map') showOnMap(node.id);
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
/** A proposal's Review: the map is the review's (Before, Diff, After lay it over the map), so the view goes back to it and the proposal opens; Approve and Send back are the review's own */
|
|
514
|
+
function reviewSpec(slug, source) {
|
|
515
|
+
if (!slug) return;
|
|
516
|
+
const i = inst();
|
|
517
|
+
closeWork();
|
|
518
|
+
i.emit('node:close'); // a proposal shown from the lists has nothing selected to close it
|
|
519
|
+
openProposal(i, slug, source || null).catch(() => {});
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
/** A node of code, on the map: the view goes back to it, the node selected and in view */
|
|
523
|
+
function showOnMap(id) {
|
|
524
|
+
closeWork();
|
|
525
|
+
const node = state.nodes.find((n) => n.id === id);
|
|
526
|
+
if (node) selectNode(inst(), node, { frame: true, source: 'link' });
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
// ---------------------------------------------------------------------------
|
|
530
|
+
// Addresses (spec 0012 D8)
|
|
531
|
+
// ---------------------------------------------------------------------------
|
|
532
|
+
|
|
533
|
+
/** Follows `?view=work`, `?pr=`, `?issue=`, `?run=`, `?thread=` and `?spec=`, once; the ones that ask for a node are taken out of the address when followed */
|
|
534
|
+
export async function followWorkAddress(search = location.search) {
|
|
535
|
+
const ask = workAddress(search);
|
|
536
|
+
if (!ask) return false;
|
|
537
|
+
if (!offered) { announce(inst(), 'The map of work needs a forge in the config.'); return false; }
|
|
538
|
+
spend();
|
|
539
|
+
return openWork({ ask: ask.kind ? ask : null });
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
/** What an address that asks for work is, for the page to decide whether it is the Work view's (the old Work panel's links are `?run=` and `?issue=` too: step 3 of spec 0012 moves them) */
|
|
543
|
+
export const asksForWork = (search) => workAddress(search) !== null;
|
|
544
|
+
|
|
545
|
+
function spend() {
|
|
546
|
+
if (typeof history === 'undefined') return;
|
|
547
|
+
try {
|
|
548
|
+
const params = new URLSearchParams(location.search);
|
|
549
|
+
for (const k of ['pr', 'issue', 'run', 'thread', 'spec']) params.delete(k);
|
|
550
|
+
const query = params.toString();
|
|
551
|
+
history.replaceState(null, '', `${location.pathname}${query ? `?${query}` : ''}${location.hash}`);
|
|
552
|
+
} catch { /* the address is a convenience */ }
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
/** For tests: forget the page this was wired to */
|
|
556
|
+
export function resetWorkViewForTests() {
|
|
557
|
+
clearTimeout(timer);
|
|
558
|
+
if (offPaint) offPaint();
|
|
559
|
+
offPaint = null;
|
|
560
|
+
laneEls = [];
|
|
561
|
+
laneKey = null;
|
|
562
|
+
wired = false;
|
|
563
|
+
offered = false;
|
|
564
|
+
els = null;
|
|
565
|
+
card = null;
|
|
566
|
+
seq++;
|
|
567
|
+
wasOn = false;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
export { WORK_THEMES };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cornfield",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.56.0",
|
|
4
4
|
"description": "A self-hostable dev dashboard with the topology map at its centre: proposals on the map, scenarios, outages and what-if edits, for any repo.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "popcorn245 (https://github.com/popcorn245)",
|