@popcorn245/cornfield 0.62.0 → 0.64.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/release-notes.js +2 -2
- package/explorer/css/changes.css +3 -7
- package/explorer/css/header.css +15 -0
- package/explorer/css/layers.css +11 -2
- package/explorer/css/map.css +0 -1
- package/explorer/css/node-panel.css +45 -0
- package/explorer/css/page.css +2 -7
- package/explorer/css/proposal.css +2 -3
- package/explorer/css/work.css +7 -7
- package/explorer/engine/hint.js +7 -7
- package/explorer/engine/keyboard.js +5 -4
- package/explorer/engine/map-rect.js +2 -2
- package/explorer/engine/render.js +2 -1
- package/explorer/forge-panel-model.js +24 -0
- package/explorer/history-model.js +21 -11
- package/explorer/history-replay.js +13 -5
- package/explorer/history.js +16 -7
- package/explorer/inbox-model.js +180 -0
- package/explorer/index.html +6 -3
- package/explorer/page.js +1 -2
- package/explorer/panel-model.js +103 -0
- package/explorer/panel-sections.js +140 -0
- package/explorer/pieces/inbox.js +201 -0
- package/explorer/pieces/layers.js +27 -6
- package/explorer/pieces/node-panel.js +78 -1
- package/explorer/pieces/search.js +22 -9
- package/explorer/pieces/work-deploys.js +13 -13
- package/explorer/pieces/work-issues.js +10 -5
- package/explorer/pieces/work-list.js +72 -9
- package/explorer/pieces/work-paint.js +45 -10
- package/explorer/pieces/work-prs.js +46 -34
- package/explorer/pieces/work-runs.js +17 -5
- package/explorer/pieces/work-specs.js +24 -4
- package/explorer/pieces/work-threads.js +59 -15
- package/explorer/pieces/work.js +6 -3
- package/explorer/proposal-model.js +3 -6
- package/explorer/runs-view.js +42 -8
- package/explorer/scene.js +5 -1
- package/explorer/work-model.js +266 -55
- package/explorer/work-view.css +60 -16
- package/explorer/work-view.js +175 -35
- package/package.json +1 -1
- package/server/server.js +1 -1
- package/server/work-graph.js +65 -8
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module explorer/pieces/inbox
|
|
3
|
+
*
|
|
4
|
+
* The Work inbox in cornfield's page (spec 0016 D1, D2, D5 to D8): the queue of what needs you, over the Work view's stage, beside the node panel. Its rules are
|
|
5
|
+
* inbox-model.js (pure); work-view.js owns the read of the graph and the Inbox · Graph toggle, and mounts this once.
|
|
6
|
+
*
|
|
7
|
+
* mount(stage, { pick, act, announce, refresh, colorOf, now }) -> { paint(graph, { on, selected }), focus(), destroy() }
|
|
8
|
+
*
|
|
9
|
+
* `pick(id)` selects a piece of work (the node panel opens on it, with its actions: spec 0015's action bar); `act(id)` selects it and does its primary action, the
|
|
10
|
+
* node panel's own button, with its confirm step. Every word from the forge is set as text, never as HTML. J and K (and the arrows) move through the open groups,
|
|
11
|
+
* Enter acts, a group's header folds it. Nothing is filed by hand (D7): a row moves when the graph says its state moved.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { GROUPS, inboxOf, headingOf, openedWords, orderOf, rowWords } from '../inbox-model.js';
|
|
15
|
+
import { relativeTime } from '../review-model.js';
|
|
16
|
+
|
|
17
|
+
const SHAPE = { thread: 'circle', issue: 'circle', proposal: 'diamond', run: 'hexagon', pull: 'rounded', deploy: 'square' };
|
|
18
|
+
|
|
19
|
+
/** A small mark of the kind, drawn by its shape (the kind is said in words too: the row's tag) */
|
|
20
|
+
function glyph(kind, color) {
|
|
21
|
+
const ns = 'http://www.w3.org/2000/svg';
|
|
22
|
+
const svg = document.createElementNS(ns, 'svg');
|
|
23
|
+
svg.setAttribute('viewBox', '0 0 16 16');
|
|
24
|
+
svg.setAttribute('width', '16');
|
|
25
|
+
svg.setAttribute('height', '16');
|
|
26
|
+
svg.setAttribute('aria-hidden', 'true');
|
|
27
|
+
svg.setAttribute('class', `hx-inbox-glyph is-${kind}`);
|
|
28
|
+
if (color) svg.style.setProperty('--hx-glyph', color);
|
|
29
|
+
const shape = SHAPE[kind] || 'circle';
|
|
30
|
+
let el;
|
|
31
|
+
if (shape === 'circle') { el = document.createElementNS(ns, 'circle'); el.setAttribute('cx', '8'); el.setAttribute('cy', '8'); el.setAttribute('r', '6'); }
|
|
32
|
+
else if (shape === 'diamond') { el = document.createElementNS(ns, 'rect'); el.setAttribute('x', '3.5'); el.setAttribute('y', '3.5'); el.setAttribute('width', '9'); el.setAttribute('height', '9'); el.setAttribute('transform', 'rotate(45 8 8)'); }
|
|
33
|
+
else if (shape === 'hexagon') { el = document.createElementNS(ns, 'polygon'); el.setAttribute('points', '8,1.5 13.6,4.75 13.6,11.25 8,14.5 2.4,11.25 2.4,4.75'); }
|
|
34
|
+
else { el = document.createElementNS(ns, 'rect'); el.setAttribute('x', '2'); el.setAttribute('y', '2'); el.setAttribute('width', '12'); el.setAttribute('height', '12'); el.setAttribute('rx', shape === 'rounded' ? '3.5' : '1.5'); }
|
|
35
|
+
svg.append(el);
|
|
36
|
+
return svg;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** A number as data, and a kind's tag: the page's own `count` and `tag` hooks (docs/theming.md) */
|
|
40
|
+
const counted = (n) => { const el = make('span', 'hx-inbox-count', String(n)); el.dataset.corn = 'count'; el.setAttribute('part', 'count'); return el; };
|
|
41
|
+
const tagged = (words) => { const el = make('span', 'hx-inbox-tag', words); el.dataset.corn = 'tag'; el.setAttribute('part', 'tag'); return el; };
|
|
42
|
+
const make = (tag, cls, words) => { const el = document.createElement(tag); if (cls) el.className = cls; if (words != null) el.textContent = words; return el; };
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* @param {HTMLElement} stage the Work view's stage (the map's box)
|
|
46
|
+
* @param {{ pick: (id: string) => boolean, act: (id: string) => void, announce: (words: string) => void, now?: () => number, refresh: () => void, colorOf?: (kind: string) => string }} hooks
|
|
47
|
+
*/
|
|
48
|
+
export function mount(stage, hooks) {
|
|
49
|
+
const now = hooks.now || (() => Date.now());
|
|
50
|
+
const color = (kind) => (hooks.colorOf ? hooks.colorOf(kind) : '');
|
|
51
|
+
const root = make('section', 'hx-inbox');
|
|
52
|
+
root.dataset.corn = 'inbox';
|
|
53
|
+
root.setAttribute('part', 'inbox');
|
|
54
|
+
root.setAttribute('aria-label', 'Inbox');
|
|
55
|
+
root.hidden = true;
|
|
56
|
+
const queue = make('div', 'hx-inbox-queue');
|
|
57
|
+
const head = make('div', 'hx-inbox-head');
|
|
58
|
+
const title = make('h2', 'hx-inbox-title', 'Inbox');
|
|
59
|
+
const sub = make('span', 'hx-inbox-sub');
|
|
60
|
+
head.append(title, sub);
|
|
61
|
+
const list = make('div', 'hx-inbox-groups');
|
|
62
|
+
queue.append(head, list);
|
|
63
|
+
const aside = make('p', 'hx-inbox-pick', 'Pick a row: what it needs opens beside the queue.');
|
|
64
|
+
aside.dataset.corn = 'hint';
|
|
65
|
+
aside.setAttribute('part', 'hint');
|
|
66
|
+
root.append(queue, aside);
|
|
67
|
+
stage.append(root);
|
|
68
|
+
|
|
69
|
+
/** which groups are open: the ones GROUPS starts open, then as the viewer folds them (kept while the page is open) */
|
|
70
|
+
const open = new Set(GROUPS.filter((g) => g.open).map((g) => g.key));
|
|
71
|
+
let inbox = inboxOf(null);
|
|
72
|
+
let selected = null;
|
|
73
|
+
let was = false;
|
|
74
|
+
|
|
75
|
+
function paint(graph, { on, selected: sel = null } = {}) {
|
|
76
|
+
root.hidden = !on;
|
|
77
|
+
if (!on) { was = false; return; }
|
|
78
|
+
inbox = inboxOf(graph);
|
|
79
|
+
selected = sel;
|
|
80
|
+
sub.textContent = headingOf(inbox);
|
|
81
|
+
list.textContent = '';
|
|
82
|
+
if (!inbox.count) {
|
|
83
|
+
const empty = make('p', 'hx-inbox-empty');
|
|
84
|
+
empty.dataset.corn = 'empty';
|
|
85
|
+
empty.setAttribute('part', 'empty');
|
|
86
|
+
empty.append(make('strong', '', 'Nothing waits on you.'), document.createTextNode(' What is still yours to pick up is below.'));
|
|
87
|
+
list.append(empty);
|
|
88
|
+
}
|
|
89
|
+
for (const g of GROUPS) {
|
|
90
|
+
const rows = inbox.groups[g.key];
|
|
91
|
+
if (!rows.length) continue;
|
|
92
|
+
const isOpen = open.has(g.key);
|
|
93
|
+
const group = make('div', `hx-inbox-group is-${g.key}`);
|
|
94
|
+
group.dataset.corn = 'section';
|
|
95
|
+
group.setAttribute('part', 'section');
|
|
96
|
+
group.dataset.group = g.key;
|
|
97
|
+
const btn = make('button', 'hx-inbox-group-head');
|
|
98
|
+
btn.type = 'button';
|
|
99
|
+
btn.dataset.inboxGroup = g.key;
|
|
100
|
+
btn.setAttribute('aria-expanded', String(isOpen));
|
|
101
|
+
btn.append(make('span', 'hx-inbox-group-title', g.title), counted(rows.length));
|
|
102
|
+
if (g.hint) btn.append(make('span', 'hx-inbox-hint', g.hint));
|
|
103
|
+
group.append(btn);
|
|
104
|
+
if (isOpen) {
|
|
105
|
+
const ul = make('ul', 'hx-inbox-rows');
|
|
106
|
+
ul.setAttribute('aria-label', g.title);
|
|
107
|
+
for (const r of rows) ul.append(rowEl(r, g.key));
|
|
108
|
+
group.append(ul);
|
|
109
|
+
}
|
|
110
|
+
list.append(group);
|
|
111
|
+
}
|
|
112
|
+
if (inbox.drafts) {
|
|
113
|
+
const d = make('p', 'hx-inbox-drafts');
|
|
114
|
+
d.append(make('span', 'hx-inbox-group-title', 'Drafts in the checkout'), counted(inbox.drafts), make('span', 'hx-inbox-hint', 'nobody has been asked to decide them'));
|
|
115
|
+
list.append(d);
|
|
116
|
+
}
|
|
117
|
+
aside.hidden = !!selected;
|
|
118
|
+
if (!was) { hooks.announce(openedWords(inbox)); was = true; }
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function rowEl(r, group) {
|
|
122
|
+
const li = make('li', `hx-inbox-row${r.id === selected || (r.also && r.also.id === selected) ? ' is-selected' : ''}`);
|
|
123
|
+
li.dataset.corn = 'row';
|
|
124
|
+
li.setAttribute('part', 'row');
|
|
125
|
+
li.dataset.id = r.id;
|
|
126
|
+
const ago = relativeTime(r.item.updated, now());
|
|
127
|
+
// The row is a list item holding two buttons (a row that is an option cannot hold a button): its line, which selects it and covers the row, and its action
|
|
128
|
+
const top = make('button', 'hx-inbox-line');
|
|
129
|
+
top.type = 'button';
|
|
130
|
+
top.dataset.inboxOpen = r.id;
|
|
131
|
+
top.setAttribute('aria-label', rowWords(r, ago));
|
|
132
|
+
if (r.id === selected) top.setAttribute('aria-current', 'true');
|
|
133
|
+
top.tabIndex = r.id === selected || (!selected && r.id === order()[0]) ? 0 : -1;
|
|
134
|
+
top.append(tagged(r.tag), make('span', 'hx-inbox-row-title', String(r.item.title || '')));
|
|
135
|
+
const why = make('span', `hx-inbox-why${r.bad ? ' is-bad' : ''}`, r.why);
|
|
136
|
+
li.append(glyph(r.item.kind, color(r.item.kind)), top, make('span', 'hx-inbox-age', ago), why);
|
|
137
|
+
if (r.action) {
|
|
138
|
+
const go = make('button', `hx-inbox-act${group === 'waiting' ? ' is-primary' : ''}`, r.action.label);
|
|
139
|
+
go.type = 'button';
|
|
140
|
+
go.tabIndex = -1;
|
|
141
|
+
go.dataset.inboxAct = r.id;
|
|
142
|
+
li.append(go);
|
|
143
|
+
}
|
|
144
|
+
if (r.also) {
|
|
145
|
+
const also = make('span', 'hx-inbox-also');
|
|
146
|
+
also.append(glyph('run', color('run')), document.createTextNode(` and ${r.also.tag} waits on your answer`));
|
|
147
|
+
li.append(also);
|
|
148
|
+
}
|
|
149
|
+
return li;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const order = () => orderOf(inbox, open);
|
|
153
|
+
const rowOf = (id) => list.querySelector(`.hx-inbox-row[data-id="${CSS.escape(id)}"]`);
|
|
154
|
+
|
|
155
|
+
function choose(id, { focus = true } = {}) {
|
|
156
|
+
if (!id) return;
|
|
157
|
+
hooks.pick(id);
|
|
158
|
+
const el = rowOf(id);
|
|
159
|
+
if (el && focus) el.querySelector('[data-inbox-open]').focus();
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function onClick(e) {
|
|
163
|
+
const t = e.target && e.target.closest ? e.target : null;
|
|
164
|
+
if (!t || !root.contains(t)) return;
|
|
165
|
+
const fold = t.closest('[data-inbox-group]');
|
|
166
|
+
if (fold) { const k = fold.dataset.inboxGroup; if (open.has(k)) open.delete(k); else open.add(k); hooks.refresh(); return; }
|
|
167
|
+
const go = t.closest('[data-inbox-act]');
|
|
168
|
+
if (go) { e.stopPropagation(); hooks.act(go.dataset.inboxAct); return; }
|
|
169
|
+
const row = t.closest('.hx-inbox-row');
|
|
170
|
+
if (row) choose(row.dataset.id, { focus: false });
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function onKey(e) {
|
|
174
|
+
if (root.hidden || e.ctrlKey || e.metaKey || e.altKey) return;
|
|
175
|
+
const t = e.target;
|
|
176
|
+
if (!t || !root.contains(t) || (t.closest && t.closest('input, textarea, select'))) return;
|
|
177
|
+
const ids = order();
|
|
178
|
+
const cur = t.closest('.hx-inbox-row') ? t.closest('.hx-inbox-row').dataset.id : selected;
|
|
179
|
+
const i = ids.indexOf(cur);
|
|
180
|
+
let to = null;
|
|
181
|
+
if (e.key === 'j' || e.key === 'J' || e.key === 'ArrowDown') to = ids[Math.min(ids.length - 1, i + 1)] ?? ids[0];
|
|
182
|
+
else if (e.key === 'k' || e.key === 'K' || e.key === 'ArrowUp') to = ids[Math.max(0, i - 1)] ?? ids[0];
|
|
183
|
+
else if (e.key === 'Enter' && cur && t.closest('.hx-inbox-row')) { e.preventDefault(); hooks.act(cur); return; }
|
|
184
|
+
else return;
|
|
185
|
+
e.preventDefault();
|
|
186
|
+
if (to) choose(to);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
root.addEventListener('click', onClick);
|
|
190
|
+
root.addEventListener('keydown', onKey);
|
|
191
|
+
|
|
192
|
+
return {
|
|
193
|
+
paint,
|
|
194
|
+
/** The focus on the selected row, else the first */
|
|
195
|
+
focus() { const el = (selected && rowOf(selected)) || list.querySelector('.hx-inbox-row'); if (el) el.querySelector('[data-inbox-open]').focus(); },
|
|
196
|
+
/** The row of the selection and the next one in the order (the selection moves there after an action: D6) */
|
|
197
|
+
order,
|
|
198
|
+
destroy() { root.removeEventListener('click', onClick); root.removeEventListener('keydown', onKey); root.remove(); },
|
|
199
|
+
el: root,
|
|
200
|
+
};
|
|
201
|
+
}
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
* @module explorer/pieces/layers
|
|
3
3
|
*
|
|
4
4
|
* The Layers menu as a piece (spec 0011 D3): one toggle per kind of node (apps, pages, tables, services, ...) with its count, plus the legend
|
|
5
|
-
* of what the lines mean. The data-flow preset ignores the toggles.
|
|
5
|
+
* of what the lines mean. The data-flow preset ignores the toggles. A row may carry a button of its own beside it (`action` on the row: the History
|
|
6
|
+
* row's Replay, spec 0015 D6), which this piece draws and closes the menu for; what it does is the page's (page.js hears its `data-action`). A legend
|
|
7
|
+
* (the Key, Agent runs, History, Cloud, Data Flow) shows only while its layer is on; the proposal marks' while a proposal is open. What the layers are, which are on and what a review shows is the instance's
|
|
6
8
|
* (engine/layers.js); this is the chip, the menu and its rows.
|
|
7
9
|
*
|
|
8
10
|
* mount(root, inst, options) -> { update, destroy, ... }
|
|
@@ -43,7 +45,7 @@ export const markup = () => ({
|
|
|
43
45
|
<button type="button" id="legend-toggle-btn" class="hx-layers-chip" data-action="toggle-layers-menu" aria-expanded="false" aria-controls="legend-dropdown" data-corn="layers-button"><span data-corn-string="layers">Layers</span><span id="layers-count" class="hx-layers-count" data-corn="count"></span></button>
|
|
44
46
|
<div id="legend-dropdown" class="hx-menu glass" hidden data-corn="layers-menu">
|
|
45
47
|
<div class="hx-menu-title hx-menu-head" data-corn="menu-title">
|
|
46
|
-
<span>
|
|
48
|
+
<span>Layers</span>
|
|
47
49
|
<span class="hx-menu-links">
|
|
48
50
|
<button type="button" class="hx-textbtn hx-textbtn--accent" data-action="layers-all" data-corn="layers-all" data-corn-kind="quiet" data-corn-string="layersAll">All</button>
|
|
49
51
|
<span class="hx-faint">•</span>
|
|
@@ -81,6 +83,9 @@ export const markup = () => ({
|
|
|
81
83
|
});
|
|
82
84
|
|
|
83
85
|
/** "1 link", "3 in flight", else the number */
|
|
86
|
+
/** The runs' layer (runs-map.js `RUNS_LAYER`): named here, so the menu does not load the runs' marks */
|
|
87
|
+
const RUNS_LAYER = 'runs';
|
|
88
|
+
|
|
84
89
|
const UNIT = Object.assign(Object.create(null), { flow: (n) => `${n} ${n === 1 ? 'link' : 'links'}`, runs: (n) => `${n} in flight` });
|
|
85
90
|
|
|
86
91
|
/** Mounts the Layers menu; see the top of this file */
|
|
@@ -219,11 +224,12 @@ export function mount(root, inst, options = {}) {
|
|
|
219
224
|
|
|
220
225
|
const row = (layer) => {
|
|
221
226
|
const on = isOn(inst, layer.key);
|
|
227
|
+
const act = layer.action && typeof layer.action.name === 'string' ? layer.action : null;
|
|
222
228
|
const shown = byProposal[layer.key] ? `<span class="hx-faint hx-layer-note" data-corn="layer-note">+${byProposal[layer.key]} shown by the proposal</span>` : '';
|
|
223
229
|
// A row the review hid says so under its name (there is no room beside it): it can still be turned on, for the review
|
|
224
230
|
const hid = !shown && counts[layer.key] && reviewHides(state, layer.key) ? `<span class="hx-faint hx-layer-note" data-corn="layer-note">${escHtml(t(inst, 'hiddenWhileReviewing'))}</span>` : '';
|
|
225
231
|
const name = `<span class="hx-toggle-name">${escHtml(layer.label)}</span>`;
|
|
226
|
-
|
|
232
|
+
const toggle = `
|
|
227
233
|
<button type="button" class="hx-toggle-row${on ? '' : ' is-off'}" data-action="toggle-layer" data-layer="${escHtml(layer.key)}" aria-pressed="${on}" title="${escHtml(layer.desc)}" data-corn="row">
|
|
228
234
|
<span class="hx-toggle-label">
|
|
229
235
|
${dot(swatch(layer.color), on, surface)}
|
|
@@ -233,7 +239,10 @@ export function mount(root, inst, options = {}) {
|
|
|
233
239
|
<span class="hx-count" data-corn="count">${layer.countText || (UNIT[layer.key] || String)(counts[layer.key] || 0)}</span>
|
|
234
240
|
<span class="hx-tick">${on ? '✓' : '—'}</span>
|
|
235
241
|
</span>
|
|
236
|
-
</button
|
|
242
|
+
</button>`;
|
|
243
|
+
// A row's own button (the History row's Replay) sits beside it, never in it: a button in a button is not one
|
|
244
|
+
const line = act ? `<div class="hx-toggle-line">${toggle}<button type="button" class="hx-row-action" data-action="${escHtml(act.name)}" data-corn-kind="secondary" aria-pressed="${act.pressed === true}" title="${escHtml(act.title || '')}">${escHtml(act.label)}</button></div>` : toggle;
|
|
245
|
+
return `${line}${kindsHtml(layer, kinds.get(layer.key), surface)}`;
|
|
237
246
|
};
|
|
238
247
|
|
|
239
248
|
// The focus stays where it was across the redraw: the same row or disclosure, found again by what it names
|
|
@@ -249,10 +258,20 @@ export function mount(root, inst, options = {}) {
|
|
|
249
258
|
}
|
|
250
259
|
renderFlowLegend(inst, own('flow-legend'));
|
|
251
260
|
renderEdgeKey();
|
|
261
|
+
paintLegends(layers);
|
|
252
262
|
renderCloudLegend();
|
|
253
263
|
addParts(own('flow-legend'));
|
|
254
264
|
}
|
|
255
265
|
|
|
266
|
+
/** The legends that follow a layer (spec 0015 D6): the Key while any layer is on (with none, no line is drawn), Agent runs while runs are on the map and their layer is on */
|
|
267
|
+
let runsActive = false;
|
|
268
|
+
function paintLegends(layers = layerRows(inst).layers) {
|
|
269
|
+
const key = own('edge-key');
|
|
270
|
+
if (key) key.hidden = !layers.some((l) => isOn(inst, l.key));
|
|
271
|
+
const runs = own('runs-legend');
|
|
272
|
+
if (runs) runs.hidden = !(runsActive && isOn(inst, RUNS_LAYER));
|
|
273
|
+
}
|
|
274
|
+
|
|
256
275
|
/** The Key (spec 0008 D7): each kind of line as the map draws it (edge-key.js) */
|
|
257
276
|
function renderEdgeKey() {
|
|
258
277
|
const el = own('edge-key');
|
|
@@ -296,6 +315,8 @@ export function mount(root, inst, options = {}) {
|
|
|
296
315
|
scope.listen(wrap, 'click', (e) => {
|
|
297
316
|
const target = e.target.closest && e.target.closest('[data-action]');
|
|
298
317
|
if (!target) return;
|
|
318
|
+
// A row's own button (Replay): the menu closes, the focus on its chip, and the page does the rest (it hears the click on the document)
|
|
319
|
+
if (target.classList.contains('hx-row-action')) { closeMenu(); btn.focus(); return; }
|
|
299
320
|
const action = ACTIONS[target.dataset.action];
|
|
300
321
|
if (action) action(target);
|
|
301
322
|
});
|
|
@@ -323,8 +344,8 @@ export function mount(root, inst, options = {}) {
|
|
|
323
344
|
scope.on('layers:redraw', renderLayerToggles);
|
|
324
345
|
scope.on('theme', renderLayerToggles); // the dots and the legends are drawn in the theme's colours
|
|
325
346
|
scope.on('view', syncView);
|
|
326
|
-
scope.on('runs:map', ({ active }) => {
|
|
327
|
-
scope.on('history:legend', ({ active }) => { const legend = own('history-legend'); if (legend) legend.hidden = !active; }); // the History layer is drawn (history.js): what a halo's width and colour say
|
|
347
|
+
scope.on('runs:map', ({ active }) => { runsActive = !!active; paintLegends(); }); // runs are on the map (the Work list): the legend says what each mark is, while their layer is on
|
|
348
|
+
scope.on('history:legend', ({ active }) => { const legend = own('history-legend'); if (legend) legend.hidden = !active; }); // the History layer is drawn (history.js): what a halo's width and colour say
|
|
328
349
|
// The marks legend is there while a proposal is open (the proposal's bar says so: engine/proposal.js)
|
|
329
350
|
const showLegend = (open) => { const legend = own('proposal-legend'); if (legend) legend.hidden = !open; };
|
|
330
351
|
scope.on('proposal:draw', ({ open }) => showLegend(open));
|
|
@@ -44,6 +44,8 @@ import { reach } from '../selection-view.js';
|
|
|
44
44
|
import { announce, frameThem } from '../engine/keyboard.js';
|
|
45
45
|
import { selectNode, clearSelection } from '../engine/selection.js';
|
|
46
46
|
import { scopeOf, place, addParts } from '../engine/piece.js';
|
|
47
|
+
import { panelKind, sectionHtml } from '../panel-model.js';
|
|
48
|
+
import { applySections, onSectionsClick, onSectionsKey } from '../panel-sections.js';
|
|
47
49
|
|
|
48
50
|
// ---------------------------------------------------------------------------
|
|
49
51
|
// Small HTML pieces shared by the sections below
|
|
@@ -96,6 +98,8 @@ export const LINES_CAP = 12;
|
|
|
96
98
|
export const markup = () => ({
|
|
97
99
|
drawer: '<aside id="spec-drawer" class="hx-drawer glass" aria-label="Node details" inert data-corn="node-panel">'
|
|
98
100
|
+ '<div class="hx-drawer-body">'
|
|
101
|
+
// Back (spec 0015 D3): to the Work list this panel took the place of, or from a thread folded into a proposal to the proposal; hidden when there is nowhere to go back to
|
|
102
|
+
+ '<button type="button" id="drawer-back" class="hx-forge-back hx-panel-back" data-action="panel-back" data-corn="back" hidden><svg width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" aria-hidden="true"><path d="M10 3L5 8l5 5"/></svg><span class="hx-forge-back-text">Back</span></button>'
|
|
99
103
|
+ '<div class="hx-drawer-head">'
|
|
100
104
|
+ '<div class="hx-drawer-id">'
|
|
101
105
|
+ '<p class="hx-kicker"><span id="drawer-badge" data-corn="badge">Atom</span><span id="drawer-host" data-corn="node-host"></span><span id="drawer-diff" class="hx-diffpill" data-corn="diff-pill" hidden></span></p>'
|
|
@@ -265,7 +269,7 @@ function sectionsOf(inst) {
|
|
|
265
269
|
const count = Number(th.comments) || 0;
|
|
266
270
|
return `<li><button type="button" class="hx-row hx-thread-open" data-thread-open="${escHtml(th.number)}" data-corn="row" aria-label="Open thread #${escHtml(th.number)}, ${escHtml(th.title)}, ${count} ${count === 1 ? 'comment' : 'comments'}, in the issues and pull requests panel"><span class="hx-row-title">${escHtml(th.title)}</span><span class="hx-row-meta">#${escHtml(th.number)} · ${count}</span></button></li>`;
|
|
267
271
|
});
|
|
268
|
-
return
|
|
272
|
+
return sectionHtml({ key: 'threads', title: 'Threads', count: threads.length, body: `<ul class="hx-rows">${rows.join('')}</ul>${start}` });
|
|
269
273
|
}
|
|
270
274
|
|
|
271
275
|
/** "In this proposal": the diff for a changed node as key/value rows (id, parent, edges +2; a change shows each field before and after) */
|
|
@@ -389,8 +393,12 @@ export function mount(root, inst, options = {}) {
|
|
|
389
393
|
if (!box || !state.selectedNode) return;
|
|
390
394
|
box.innerHTML = sections.threadsSection(state.selectedNode);
|
|
391
395
|
addParts(box);
|
|
396
|
+
applySections(inst, box, kindShown());
|
|
392
397
|
}
|
|
393
398
|
|
|
399
|
+
/** The kind of node the panel shows, whose sections' open and closed the browser remembers (spec 0015 D4) */
|
|
400
|
+
const kindShown = () => drawer.dataset.panelKind || '';
|
|
401
|
+
|
|
394
402
|
/** Draws "History" again in the open panel (spec 0014 D2: the history was read, a spec was picked, or Show all); nothing else in the panel moves */
|
|
395
403
|
function repaintHistory() {
|
|
396
404
|
const box = own('drawer-history');
|
|
@@ -400,6 +408,7 @@ export function mount(root, inst, options = {}) {
|
|
|
400
408
|
const key = active && box.contains(active) ? (active.dataset.historySpec ? `spec:${active.dataset.historySpec}` : active.hasAttribute('data-history-all') ? 'all' : '') : '';
|
|
401
409
|
box.innerHTML = inst.ask('history:section', node) || '';
|
|
402
410
|
addParts(box);
|
|
411
|
+
applySections(inst, box, kindShown());
|
|
403
412
|
if (key.startsWith('spec:')) { const el = [...box.querySelectorAll('[data-history-spec]')].find((x) => `spec:${x.dataset.historySpec}` === key); if (el) el.focus(); }
|
|
404
413
|
else if (key === 'all') { const first = box.querySelector('.hx-history-commit a'); if (first) first.focus(); }
|
|
405
414
|
}
|
|
@@ -422,6 +431,7 @@ export function mount(root, inst, options = {}) {
|
|
|
422
431
|
const els = [];
|
|
423
432
|
for (let el = metaList.firstChild; el && el !== before; el = el.nextSibling) els.push(el);
|
|
424
433
|
if (html) addParts(metaList);
|
|
434
|
+
for (const el of els) applySections(inst, el, kindShown());
|
|
425
435
|
workShown = { node, html, els };
|
|
426
436
|
}
|
|
427
437
|
/** The work changed (`work:changed`: the Work layer came on or went off, or a new answer): the open panel's section for it is drawn again, and nothing else in it moves */
|
|
@@ -435,8 +445,11 @@ export function mount(root, inst, options = {}) {
|
|
|
435
445
|
}
|
|
436
446
|
|
|
437
447
|
/** Fills the panel for a node and opens it. The selection itself is the instance's (engine/selection.js); this is what is shown for it. */
|
|
448
|
+
let shownNode = null; // what the panel shows, for `panel:return` (the Work list stepped in front of it, spec 0015 D3)
|
|
438
449
|
function show(node, { frame = false } = {}) {
|
|
439
450
|
if (!node || gone) return;
|
|
451
|
+
shownNode = node;
|
|
452
|
+
drawer.dataset.panelKind = panelKind(node);
|
|
440
453
|
const title = own('drawer-title');
|
|
441
454
|
title.textContent = node.tag ? `<${node.tag}>` : node.label;
|
|
442
455
|
title.classList.toggle('hx-mono', node.type === 'page' || !!node.tag); // a route or a tag reads as code
|
|
@@ -497,6 +510,10 @@ export function mount(root, inst, options = {}) {
|
|
|
497
510
|
openBtn.hidden = true;
|
|
498
511
|
own('drawer-run-btn').hidden = true;
|
|
499
512
|
} else putWork(node, work ? work.html : '');
|
|
513
|
+
applySections(inst, metaList, kindShown()); // each section as it was left for this kind of node (spec 0015 D4)
|
|
514
|
+
// The foot holds a node of code's actions; a piece of work's are its action bar, at the top
|
|
515
|
+
own('drawer-copy-btn').closest('.hx-drawer-foot').hidden = !!(work && work.replace);
|
|
516
|
+
setBack(node);
|
|
500
517
|
|
|
501
518
|
drawer.classList.add('drawer-open');
|
|
502
519
|
drawer.inert = false; // closed, it waits off screen: inert, so Tab never reaches its buttons (MAP-02)
|
|
@@ -507,12 +524,47 @@ export function mount(root, inst, options = {}) {
|
|
|
507
524
|
inst.emit('node:painted', { node });
|
|
508
525
|
}
|
|
509
526
|
|
|
527
|
+
/**
|
|
528
|
+
* Back, at the top of the panel (spec 0015 D3): from a thread folded into the selected proposal (spec 0015 D2), to the proposal; else, while the Work list is open on a desktop
|
|
529
|
+
* (it waits behind this panel: `panel:back`, answered by the Work list), to the list. Escape does the same. With nowhere to go back to it is hidden, and Escape closes the panel.
|
|
530
|
+
*/
|
|
531
|
+
let backTo = null;
|
|
532
|
+
function setBack(node) {
|
|
533
|
+
const btn = own('drawer-back');
|
|
534
|
+
const sel = state.selectedNode;
|
|
535
|
+
const into = node && node.foldedInto && sel && sel !== node && sel.id === node.foldedInto ? sel : null;
|
|
536
|
+
const list = !into && node && !inline ? inst.ask('panel:back') : undefined;
|
|
537
|
+
backTo = into ? () => { show(into, { frame: false }); return true; } : typeof list === 'function' ? list : null;
|
|
538
|
+
if (!btn) return;
|
|
539
|
+
btn.hidden = !backTo;
|
|
540
|
+
const words = into ? `Back to ${into.label || into.id}` : 'Back to the list';
|
|
541
|
+
btn.querySelector('.hx-forge-back-text').textContent = words;
|
|
542
|
+
btn.setAttribute('aria-label', into ? words : 'Back to the Work list');
|
|
543
|
+
}
|
|
544
|
+
/** Goes back (the button, or Escape); false when there was nowhere to go */
|
|
545
|
+
function goBack() {
|
|
546
|
+
const go = backTo;
|
|
547
|
+
if (!go) return false;
|
|
548
|
+
backTo = null;
|
|
549
|
+
go();
|
|
550
|
+
return true;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
/** The Work list took this panel's place (spec 0015 D3): the panel steps aside, the selection stays, Back on the list's row brings it again */
|
|
554
|
+
function stepAside() {
|
|
555
|
+
if (inline || gone || !drawer.classList.contains('drawer-open')) return;
|
|
556
|
+
drawer.classList.remove('drawer-open');
|
|
557
|
+
drawer.inert = true;
|
|
558
|
+
backdrop.hidden = true;
|
|
559
|
+
}
|
|
560
|
+
|
|
510
561
|
/**
|
|
511
562
|
* Fills the panel for an edge and opens it: what it is, and what the proposal says about it (the engine's `showEdge` selects it and says `node:show-edge`).
|
|
512
563
|
* As ever, an edge alone gets no sheet on a phone (the panel is opened, not `showSheet`ed), and Escape on the map does not close it.
|
|
513
564
|
*/
|
|
514
565
|
function showEdge(edge) {
|
|
515
566
|
if (!edge || gone) return;
|
|
567
|
+
shownNode = null;
|
|
516
568
|
const row = (label, value) => (value ? `<div class="hx-fact" data-corn="section"><div class="hx-fact-k">${escHtml(label)}</div><div class="hx-fact-v">${escHtml(value)}</div></div>` : '');
|
|
517
569
|
const kind = edge.kind || (edge.dashed ? 'usage' : 'ownership');
|
|
518
570
|
const facts = row('Kind', kind) + row('Flow', edge.flow) + row('Label', edge.label) + row('Reads', Array.isArray(edge.keys) ? edge.keys.join(', ') : '');
|
|
@@ -534,6 +586,9 @@ export function mount(root, inst, options = {}) {
|
|
|
534
586
|
own('drawer-open-btn').hidden = true;
|
|
535
587
|
own('drawer-file-btn').hidden = true;
|
|
536
588
|
own('drawer-run-btn').hidden = true;
|
|
589
|
+
own('drawer-copy-btn').closest('.hx-drawer-foot').hidden = false;
|
|
590
|
+
setBack(null);
|
|
591
|
+
delete drawer.dataset.panelKind;
|
|
537
592
|
drawer.classList.add('drawer-open');
|
|
538
593
|
drawer.inert = false; // closed, the panel is inert (MAP-02): open for an edge, its links and its Close are reached as a node's are
|
|
539
594
|
backdrop.hidden = false;
|
|
@@ -554,7 +609,20 @@ export function mount(root, inst, options = {}) {
|
|
|
554
609
|
inst.map.render();
|
|
555
610
|
}
|
|
556
611
|
|
|
612
|
+
/** After Back to the proposal the button that was pressed is gone: the focus goes to the title, as Enter on the map puts it */
|
|
613
|
+
function focusTitle() {
|
|
614
|
+
const now = inst.active();
|
|
615
|
+
if (!drawer.classList.contains('drawer-open') || (now && now.isConnected && now !== inst.doc.body && drawer.contains(now))) return;
|
|
616
|
+
const title = own('drawer-title');
|
|
617
|
+
title.setAttribute('tabindex', '-1');
|
|
618
|
+
title.focus();
|
|
619
|
+
}
|
|
620
|
+
|
|
557
621
|
function close() {
|
|
622
|
+
shownNode = null;
|
|
623
|
+
backTo = null;
|
|
624
|
+
const btn = own('drawer-back');
|
|
625
|
+
if (btn) btn.hidden = true;
|
|
558
626
|
drawer.classList.remove('drawer-open');
|
|
559
627
|
drawer.inert = true;
|
|
560
628
|
backdrop.hidden = true;
|
|
@@ -576,8 +644,10 @@ export function mount(root, inst, options = {}) {
|
|
|
576
644
|
'start-run': () => startRun(),
|
|
577
645
|
'select-node': (el) => selectNode(inst, sections.nodeById(el.dataset.id), { frame: true, source: 'link' }), // a link or a list row: the camera follows (spec 0008 D6)
|
|
578
646
|
'frame-selection': () => frameThem(inst),
|
|
647
|
+
'panel-back': () => { if (goBack()) scope.timeout(focusTitle, 0); },
|
|
579
648
|
};
|
|
580
649
|
scope.listen(drawer, 'click', (e) => {
|
|
650
|
+
if (onSectionsClick(inst, e, kindShown())) return; // a section's title, a count that opens its rows, ⋯
|
|
581
651
|
const target = e.target.closest && e.target.closest('[data-action]');
|
|
582
652
|
if (!target) return;
|
|
583
653
|
const shut = target.dataset.action === 'close-drawer';
|
|
@@ -607,9 +677,12 @@ export function mount(root, inst, options = {}) {
|
|
|
607
677
|
}
|
|
608
678
|
// Escape anywhere in the panel closes it, and the map has the focus again
|
|
609
679
|
scope.listen(drawer, 'keydown', (e) => {
|
|
680
|
+
if (onSectionsKey(e)) return; // Escape in the open ⋯ menu closes the menu, not the panel
|
|
610
681
|
if (e.key !== 'Escape' || e.defaultPrevented) return;
|
|
611
682
|
if (e.target.closest && e.target.closest('select, input, textarea')) return; // a field's own Escape first
|
|
612
683
|
e.preventDefault();
|
|
684
|
+
// Back first (spec 0015 D3): to the Work list this panel took the place of, or from a folded thread to its proposal
|
|
685
|
+
if (backTo) { goBack(); scope.timeout(focusTitle, 0); announce(inst, 'Back'); return; }
|
|
613
686
|
const back = inst.ask('node:back');
|
|
614
687
|
clearSelection(inst, { source: 'keyboard' });
|
|
615
688
|
if (!(back && back()) && state.canvas) state.canvas.focus();
|
|
@@ -621,6 +694,10 @@ export function mount(root, inst, options = {}) {
|
|
|
621
694
|
scope.on('panel:covers', () => (!inline && !gone && !drawer.hidden && drawer.classList.contains('drawer-open') ? { right: drawer.offsetWidth } : undefined));
|
|
622
695
|
scope.on('node:show', ({ node, frame }) => show(node, { frame }));
|
|
623
696
|
scope.on('node:close', close);
|
|
697
|
+
// The Work list opened on a desktop: it takes this panel's place, and the selection stays (spec 0015 D3; a phone's sheets take turns on their own)
|
|
698
|
+
scope.on('work:list', ({ open }) => { if (open && !inline && !isPhone(inst)) stepAside(); });
|
|
699
|
+
// ... and the list's row of what it shows brings it back in the list's place (the list goes behind it again)
|
|
700
|
+
scope.on('panel:return', () => { if (shownNode && !inline && !gone && !drawer.classList.contains('drawer-open')) show(shownNode, { frame: false }); });
|
|
624
701
|
scope.on('node:show-edge', ({ edge }) => showEdge(edge));
|
|
625
702
|
// Enter on the map goes into the open panel: its title takes the focus, so a screen reader starts there and Tab goes on into it
|
|
626
703
|
scope.on('node:focus', () => {
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
* what a layer that is off hides last, under "In layers that are off", and choosing one turns its layer on;
|
|
9
9
|
* - stepping: Enter and Shift+Enter in the field, the arrow keys in the list, N and P on the map (engine/keyboard.js asks `search:active` and
|
|
10
10
|
* `search:step`) and the field's ^ and v buttons. Each step selects the match and flies the camera to it, at zoom 1 or closer;
|
|
11
|
+
* a choice made in the field (Enter) or the list (a click, Enter on a row) closes the list, so it does not lie over the node panel (spec 0015 D7):
|
|
12
|
+
* typing again, the down arrow or the field taking the focus again opens it;
|
|
11
13
|
* - on the map the matches keep their halo and win a label (scene.js, labels.js), the rest dims.
|
|
12
14
|
*
|
|
13
15
|
* The desktop field and the phone's bar are two inputs on one search: the query, the matches and the current match are shared, each
|
|
@@ -183,7 +185,7 @@ export function mount(root, inst, options = {}) {
|
|
|
183
185
|
if (!list) continue;
|
|
184
186
|
const input = own(field.input);
|
|
185
187
|
const focused = inst.active();
|
|
186
|
-
const open = !!result.query && keepOpen && (focused === input || list.contains(focused) || list.dataset.open === 'true');
|
|
188
|
+
const open = !!result.query && keepOpen && list.dataset.shut !== 'true' && (focused === input || list.contains(focused) || list.dataset.open === 'true');
|
|
187
189
|
// A row that has the focus is repainted: the focus goes to the same row again, so a keyboard user keeps their place
|
|
188
190
|
const held = list.contains(focused) ? focused : null;
|
|
189
191
|
const heldId = held ? held.dataset.searchId || (held.hasAttribute('data-search-frame') ? '' : null) : null;
|
|
@@ -204,6 +206,14 @@ export function mount(root, inst, options = {}) {
|
|
|
204
206
|
}
|
|
205
207
|
}
|
|
206
208
|
|
|
209
|
+
/** The list of a field, closed until it is asked for again (a match was chosen: Enter, or a row): typing, the down arrow or the field's focus opens it */
|
|
210
|
+
function shutList(field) {
|
|
211
|
+
const list = listOf(field);
|
|
212
|
+
if (list) list.dataset.shut = 'true';
|
|
213
|
+
closeList(field);
|
|
214
|
+
}
|
|
215
|
+
const unshut = (field) => { const list = listOf(field); if (list) delete list.dataset.shut; };
|
|
216
|
+
|
|
207
217
|
/** The list of a field, closed (Escape, or the focus left it) */
|
|
208
218
|
function closeList(field) {
|
|
209
219
|
const list = listOf(field);
|
|
@@ -308,10 +318,11 @@ export function mount(root, inst, options = {}) {
|
|
|
308
318
|
if (!typed) return;
|
|
309
319
|
const result = currentResult();
|
|
310
320
|
if (!result.total) { announce(inst, `No node matches ${typed}`); return; }
|
|
321
|
+
shutList(field); // the choice is made: the list would lie over the node's panel
|
|
311
322
|
stepMatch(e.shiftKey ? -1 : 1);
|
|
312
323
|
} else if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
|
|
313
324
|
const list = listOf(field);
|
|
314
|
-
if (!list || list.hidden) { if (e.key === 'ArrowDown' && state.searchQuery) { e.preventDefault(); list.dataset.open = 'true'; paintSearch(); } return; }
|
|
325
|
+
if (!list || list.hidden) { if (e.key === 'ArrowDown' && state.searchQuery) { e.preventDefault(); unshut(field); list.dataset.open = 'true'; paintSearch(); } return; }
|
|
315
326
|
const rows = rowsOf(list);
|
|
316
327
|
if (!rows.length) return;
|
|
317
328
|
e.preventDefault();
|
|
@@ -347,14 +358,15 @@ export function mount(root, inst, options = {}) {
|
|
|
347
358
|
const result = currentResult();
|
|
348
359
|
const match = result.matches.find((m) => m.node.id === row.dataset.searchId);
|
|
349
360
|
if (!match) return;
|
|
350
|
-
|
|
351
|
-
// On a phone the list would cover the match: it shuts, and the focus goes to the next-match button, which stays
|
|
361
|
+
// The list shuts (it would lie over the node's panel) and the focus goes back to the field; on a phone, to the next-match button, which stays
|
|
352
362
|
const field = fields.find((f) => listOf(f) === e.currentTarget);
|
|
353
|
-
if (field
|
|
354
|
-
|
|
363
|
+
if (field) {
|
|
364
|
+
shutList(field);
|
|
355
365
|
const next = own(field.steps) && own(field.steps).querySelector('[data-action="search-next"]');
|
|
356
|
-
|
|
366
|
+
const to = field.input === 'mobile-node-search' && isPhone(inst) ? next : own(field.input);
|
|
367
|
+
if (to) to.focus();
|
|
357
368
|
}
|
|
369
|
+
chooseMatch(match);
|
|
358
370
|
}
|
|
359
371
|
|
|
360
372
|
/** The list closes when the focus leaves the field and its list (a click on the map, Tab away) */
|
|
@@ -364,6 +376,7 @@ export function mount(root, inst, options = {}) {
|
|
|
364
376
|
if (next && box && box.contains(next)) return;
|
|
365
377
|
if (!next && e.target && e.target.matches && e.target.matches('[data-corn="search-result"]')) return; // a row that left the DOM (the list repainted)
|
|
366
378
|
closeList(field);
|
|
379
|
+
unshut(field); // coming back to the field opens the list again
|
|
367
380
|
}
|
|
368
381
|
|
|
369
382
|
/** Opens or shuts the phone's search bar (its icon in the header, Cancel); opened, it takes the query and the focus */
|
|
@@ -388,9 +401,9 @@ export function mount(root, inst, options = {}) {
|
|
|
388
401
|
input.setAttribute('aria-autocomplete', 'none');
|
|
389
402
|
input.setAttribute('aria-expanded', 'false');
|
|
390
403
|
input.setAttribute('aria-controls', field.results);
|
|
391
|
-
scope.listen(input, 'input', (e) => setQuery(e.target.value));
|
|
404
|
+
scope.listen(input, 'input', (e) => { unshut(field); setQuery(e.target.value); });
|
|
392
405
|
scope.listen(input, 'keydown', (e) => onFieldKey(e, field));
|
|
393
|
-
scope.listen(input, 'focus', () => { const list = listOf(field); if (list && state.searchQuery) { list.dataset.open = 'true'; paintSearch(); } });
|
|
406
|
+
scope.listen(input, 'focus', () => { const list = listOf(field); if (list && state.searchQuery && list.dataset.shut !== 'true') { list.dataset.open = 'true'; paintSearch(); } });
|
|
394
407
|
const box = input.closest('[data-corn="search"], [data-corn="mobile-search"]');
|
|
395
408
|
if (box) scope.listen(box, 'focusout', (e) => onFocusOut(e, field));
|
|
396
409
|
const list = listOf(field);
|
|
@@ -10,6 +10,7 @@ import { nodesForRestarts, deployWords, deployMeta, listUrl } from '../forge-pan
|
|
|
10
10
|
import { cornStateAttr, stateIconHtml } from '../corn-state.js';
|
|
11
11
|
import { escapeHtml as escHtml } from '../../core/text.js';
|
|
12
12
|
import { plural, safeUrl } from './work-common.js';
|
|
13
|
+
import { sectionHtml } from '../panel-model.js';
|
|
13
14
|
|
|
14
15
|
export function install(ctx) {
|
|
15
16
|
const { ui, m, fn, state } = ctx;
|
|
@@ -71,24 +72,23 @@ export function install(ctx) {
|
|
|
71
72
|
}
|
|
72
73
|
|
|
73
74
|
/** The deploy in the node panel: what it was, its logs on the forge, and the nodes it restarted (each a button that selects it on the map) */
|
|
74
|
-
function
|
|
75
|
-
if (ui.detailError && !ui.deployItem) return `<p class="hx-forge-notice" data-corn="notice">${escHtml(ui.detailError)}</p
|
|
75
|
+
function deployParts() {
|
|
76
|
+
if (ui.detailError && !ui.deployItem) return { notes: `<p class="hx-forge-notice" data-corn="notice">${escHtml(ui.detailError)}</p>` };
|
|
76
77
|
const d = ui.deployItem;
|
|
77
|
-
if (!d) return '<p class="hx-faint">Loading what it restarted …</p>';
|
|
78
|
+
if (!d) return { notes: '<p class="hx-faint">Loading what it restarted …</p>' };
|
|
78
79
|
const lit = ui.litDeploy;
|
|
79
80
|
const url = safeUrl(d.url);
|
|
80
|
-
|
|
81
|
-
|
|
81
|
+
// Its logs are its one action (spec 0015 D4); its state and when are the panel's head, its run's words a line under the bar
|
|
82
|
+
const logs = url ? `<a data-corn="open-link" data-corn-kind="primary" class="hx-btn hx-btn--primary hx-forge-open" href="${escHtml(url)}" target="_blank" rel="noreferrer">Open the logs on ${escHtml(fn.forgeName())} ↗</a>` : '';
|
|
83
|
+
const head = `<p class="hx-forge-meta">${escHtml(deployMeta(d, m.now()))}</p>`; // its state is the panel's one pill
|
|
82
84
|
const stale = ui.lists.deploys && ui.lists.deploys.stale;
|
|
83
|
-
|
|
85
|
+
const notes = `${head}${stale ? `<p class="hx-forge-notice" data-corn="notice">${escHtml(`This is an older answer. ${stale}`)}</p>` : ''}`;
|
|
84
86
|
if (!d.restarts.length) {
|
|
85
|
-
|
|
86
|
-
} else {
|
|
87
|
-
const rows = lit.nodes.map((n) => `<li class="hx-forge-file" data-corn="file"><button data-corn="node-chip" type="button" class="hx-forge-node" data-forge-node="${escHtml(n.id)}" aria-label="Show ${escHtml(n.label)} on the map${isNodeVisible(n) ? '' : ' (its layer is off)'}">${escHtml(n.label)}${isNodeVisible(n) ? '' : ' · layer off'}</button> <span class="hx-faint">${escHtml(n.type)}</span></li>`).join('');
|
|
88
|
-
const missing = lit.missing.length ? `<p class="hx-forge-notice" data-corn="notice">${escHtml(lit.missing.join(', '))} ${lit.missing.length === 1 ? 'is' : 'are'} named in the config but not on the map.</p>` : '';
|
|
89
|
-
body = `<h3 class="hx-forge-sub">${escHtml(`Restarted: ${plural(lit.nodes.length, 'node')} on the map`)}</h3>${rows ? `<ul class="hx-forge-files">${rows}</ul>` : ''}${missing}`;
|
|
87
|
+
return { primary: logs, notes: `${notes}<p class="hx-forge-notice" data-corn="notice">No node is mapped to this deploy. Say what it restarts under <code class="hx-code">deploys.restarts</code> in cornfield.config.js (docs/deploys.md).</p>`, sections: [] };
|
|
90
88
|
}
|
|
91
|
-
|
|
89
|
+
const rows = lit.nodes.map((n) => `<li class="hx-forge-file" data-corn="file"><button data-corn="node-chip" type="button" class="hx-forge-node" data-forge-node="${escHtml(n.id)}" aria-label="Show ${escHtml(n.label)} on the map${isNodeVisible(n) ? '' : ' (its layer is off)'}">${escHtml(n.label)}${isNodeVisible(n) ? '' : ' · layer off'}</button> <span class="hx-faint">${escHtml(n.type)}</span></li>`).join('');
|
|
90
|
+
const missing = lit.missing.length ? `<p class="hx-forge-notice" data-corn="notice">${escHtml(lit.missing.join(', '))} ${lit.missing.length === 1 ? 'is' : 'are'} named in the config but not on the map.</p>` : '';
|
|
91
|
+
return { primary: logs, notes, sections: [sectionHtml({ key: 'restarted', title: 'Restarted', count: lit.nodes.length, body: `${rows ? `<ul class="hx-forge-files">${rows}</ul>` : `<p class="hx-faint">${escHtml(plural(0, 'node'))} on the map.</p>`}${missing}` })] };
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
/** What a screen reader hears when a deploy is selected */
|
|
@@ -101,5 +101,5 @@ export function install(ctx) {
|
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
// what other parts put in the panel gets its parts (a hook is a part of the same name)
|
|
104
|
-
Object.assign(fn, { selectDeploy, showDeploy, clearDeploy, restartWords, deployHtml: (...a) => withParts(deployHtml(...a)),
|
|
104
|
+
Object.assign(fn, { selectDeploy, showDeploy, clearDeploy, restartWords, deployHtml: (...a) => withParts(deployHtml(...a)), deployParts, deploySelectionWords });
|
|
105
105
|
}
|