cornfield 0.36.1 → 0.38.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/strings.js +10 -0
- package/explorer/capped.js +1 -1
- package/explorer/check.js +3 -2
- package/explorer/cloud-model.js +1 -1
- package/explorer/corn-state.js +22 -2
- package/explorer/explorer.css +63 -0
- package/explorer/flows.js +5 -5
- package/explorer/forge-panel.js +207 -46
- package/explorer/house.js +6 -6
- package/explorer/index.html +101 -95
- package/explorer/layers.js +4 -4
- package/explorer/live-model.js +1 -1
- package/explorer/live.js +8 -5
- package/explorer/mockups-model.js +1 -1
- package/explorer/mockups.js +2 -0
- package/explorer/panels.js +9 -4
- package/explorer/plugins.js +1 -1
- package/explorer/proposal-model.js +21 -15
- package/explorer/proposal.js +10 -8
- package/explorer/review.js +3 -2
- package/explorer/runs-view.js +20 -17
- package/explorer/scenario-ui.js +5 -4
- package/explorer/sheet-model.js +67 -19
- package/explorer/sheets.js +140 -14
- package/explorer/waiting-line.js +57 -0
- package/explorer/waiting-model.js +287 -0
- package/explorer/waiting-view.js +37 -0
- package/explorer/whatif.js +42 -41
- package/package.json +1 -1
- package/server/forge-forgejo.js +1 -1
- package/server/forge-github.js +1 -1
- package/server/forge.js +1 -1
- package/server/proposal-pulls.js +93 -2
- package/server/proposals.js +4 -2
- package/server/reviews.js +5 -4
- package/server/submit-review.js +2 -1
package/explorer/live.js
CHANGED
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
import { state, nodeById, escHtml, touchScene } from './state.js';
|
|
28
28
|
import { render, ensureFlowLoop } from './render.js';
|
|
29
29
|
import { setMap } from './view.js';
|
|
30
|
+
import { cornState } from './corn-state.js';
|
|
30
31
|
import { onLayersChange, renderLayerToggles } from './layers.js';
|
|
31
32
|
import { chipModel, createLiveRunner, groupsOf, liveDetailsHtml, liveWanted } from './live-model.js';
|
|
32
33
|
|
|
@@ -140,6 +141,8 @@ function paintChip() {
|
|
|
140
141
|
if (text) text.textContent = chip.text;
|
|
141
142
|
const btn = $('live-chip');
|
|
142
143
|
if (btn) {
|
|
144
|
+
const live = cornState(chip.tone); // success, waiting (stale), stopped (off), failure (unavailable) or running (loading)
|
|
145
|
+
if (live) btn.dataset.cornState = live; else delete btn.dataset.cornState;
|
|
143
146
|
btn.title = chip.text;
|
|
144
147
|
btn.setAttribute('aria-label', chip.text || 'Live layer');
|
|
145
148
|
btn.setAttribute('aria-expanded', String(menuOpen));
|
|
@@ -158,7 +161,7 @@ function paintChip() {
|
|
|
158
161
|
<p class="hx-live-line hx-live-line--main">${escHtml(chip.text)}</p>
|
|
159
162
|
${chip.lines.map((l) => `<p class="hx-live-line">${escHtml(l)}</p>`).join('')}
|
|
160
163
|
${chip.note ? `<p class="hx-live-line hx-faint">${escHtml(chip.note)}</p>` : ''}
|
|
161
|
-
${chip.href && !asking ? `<p class="hx-live-line"><a class="hx-link" href="${escHtml(chip.href)}">Where to set a token ↗</a></p>` : ''}`;
|
|
164
|
+
${chip.href && !asking ? `<p class="hx-live-line"><a data-corn="text-link" class="hx-link" href="${escHtml(chip.href)}">Where to set a token ↗</a></p>` : ''}`;
|
|
162
165
|
// The field is painted only when it changes, so a repaint (a refresh, the stale tick) never drops what is being typed
|
|
163
166
|
const fieldHtml = asking ? tokenFieldHtml(tok, chip.href) : '';
|
|
164
167
|
if (field.dataset.painted !== String(asking)) {
|
|
@@ -168,7 +171,7 @@ function paintChip() {
|
|
|
168
171
|
field.hidden = !asking;
|
|
169
172
|
row.innerHTML = `
|
|
170
173
|
<span class="hx-live-buttons">
|
|
171
|
-
<button type="button" class="hx-btn" data-live="refresh"${loading ? ' disabled' : ''}>Refresh</button>
|
|
174
|
+
<button data-corn-kind="secondary" type="button" class="hx-btn" data-live="refresh"${loading ? ' disabled' : ''}>Refresh</button>
|
|
172
175
|
${has ? '<button type="button" class="hx-btn" data-live="token-forget" data-corn-kind="danger">Forget token</button>' : ''}
|
|
173
176
|
</span>
|
|
174
177
|
<span class="hx-faint">${escHtml(source && source.name ? source.name : '')}</span>`;
|
|
@@ -218,11 +221,11 @@ function tokenFieldHtml(tok, href) {
|
|
|
218
221
|
return `
|
|
219
222
|
<label class="hx-live-token-label" for="live-token-input">${escHtml(label)}</label>
|
|
220
223
|
<div class="hx-live-token-row">
|
|
221
|
-
<input id="live-token-input" class="hx-field hx-live-token-input" type="password" data-live="token-input" autocomplete="off" autocapitalize="off" spellcheck="false" />
|
|
222
|
-
<button type="button" class="hx-btn" data-live="token-save">Save</button>
|
|
224
|
+
<input data-corn="control" id="live-token-input" class="hx-field hx-live-token-input" type="password" data-live="token-input" autocomplete="off" autocapitalize="off" spellcheck="false" />
|
|
225
|
+
<button data-corn-kind="secondary" type="button" class="hx-btn" data-live="token-save">Save</button>
|
|
223
226
|
</div>
|
|
224
227
|
${tok.help ? `<p class="hx-live-line hx-faint hx-live-help">${withCode(tok.help)}</p>` : ''}
|
|
225
|
-
${href ? `<p class="hx-live-line hx-live-second"><a class="hx-link" href="${escHtml(href)}">or set it there ↗</a></p>` : ''}`;
|
|
228
|
+
${href ? `<p class="hx-live-line hx-live-second"><a data-corn="text-link" class="hx-link" href="${escHtml(href)}">or set it there ↗</a></p>` : ''}`;
|
|
226
229
|
}
|
|
227
230
|
|
|
228
231
|
/** Saves what is in the field (then empties it) and asks the source again at once; an empty field saves nothing */
|
|
@@ -57,7 +57,7 @@ export function mockupsFor(proposal, slug, source, nodeId, states = {}) {
|
|
|
57
57
|
export function mockupsSectionHtml(items) {
|
|
58
58
|
if (!items.length) return '';
|
|
59
59
|
const rows = items.map((m) => `<li class="hx-mockup-item" data-corn="row">
|
|
60
|
-
<button type="button" class="hx-btn hx-mockup-open" data-mockup="${m.index}" aria-haspopup="dialog">${escHtml(m.title)}<span class="hx-sr-only"> (${m.type === 'page' ? 'page' : 'image'}, opens in a window)</span></button>
|
|
60
|
+
<button data-corn-kind="secondary" type="button" class="hx-btn hx-mockup-open" data-mockup="${m.index}" aria-haspopup="dialog">${escHtml(m.title)}<span class="hx-sr-only"> (${m.type === 'page' ? 'page' : 'image'}, opens in a window)</span></button>
|
|
61
61
|
<span class="hx-mockup-state hx-mockup-state--${escHtml(m.state)}" data-corn="state-pill"${cornStateAttr(m.state)}>${escHtml(stateWords(m.state))}</span>
|
|
62
62
|
</li>`).join('');
|
|
63
63
|
return `<div class="hx-sec hx-mockups" data-mockups data-corn="section">
|
package/explorer/mockups.js
CHANGED
|
@@ -132,6 +132,7 @@ export function openMockup(index, opener = null) {
|
|
|
132
132
|
const close = document.createElement('button');
|
|
133
133
|
close.type = 'button';
|
|
134
134
|
close.className = 'hx-btn hx-mockup-close';
|
|
135
|
+
close.dataset.cornKind = 'secondary';
|
|
135
136
|
close.dataset.mockupClose = '';
|
|
136
137
|
close.textContent = 'Close';
|
|
137
138
|
head.append(title, close);
|
|
@@ -143,6 +144,7 @@ export function openMockup(index, opener = null) {
|
|
|
143
144
|
status.textContent = stateWords(item.state);
|
|
144
145
|
const stage = document.createElement('div');
|
|
145
146
|
stage.className = 'hx-mockup-stage';
|
|
147
|
+
stage.dataset.corn = 'mockup-stage';
|
|
146
148
|
if (item.type === 'page') {
|
|
147
149
|
const frame = document.createElement('iframe');
|
|
148
150
|
frame.className = 'hx-mockup-frame';
|
package/explorer/panels.js
CHANGED
|
@@ -12,11 +12,12 @@ import { flowSummary } from './flows.js';
|
|
|
12
12
|
import { clearScenario } from './scenario-ui.js';
|
|
13
13
|
import { kindOfMark, fieldRows, MARK_WORDS } from './proposal-model.js';
|
|
14
14
|
import { nodeMockupsHtml } from './mockups-model.js';
|
|
15
|
-
import { collapseSheet, isPhone, measureCovered, onCoveredChange } from './sheets.js';
|
|
15
|
+
import { collapseSheet, isPhone, measureCovered, onCoveredChange, showSheet } from './sheets.js';
|
|
16
16
|
import { panIntoView } from './camera.js';
|
|
17
17
|
import { liveSection, hydrateLivePhotos } from './live.js';
|
|
18
18
|
import { cloudPanelHtml } from './cloud-model.js';
|
|
19
19
|
import { t } from './strings.js';
|
|
20
|
+
import { markStateAttr, markState } from './corn-state.js';
|
|
20
21
|
import { fileUrl } from './file-url.js';
|
|
21
22
|
import { capped, toggleCapped } from './capped.js';
|
|
22
23
|
import { dismissHint } from './hint.js';
|
|
@@ -61,7 +62,7 @@ function dataSummary(node) {
|
|
|
61
62
|
|
|
62
63
|
if (node.type === 'app') {
|
|
63
64
|
const served = node.deployed
|
|
64
|
-
? line(`${/^https?:\/\//.test(node.url) ? `<a class="hx-link" href="${escHtml(node.url)}" target="_blank" rel="noreferrer">${escHtml(node.url)}</a>` : code(node.url)} → ${(node.upstreams || []).map(code).join(' ')}${node.stack ? ` <span class="hx-faint">[${escHtml(node.stack)}]</span>` : ''}`)
|
|
65
|
+
? line(`${/^https?:\/\//.test(node.url) ? `<a data-corn="text-link" class="hx-link" href="${escHtml(node.url)}" target="_blank" rel="noreferrer">${escHtml(node.url)}</a>` : code(node.url)} → ${(node.upstreams || []).map(code).join(' ')}${node.stack ? ` <span class="hx-faint">[${escHtml(node.stack)}]</span>` : ''}`)
|
|
65
66
|
: line('Not deployed by any stack in this repo');
|
|
66
67
|
const runsOn = state.edges.filter((e) => e.kind === 'runs-on' && e.from === node.id)
|
|
67
68
|
.map((e) => line(`${nm(e.to)}${(e.mappings || []).map((m) => `<div class="hx-faint">${code(m.host)} → ${code(m.upstream)}${m.service ? ` = ${code(m.service)}` : ''}</div>`).join('')}`));
|
|
@@ -158,7 +159,7 @@ function threadsSection(node) {
|
|
|
158
159
|
if (!index) return '';
|
|
159
160
|
const threads = index.for(node.id);
|
|
160
161
|
// "Start a thread about this" shows whenever threads are on and a maintainer is signed in (the panel only sets `start` then)
|
|
161
|
-
const start = index.start ? `<button type="button" class="hx-btn hx-btn--quiet hx-textact" data-thread-start="${escHtml(node.id)}" aria-label="Start a thread about this: opens the New idea form for ${escHtml(index.forge())}, with this node mentioned">Start a thread about this</button>` : '';
|
|
162
|
+
const start = index.start ? `<button data-corn-kind="quiet" type="button" class="hx-btn hx-btn--quiet hx-textact" data-thread-start="${escHtml(node.id)}" aria-label="Start a thread about this: opens the New idea form for ${escHtml(index.forge())}, with this node mentioned">Start a thread about this</button>` : '';
|
|
162
163
|
if (!threads || !threads.length) return start;
|
|
163
164
|
const rows = threads.map((th) => {
|
|
164
165
|
const count = Number(th.comments) || 0;
|
|
@@ -214,7 +215,7 @@ function diffSection(node) {
|
|
|
214
215
|
if (kind === 'changed') {
|
|
215
216
|
for (const r of fieldRows(node)) rows.push(row(r.field, `<span class="hx-change-before">${escHtml(r.before) || '<em>nothing</em>'}</span> <span aria-hidden="true">→</span><span class="hx-sr-only"> became </span> <span class="hx-change-after">${escHtml(r.after) || '<em>nothing</em>'}</span>`));
|
|
216
217
|
}
|
|
217
|
-
return `<div class="hx-sec-block" data-proposal-mark="${escHtml(node.mark)}" data-corn="section"><h3 class="hx-sec-title">In this proposal</h3>${node.why ? `<p class="hx-why">${escHtml(node.why)}</p>` : ''}<div class="hx-diff hx-diff--${escHtml(kind)}">${rows.join('')}</div></div>`;
|
|
218
|
+
return `<div class="hx-sec-block" data-proposal-mark="${escHtml(node.mark)}" data-corn="section"><h3 class="hx-sec-title">In this proposal</h3>${node.why ? `<p class="hx-why">${escHtml(node.why)}</p>` : ''}<div class="hx-diff hx-diff--${escHtml(kind)}" data-corn="diff-block"${markStateAttr(node.mark)}>${rows.join('')}</div></div>`;
|
|
218
219
|
}
|
|
219
220
|
|
|
220
221
|
// ---------------------------------------------------------------------------
|
|
@@ -246,6 +247,8 @@ export async function selectNode(node) {
|
|
|
246
247
|
const pill = diffPillWords(node);
|
|
247
248
|
$('drawer-diff').textContent = pill;
|
|
248
249
|
$('drawer-diff').hidden = !pill;
|
|
250
|
+
const pillState = markState(pill ? node.mark : ''); // added, changed, removed or edit
|
|
251
|
+
if (pillState) $('drawer-diff').dataset.cornState = pillState; else delete $('drawer-diff').dataset.cornState;
|
|
249
252
|
const lead = $('drawer-description');
|
|
250
253
|
lead.textContent = node.desc || '';
|
|
251
254
|
lead.hidden = !node.desc;
|
|
@@ -270,6 +273,7 @@ export async function selectNode(node) {
|
|
|
270
273
|
if (route) openBtn.href = node.url; else openBtn.removeAttribute('href');
|
|
271
274
|
openBtn.hidden = !route;
|
|
272
275
|
openBtn.className = file ? 'hx-btn hx-btn--quiet hx-foot-btn' : 'hx-open';
|
|
276
|
+
if (file) openBtn.dataset.cornKind = 'quiet'; else openBtn.dataset.cornKind = 'primary'; // the route is the primary action when there is no file
|
|
273
277
|
openBtn.textContent = `${t('openRoute')} ↗`;
|
|
274
278
|
fileBtn.textContent = `${t('openFile')} ↗`;
|
|
275
279
|
const run = $('drawer-run-btn');
|
|
@@ -278,6 +282,7 @@ export async function selectNode(node) {
|
|
|
278
282
|
$('spec-drawer').classList.add('drawer-open');
|
|
279
283
|
$('spec-drawer').inert = false; // closed, it waits off screen: inert, so Tab never reaches its buttons (MAP-02)
|
|
280
284
|
$('drawer-backdrop').hidden = false;
|
|
285
|
+
showSheet('drawer'); // on a phone it takes Work's place (the node sheet and Work take turns), and comes back from away when its node is tapped again
|
|
281
286
|
keepSelectedInView();
|
|
282
287
|
}
|
|
283
288
|
|
package/explorer/plugins.js
CHANGED
|
@@ -93,7 +93,7 @@ function paintFooter(doc, config) {
|
|
|
93
93
|
if (!foot) return;
|
|
94
94
|
const words = [t('poweredBy'), typeof config.version === 'string' ? config.version : ''].filter(Boolean).join(' ');
|
|
95
95
|
const home = config.brand && typeof config.brand.poweredBy === 'string' && /^https:\/\//.test(config.brand.poweredBy) ? config.brand.poweredBy : '';
|
|
96
|
-
foot.innerHTML = home ? `<a href="${escHtml(home)}" target="_blank" rel="noreferrer">${escHtml(words)}</a>` : escHtml(words);
|
|
96
|
+
foot.innerHTML = home ? `<a data-corn="text-link" href="${escHtml(home)}" target="_blank" rel="noreferrer">${escHtml(words)}</a>` : escHtml(words);
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
const FORGE_NAMES = { github: 'GitHub', forgejo: 'Forgejo' };
|
|
@@ -19,6 +19,8 @@
|
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
21
|
import { escHtml } from './state.js';
|
|
22
|
+
import { markStateAttr, stateIconHtml } from './corn-state.js';
|
|
23
|
+
import { specStateOf, specStateWords, SPEC_STATE_WORDS, SPEC_STATE_CORN } from './waiting-model.js';
|
|
22
24
|
|
|
23
25
|
export const PROPOSAL_VIEWS = ['before', 'diff', 'after'];
|
|
24
26
|
|
|
@@ -207,10 +209,10 @@ export function proposalPanelHtml(item) {
|
|
|
207
209
|
if (!hasMark(item)) return '';
|
|
208
210
|
const rows = fieldRows(item);
|
|
209
211
|
const body = rows.map((r) => (item.mark === 'changed'
|
|
210
|
-
? `<div class="hx-change"><span class="hx-change-field">${escHtml(r.field)}</span><span class="hx-change-before">${escHtml(r.before) || '<em>nothing</em>'}</span><span class="hx-change-arrow" aria-hidden="true">→</span><span class="hx-change-after">${escHtml(r.after) || '<em>nothing</em>'}</span></div>`
|
|
211
|
-
: `<div class="hx-change"><span class="hx-change-field">${escHtml(r.field)}</span><span class="hx-change-after">${escHtml(r.after)}</span></div>`)).join('');
|
|
212
|
+
? `<div class="hx-change" data-corn="field-change"><span class="hx-change-field">${escHtml(r.field)}</span><span class="hx-change-before">${escHtml(r.before) || '<em>nothing</em>'}</span><span class="hx-change-arrow" aria-hidden="true">→</span><span class="hx-change-after">${escHtml(r.after) || '<em>nothing</em>'}</span></div>`
|
|
213
|
+
: `<div class="hx-change" data-corn="field-change"><span class="hx-change-field">${escHtml(r.field)}</span><span class="hx-change-after">${escHtml(r.after)}</span></div>`)).join('');
|
|
212
214
|
return `<div class="hx-sec hx-proposal-sec hx-proposal-sec--${escHtml(item.mark)}" data-proposal-mark="${escHtml(item.mark)}" data-corn="section">
|
|
213
|
-
<strong class="hx-strong"><span class="hx-mark-dot hx-mark-dot--${escHtml(item.mark)}"></span>${escHtml(item.mark === 'edit' ? `${item.editOp === 'removed' ? 'Removed' : 'Added'} by your edit` : `${MARK_WORDS[item.mark] || item.mark} by this proposal`)}</strong>
|
|
215
|
+
<strong class="hx-strong"><span class="hx-mark-dot hx-mark-dot--${escHtml(item.mark)}" data-corn="mark-dot"${markStateAttr(item.mark)}></span>${escHtml(item.mark === 'edit' ? `${item.editOp === 'removed' ? 'Removed' : 'Added'} by your edit` : `${MARK_WORDS[item.mark] || item.mark} by this proposal`)}</strong>
|
|
214
216
|
${item.why ? `<div class="hx-why">${escHtml(item.why)}</div>` : ''}
|
|
215
217
|
${body}
|
|
216
218
|
</div>`;
|
|
@@ -220,9 +222,6 @@ export function proposalPanelHtml(item) {
|
|
|
220
222
|
// A proposal as a row of the Work panel's Specs tab
|
|
221
223
|
// ---------------------------------------------------------------------------
|
|
222
224
|
|
|
223
|
-
/** What a listing entry's state pill says: its spec PR's state, or "Local" for a proposal that is only in a checkout or a worktree */
|
|
224
|
-
export const specState = (entry) => (entry.pull ? (entry.pull.draft ? 'Draft' : 'Open') : 'Local');
|
|
225
|
-
|
|
226
225
|
/** Where a listing entry is, as a line of meta: "PR #11", or the checkout or worktree it is in; a proposal that is also somewhere else says so ("PR #11, and a copy in the checkout") */
|
|
227
226
|
export function specWhere(entry) {
|
|
228
227
|
const place = (source) => (source === 'checkout' ? 'the checkout' : `worktree ${source}`);
|
|
@@ -259,22 +258,28 @@ export function mergeSpecs(entries) {
|
|
|
259
258
|
}
|
|
260
259
|
|
|
261
260
|
/**
|
|
262
|
-
* One row: title, a
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
*
|
|
261
|
+
* One row: title, a pill that says its review state (To decide, Changed since approved, Sent back, Approved, Draft PR, Local, spec 0010 D4),
|
|
262
|
+
* who and when beside it ("Approved by maintainer-one \u00b7 2 hours ago", "Waiting 2 days"), a line of what it is for, and the meta (spec number,
|
|
263
|
+
* where it is, +added ~changed \u2212removed, scenarios). A review that could not be read says so, with a way to try again, and never looks
|
|
264
|
+
* unreviewed. A proposal that could not be read is a row that says why and opens nothing. Same `open-proposal` action as the Proposals menu's row.
|
|
265
|
+
* What the forge said (a login, a date) is escaped; the pill's state is one of a fixed list.
|
|
266
|
+
* @param {{ slug: string, source: string, title?: string, summary?: string, spec?: string, pull?: {number: number, draft?: boolean}, review?: object | null, counts?: {added?: number, changed?: number, removed?: number, scenarios?: number}, errors?: number, error?: string }} entry
|
|
267
|
+
* @param {{ current?: {slug: string, source: string} | null, nowMs?: number }} [opts] the proposal that is open now; the clock
|
|
266
268
|
*/
|
|
267
|
-
export function specRowHtml(entry, { current = null } = {}) {
|
|
269
|
+
export function specRowHtml(entry, { current = null, nowMs = Date.now() } = {}) {
|
|
268
270
|
const head = `<span class="hx-forge-title">${escHtml(entry.title || entry.slug)}</span>`;
|
|
269
271
|
if (entry.error) {
|
|
270
272
|
return `<li class="hx-forge-item"><div class="hx-forge-row hx-forge-spec" data-corn="row">${head}<span class="hx-forge-sum hx-error-text">${escHtml(entry.error)}</span><span class="hx-forge-meta">${escHtml(specWhere(entry))}</span></div></li>`;
|
|
271
273
|
}
|
|
272
|
-
const state =
|
|
273
|
-
const
|
|
274
|
+
const { state } = specStateOf(entry);
|
|
275
|
+
const corn = SPEC_STATE_CORN[state];
|
|
276
|
+
const pill = `<span class="hx-forge-state hx-forge-state--${corn}" data-corn="review-state" data-corn-state="${corn}">${stateIconHtml(corn)}${escHtml(SPEC_STATE_WORDS[state])}</span>`;
|
|
274
277
|
const c = entry.counts || {};
|
|
278
|
+
const said = specStateWords(entry, nowMs);
|
|
275
279
|
const meta = [
|
|
276
280
|
entry.spec ? `<span>spec ${escHtml(entry.spec)}</span>` : '',
|
|
277
281
|
`<span>${escHtml(specWhere(entry))}</span>`,
|
|
282
|
+
said ? `<span class="hx-forge-reviewed">${escHtml(said)}</span>` : '',
|
|
278
283
|
c.added ? `<span class="hx-forge-add" title="${c.added} added">+${c.added}</span>` : '',
|
|
279
284
|
c.changed ? `<span class="hx-forge-chg" title="${c.changed} changed">~${c.changed}</span>` : '',
|
|
280
285
|
c.removed ? `<span class="hx-forge-del" title="${c.removed} removed">\u2212${c.removed}</span>` : '',
|
|
@@ -282,9 +287,10 @@ export function specRowHtml(entry, { current = null } = {}) {
|
|
|
282
287
|
entry.errors ? `<span class="hx-warn">${entry.errors} ${entry.errors === 1 ? 'problem' : 'problems'}</span>` : '',
|
|
283
288
|
].filter(Boolean).join('');
|
|
284
289
|
const mine = !!current && current.slug === entry.slug && (current.source === entry.source || (Array.isArray(entry.also) && entry.also.includes(current.source)));
|
|
290
|
+
const unread = state === 'unknown' ? `<p class="hx-forge-meta hx-forge-unread" data-corn="message" data-corn-state="failure">${escHtml(entry.review && entry.review.error ? entry.review.error : 'The forge could not be asked.')} <button type="button" class="hx-btn hx-forge-act" data-corn-kind="quiet" data-action="retry-forge" aria-label="Try again: ${escHtml(entry.title || entry.slug)}">Try again</button></p>` : '';
|
|
285
291
|
return `<li class="hx-forge-item"><button type="button" class="hx-forge-row hx-forge-spec" data-action="open-proposal" data-slug="${escHtml(entry.slug)}" data-source="${escHtml(entry.source)}" aria-pressed="${mine}" data-corn="row">`
|
|
286
|
-
+ `<span class="hx-forge-line">${head}
|
|
287
|
-
+ `${entry.summary ? `<span class="hx-forge-sum">${escHtml(entry.summary)}</span>` : ''}<span class="hx-forge-meta hx-forge-facts">${meta}</span></button
|
|
292
|
+
+ `<span class="hx-forge-line">${head}${pill}</span>`
|
|
293
|
+
+ `${entry.summary ? `<span class="hx-forge-sum">${escHtml(entry.summary)}</span>` : ''}<span class="hx-forge-meta hx-forge-facts">${meta}</span></button>${unread}</li>`;
|
|
288
294
|
}
|
|
289
295
|
|
|
290
296
|
// ---------------------------------------------------------------------------
|
package/explorer/proposal.js
CHANGED
|
@@ -35,6 +35,7 @@ import { reviewWords } from './review-model.js';
|
|
|
35
35
|
import { collapseSheet, visibleMapRect, isPhone } from './sheets.js';
|
|
36
36
|
import { announce } from './keyboard.js';
|
|
37
37
|
import { t } from './strings.js';
|
|
38
|
+
import { markStateAttr } from './corn-state.js';
|
|
38
39
|
import { isOffline } from './connection.js';
|
|
39
40
|
|
|
40
41
|
const $ = (id) => document.getElementById(id);
|
|
@@ -47,8 +48,9 @@ const $ = (id) => document.getElementById(id);
|
|
|
47
48
|
* - `closed()` the proposal was closed
|
|
48
49
|
* - `bar(open)` the bar was drawn: redraw the editing controls
|
|
49
50
|
* - `openSpecs()` the Work panel's Specs tab, for a bad link's way on (forge-panel.js sets it; without it the header's Proposals menu opens)
|
|
51
|
+
* - `reviewed()` a review was posted (Approve or Send back): what waits on the maintainer is read again (forge-panel.js sets it)
|
|
50
52
|
*/
|
|
51
|
-
export const hooks = { effective: null, mark: null, beforeClose: null, closed: null, bar: null, openSpecs: null };
|
|
53
|
+
export const hooks = { effective: null, mark: null, beforeClose: null, closed: null, bar: null, openSpecs: null, reviewed: null };
|
|
52
54
|
|
|
53
55
|
/** Whether the open proposal's source goes in the address (see `showProposal`) */
|
|
54
56
|
let pinnedSource = false;
|
|
@@ -361,7 +363,7 @@ export function renderBar() {
|
|
|
361
363
|
|
|
362
364
|
const counts = summarize(p);
|
|
363
365
|
const chip = $('proposal-chip');
|
|
364
|
-
chip.innerHTML = barCounts(counts).map((c) => `${c.mark ? `<span class="hx-mark-dot hx-mark-dot--${c.mark}" aria-hidden="true"></span>` : ''}${escHtml(c.text)}`).join('<span class="hx-proposal-sep" aria-hidden="true"> · </span>');
|
|
366
|
+
chip.innerHTML = barCounts(counts).map((c) => `${c.mark ? `<span class="hx-mark-dot hx-mark-dot--${c.mark}" data-corn="mark-dot"${markStateAttr(c.mark)} aria-hidden="true"></span>` : ''}${escHtml(c.text)}`).join('<span class="hx-proposal-sep" aria-hidden="true"> · </span>');
|
|
365
367
|
chip.title = 'Click for the list of changes.';
|
|
366
368
|
$('proposal-mode').textContent = t(state.proposalView);
|
|
367
369
|
|
|
@@ -391,10 +393,10 @@ function renderChanges() {
|
|
|
391
393
|
const rows = [];
|
|
392
394
|
for (const mark of [...MARKS, 'edit']) {
|
|
393
395
|
for (const n of state.nodes.filter((x) => x.mark === mark)) {
|
|
394
|
-
rows.push(`<button type="button" class="hx-change-row" data-action="proposal-focus" data-kind="node" data-key="${escHtml(n.id)}" data-corn="row"><span class="hx-mark-dot hx-mark-dot--${mark}"></span><span class="hx-change-what">${escHtml(MARK_WORDS[mark])}</span><span class="hx-name">${escHtml(n.label)}</span><span class="hx-faint">${escHtml(n.type)}</span></button>`);
|
|
396
|
+
rows.push(`<button type="button" class="hx-change-row" data-action="proposal-focus" data-kind="node" data-key="${escHtml(n.id)}" data-corn="row"><span class="hx-mark-dot hx-mark-dot--${mark}" data-corn="mark-dot"${markStateAttr(mark)}></span><span class="hx-change-what">${escHtml(MARK_WORDS[mark])}</span><span class="hx-name">${escHtml(n.label)}</span><span class="hx-faint">${escHtml(n.type)}</span></button>`);
|
|
395
397
|
}
|
|
396
398
|
for (const e of state.edges.filter((x) => x.mark === mark && said.has(edgeKey(x)))) {
|
|
397
|
-
rows.push(`<button type="button" class="hx-change-row" data-action="proposal-focus" data-kind="edge" data-key="${escHtml(edgeKey(e))}" data-corn="row"><span class="hx-mark-dot hx-mark-dot--${mark}"></span><span class="hx-change-what">${escHtml(MARK_WORDS[mark])}</span><span class="hx-name">${escHtml(nameOf(e.from))} → ${escHtml(nameOf(e.to))}</span><span class="hx-faint">${escHtml(e.kind || 'ownership')}</span></button>`);
|
|
399
|
+
rows.push(`<button type="button" class="hx-change-row" data-action="proposal-focus" data-kind="edge" data-key="${escHtml(edgeKey(e))}" data-corn="row"><span class="hx-mark-dot hx-mark-dot--${mark}" data-corn="mark-dot"${markStateAttr(mark)}></span><span class="hx-change-what">${escHtml(MARK_WORDS[mark])}</span><span class="hx-name">${escHtml(nameOf(e.from))} → ${escHtml(nameOf(e.to))}</span><span class="hx-faint">${escHtml(e.kind || 'ownership')}</span></button>`);
|
|
398
400
|
}
|
|
399
401
|
}
|
|
400
402
|
list.innerHTML = rows.join('') || '<p class="hx-faint">This proposal changes nothing on the map.</p>';
|
|
@@ -537,7 +539,7 @@ function renderMenu(loading = false) {
|
|
|
537
539
|
else if (!listing || listing.length === 0) body = '<p class="hx-faint hx-proposal-empty">No proposals</p>';
|
|
538
540
|
else body = `<div class="hx-proposal-list" role="list">${listing.map((e) => `<div role="listitem">${proposalRowHtml(e, current)}</div>`).join('')}</div>`;
|
|
539
541
|
const forge = forgeProblem && !listingProblem ? `<p class="hx-error-text hx-proposal-empty">The spec PRs could not be listed: ${escHtml(forgeProblem)}</p>` : '';
|
|
540
|
-
menu.innerHTML = `<div class="hx-menu-title hx-menu-head"><span>${escHtml(t('proposals'))}</span></div>${forge}${body}`;
|
|
542
|
+
menu.innerHTML = `<div class="hx-menu-title hx-menu-head" data-corn="menu-title"><span>${escHtml(t('proposals'))}</span></div>${forge}${body}`;
|
|
541
543
|
}
|
|
542
544
|
|
|
543
545
|
// ---------------------------------------------------------------------------
|
|
@@ -573,7 +575,7 @@ export function markedEdgeAt(x, y, tolerance) {
|
|
|
573
575
|
export function showEdgePanel(edge) {
|
|
574
576
|
closeDrawer(); // clears a node selection and any panel still loading
|
|
575
577
|
state.selectedEdge = edge;
|
|
576
|
-
const row = (label, value) => (value ? `<div class="hx-fact"><div class="hx-fact-k">${escHtml(label)}</div><div class="hx-fact-v">${escHtml(value)}</div></div>` : '');
|
|
578
|
+
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>` : '');
|
|
577
579
|
const facts = row('Kind', kindOf(edge)) + row('Flow', edge.flow) + row('Label', edge.label) + row('Reads', Array.isArray(edge.keys) ? edge.keys.join(', ') : '');
|
|
578
580
|
|
|
579
581
|
$('drawer-title').textContent = `${nameOf(edge.from)} → ${nameOf(edge.to)}`;
|
|
@@ -585,8 +587,8 @@ export function showEdgePanel(edge) {
|
|
|
585
587
|
$('drawer-description').hidden = true;
|
|
586
588
|
$('drawer-meta-list').innerHTML = `${facts ? `<div class="hx-facts">${facts}</div>` : ''}
|
|
587
589
|
<div class="hx-facts">
|
|
588
|
-
<div class="hx-fact"><div class="hx-fact-k">From</div><div class="hx-fact-v"><button type="button" class="hx-linkbtn" data-action="select-node" data-id="${escHtml(edge.from)}">${escHtml(nameOf(edge.from))}</button></div></div>
|
|
589
|
-
<div class="hx-fact"><div class="hx-fact-k">To</div><div class="hx-fact-v"><button type="button" class="hx-linkbtn" data-action="select-node" data-id="${escHtml(edge.to)}">${escHtml(nameOf(edge.to))}</button></div></div>
|
|
590
|
+
<div class="hx-fact" data-corn="section"><div class="hx-fact-k">From</div><div class="hx-fact-v"><button data-corn="node-link" type="button" class="hx-linkbtn" data-action="select-node" data-id="${escHtml(edge.from)}">${escHtml(nameOf(edge.from))}</button></div></div>
|
|
591
|
+
<div class="hx-fact" data-corn="section"><div class="hx-fact-k">To</div><div class="hx-fact-v"><button data-corn="node-link" type="button" class="hx-linkbtn" data-action="select-node" data-id="${escHtml(edge.to)}">${escHtml(nameOf(edge.to))}</button></div></div>
|
|
590
592
|
</div>${proposalPanelHtml(edge)}`;
|
|
591
593
|
$('drawer-open-btn').hidden = true;
|
|
592
594
|
$('drawer-file-btn').hidden = true;
|
package/explorer/review.js
CHANGED
|
@@ -73,8 +73,8 @@ function mount() {
|
|
|
73
73
|
root.innerHTML = `
|
|
74
74
|
<p class="hx-review-status" data-review-status hidden><span data-review-verdict role="status"></span><span data-review-when></span></p>
|
|
75
75
|
<div class="hx-review-form" id="review-form" data-review-form hidden>
|
|
76
|
-
<label class="hx-review-label" for="review-note"></label>
|
|
77
|
-
<textarea id="review-note" class="hx-review-note" rows="2" maxlength="20000"></textarea>
|
|
76
|
+
<label class="hx-review-label" for="review-note" data-corn="review-label"></label>
|
|
77
|
+
<textarea data-corn="review-note" id="review-note" class="hx-review-note" rows="2" maxlength="20000"></textarea>
|
|
78
78
|
<div class="hx-review-row">
|
|
79
79
|
<button type="button" class="hx-btn hx-btn--quiet" data-review-cancel data-corn-kind="quiet">Cancel</button>
|
|
80
80
|
</div>
|
|
@@ -280,6 +280,7 @@ export async function sendReview(verdict) {
|
|
|
280
280
|
const lost = !document.activeElement || document.activeElement === document.body || !document.activeElement.isConnected;
|
|
281
281
|
if (verdict === 'approved') { if (lost) button('approved')?.focus(); }
|
|
282
282
|
else if (wasNoting || lost) button('notes')?.focus();
|
|
283
|
+
if (hooks.reviewed) hooks.reviewed(); // what waits on you changed: the count is read again (spec 0010)
|
|
283
284
|
refreshMockups(); // an approval covers the screens as they are now; a send back leaves them not reviewed
|
|
284
285
|
if (verdict === 'notes') clearEdits(); // the edits went with the note; an approval keeps them, they are in the review
|
|
285
286
|
return true;
|
package/explorer/runs-view.js
CHANGED
|
@@ -9,9 +9,11 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import { relativeTime } from './review-model.js';
|
|
12
|
-
import { runTone, canRetry, aboutWords, runName, statusWords, statusWhy, runMeta, canStop, canAnswer,
|
|
12
|
+
import { runTone, canRetry, aboutWords, runName, statusWords, statusWhy, runMeta, canStop, canAnswer, compareTitle, limitRows, checksWords, timelineWords, nodeLabels, collisionWords, answerWords } from './runs-model.js';
|
|
13
13
|
import { cornState, cornStateAttr, stateIconHtml } from './corn-state.js';
|
|
14
14
|
import { t } from './strings.js';
|
|
15
|
+
import { runGroups } from './waiting-model.js';
|
|
16
|
+
import { runGroupHeadingHtml } from './waiting-view.js';
|
|
15
17
|
|
|
16
18
|
|
|
17
19
|
/**
|
|
@@ -31,7 +33,7 @@ import { t } from './strings.js';
|
|
|
31
33
|
*/
|
|
32
34
|
|
|
33
35
|
/** A link that opens a new tab, said so for a screen reader */
|
|
34
|
-
const link = (ctx, href, text, after = '') => (ctx.safeUrl(href) ? `<a class="hx-link" href="${ctx.esc(href)}" target="_blank" rel="noreferrer">${ctx.esc(text)} <span class="hx-sr-only">(new tab)</span></a>${after}` : '');
|
|
36
|
+
const link = (ctx, href, text, after = '') => (ctx.safeUrl(href) ? `<a data-corn="text-link" class="hx-link" href="${ctx.esc(href)}" target="_blank" rel="noreferrer">${ctx.esc(text)} <span class="hx-sr-only">(new tab)</span></a>${after}` : '');
|
|
35
37
|
|
|
36
38
|
/** The address of a branch on the forge, or null */
|
|
37
39
|
function branchUrl(ctx, branch) {
|
|
@@ -55,7 +57,7 @@ function linksHtml(ctx, run) {
|
|
|
55
57
|
/** A run id that is another run of the list is a button that takes you to it; otherwise it is plain text */
|
|
56
58
|
function runLink(ctx, runId, all) {
|
|
57
59
|
const there = (all || []).find((r) => r.runId === runId);
|
|
58
|
-
return there ? `<button type="button" class="hx-btn hx-forge-act" data-run-goto="${ctx.esc(runId)}" title="Go to this run">${ctx.esc(runName(there))}</button>` : 'an earlier run';
|
|
60
|
+
return there ? `<button data-corn-kind="secondary" type="button" class="hx-btn hx-forge-act" data-run-goto="${ctx.esc(runId)}" title="Go to this run">${ctx.esc(runName(there))}</button>` : 'an earlier run';
|
|
59
61
|
}
|
|
60
62
|
|
|
61
63
|
/** Which run this one starts again, and which start it again */
|
|
@@ -69,7 +71,7 @@ function timelineHtml(ctx, run, all) {
|
|
|
69
71
|
const items = (run.timeline || []).map((e) => {
|
|
70
72
|
const w = timelineWords(e);
|
|
71
73
|
const other = (e.kind === 'retry-of' || e.kind === 'retried-by') && e.ref ? (all || []).find((r) => r.runId === e.ref) : null;
|
|
72
|
-
const goto = other ? ` <button type="button" class="hx-btn hx-forge-act" data-run-goto="${ctx.esc(e.ref)}" aria-label="Go to it: ${ctx.esc(runName(other))}">Go to it</button>` : '';
|
|
74
|
+
const goto = other ? ` <button data-corn-kind="secondary" type="button" class="hx-btn hx-forge-act" data-run-goto="${ctx.esc(e.ref)}" aria-label="Go to it: ${ctx.esc(runName(other))}">Go to it</button>` : '';
|
|
73
75
|
return `<li><time datetime="${ctx.esc(e.at)}" title="${ctx.esc(e.at)}">${ctx.esc(relativeTime(e.at, ctx.now) || e.at)}</time>${ctx.esc(w.what.replace(/run-[0-9A-Za-z]{26}/g, (id) => { const o = (all || []).find((r) => r.runId === id); return o ? runName(o) : 'an earlier run'; }))}${goto}${w.note ? `<span class="hx-run-note">${ctx.esc(w.note)}</span>` : ''}</li>`;
|
|
74
76
|
});
|
|
75
77
|
return `<ol class="hx-run-timeline" id="run-tl-${ctx.esc(run.runId)}" aria-label="Timeline of ${ctx.esc(runName(run))}, oldest first">${items.join('')}</ol>`;
|
|
@@ -94,11 +96,11 @@ function answerHtml(ctx, run) {
|
|
|
94
96
|
const name = ctx.esc(runName(run, ctx.now));
|
|
95
97
|
const off = ctx.busy ? ' disabled' : '';
|
|
96
98
|
const reply = ctx.replies && ctx.replies.get(run.runId) || '';
|
|
97
|
-
return `${run.answer ? answeredHtml(ctx, run) : ''}<div class="hx-run-actions" role="group" aria-label="Answer: ${name}">
|
|
98
|
-
<button type="button" class="hx-btn hx-forge-act" data-run-answer="continue" data-run-id="${id}" aria-label="${ctx.esc(t('continueRun'))}: ${name}"${off}>${ctx.esc(t('continueRun'))}</button>
|
|
99
|
+
return `${run.answer ? answeredHtml(ctx, run) : ''}<div class="hx-run-actions" data-corn="run-actions" role="group" aria-label="Answer: ${name}">
|
|
100
|
+
<button data-corn-kind="secondary" type="button" class="hx-btn hx-forge-act" data-run-answer="continue" data-run-id="${id}" aria-label="${ctx.esc(t('continueRun'))}: ${name}"${off}>${ctx.esc(t('continueRun'))}</button>
|
|
99
101
|
<button type="button" class="hx-btn hx-forge-act" data-run-answer="stop" data-run-id="${id}" aria-label="${ctx.esc(t('stop'))}: ${name}"${off} data-corn-kind="danger">${ctx.esc(t('stop'))}</button></div>
|
|
100
|
-
<label class="hx-forge-field" data-corn="field">Reply to ${ctx.esc(`${run.kind} on ${aboutWords(run.refs)}`)}<input type="text" class="hx-forge-input" data-run-reply="${id}" value="${ctx.esc(reply)}" maxlength="4000" autocomplete="off" /></label>
|
|
101
|
-
<div class="hx-run-actions"><button type="button" class="hx-btn hx-forge-act" data-run-answer="reply" data-run-id="${id}" aria-label="${ctx.esc(t('reply'))}: ${name}"${off}>${ctx.esc(t('reply'))}</button></div>`;
|
|
102
|
+
<label class="hx-forge-field" data-corn="field">Reply to ${ctx.esc(`${run.kind} on ${aboutWords(run.refs)}`)}<input data-corn="control" type="text" class="hx-forge-input" data-run-reply="${id}" value="${ctx.esc(reply)}" maxlength="4000" autocomplete="off" /></label>
|
|
103
|
+
<div class="hx-run-actions" data-corn="run-actions"><button data-corn-kind="secondary" type="button" class="hx-btn hx-forge-act" data-run-answer="reply" data-run-id="${id}" aria-label="${ctx.esc(t('reply'))}: ${name}"${off}>${ctx.esc(t('reply'))}</button></div>`;
|
|
102
104
|
}
|
|
103
105
|
|
|
104
106
|
/**
|
|
@@ -110,8 +112,8 @@ function unsentHtml(ctx, run) {
|
|
|
110
112
|
if (!reply) return '';
|
|
111
113
|
const id = ctx.esc(run.runId);
|
|
112
114
|
return `<p class="hx-forge-why" data-corn="message" data-corn-state="failure">This run is now ${ctx.esc(statusWords(run).toLowerCase())} and no longer waits for a reply, so what you typed was not sent. It is kept here to copy.</p>
|
|
113
|
-
<label class="hx-forge-field" data-corn="field">Your reply, not sent<input type="text" class="hx-forge-input" data-run-reply="${id}" value="${ctx.esc(reply)}" maxlength="4000" autocomplete="off" /></label>
|
|
114
|
-
<div class="hx-run-actions"><button type="button" class="hx-btn hx-forge-act" data-run-discard="${id}" aria-label="Discard: your reply to ${ctx.esc(runName(run, ctx.now))}">Discard</button></div>`;
|
|
115
|
+
<label class="hx-forge-field" data-corn="field">Your reply, not sent<input data-corn="control" type="text" class="hx-forge-input" data-run-reply="${id}" value="${ctx.esc(reply)}" maxlength="4000" autocomplete="off" /></label>
|
|
116
|
+
<div class="hx-run-actions" data-corn="run-actions"><button data-corn-kind="secondary" type="button" class="hx-btn hx-forge-act" data-run-discard="${id}" aria-label="Discard: your reply to ${ctx.esc(runName(run, ctx.now))}">Discard</button></div>`;
|
|
115
117
|
}
|
|
116
118
|
|
|
117
119
|
/** The totals as plain lines (see `totalsLines`), escaped; '' when there are none */
|
|
@@ -146,7 +148,7 @@ export function runHtml(ctx, run, all) {
|
|
|
146
148
|
const note = run.report && run.report.note ? `<p class="hx-forge-meta">Runner: ${ctx.esc(run.report.note)}</p>` : '';
|
|
147
149
|
const answering = canAnswer(run);
|
|
148
150
|
const off = ctx.busy ? ' disabled' : '';
|
|
149
|
-
const retry = canRetry(run) ? `<button type="button" class="hx-btn hx-forge-act" data-forge-retry="${ctx.esc(run.runId)}" aria-label="${ctx.esc(t('startAgain'))}: ${name}"${off}>${ctx.esc(t('startAgain'))}</button>` : '';
|
|
151
|
+
const retry = canRetry(run) ? `<button data-corn-kind="secondary" type="button" class="hx-btn hx-forge-act" data-forge-retry="${ctx.esc(run.runId)}" aria-label="${ctx.esc(t('startAgain'))}: ${name}"${off}>${ctx.esc(t('startAgain'))}</button>` : '';
|
|
150
152
|
const stop = canStop(run) && !answering ? `<button type="button" class="hx-btn hx-forge-act" data-forge-stop="${ctx.esc(run.runId)}" aria-label="${ctx.esc(t('stop'))}: ${name}"${off} data-corn-kind="danger">${ctx.esc(t('stop'))}</button>` : '';
|
|
151
153
|
const names = nodeLabels(run.nodes, ctx.nodes);
|
|
152
154
|
const collision = collisionWords(run, all, ctx.nodes);
|
|
@@ -166,25 +168,26 @@ export function runHtml(ctx, run, all) {
|
|
|
166
168
|
${retryHtml(ctx, run, all)}
|
|
167
169
|
${links ? `<p class="hx-forge-meta">${links}</p>` : ''}
|
|
168
170
|
${answering ? `${answerHtml(ctx, run)}${result}` : unsentHtml(ctx, run)}${run.answer && !answering ? answeredHtml(ctx, run) : ''}
|
|
169
|
-
<div class="hx-run-actions">${stop}${retry}
|
|
170
|
-
<button type="button" class="hx-btn hx-forge-act" data-run-select="${ctx.esc(run.runId)}" aria-pressed="${lit}" aria-label="${lightWords}: ${name}"${noNodes ? ` disabled title="No node on the map yet, so there is nothing to light" aria-describedby="run-nodes-${ctx.esc(run.runId)}"` : ''}>${lightWords}</button>
|
|
171
|
-
<button type="button" class="hx-btn hx-forge-act" data-run-timeline="${ctx.esc(run.runId)}" aria-expanded="${open}" aria-controls="run-tl-${ctx.esc(run.runId)}">Timeline (${count})</button></div>
|
|
171
|
+
<div class="hx-run-actions" data-corn="run-actions">${stop}${retry}
|
|
172
|
+
<button data-corn-kind="secondary" type="button" class="hx-btn hx-forge-act" data-run-select="${ctx.esc(run.runId)}" aria-pressed="${lit}" aria-label="${lightWords}: ${name}"${noNodes ? ` disabled title="No node on the map yet, so there is nothing to light" aria-describedby="run-nodes-${ctx.esc(run.runId)}"` : ''}>${lightWords}</button>
|
|
173
|
+
<button data-corn-kind="secondary" type="button" class="hx-btn hx-forge-act" data-run-timeline="${ctx.esc(run.runId)}" aria-expanded="${open}" aria-controls="run-tl-${ctx.esc(run.runId)}">Timeline (${count})</button></div>
|
|
172
174
|
${answering ? '' : result}
|
|
173
175
|
${open ? timelineHtml(ctx, run, all) : ''}</li>`;
|
|
174
176
|
}
|
|
175
177
|
|
|
176
178
|
/**
|
|
177
|
-
* The list:
|
|
179
|
+
* The list, in groups (spec 0010 D6): Needs you (oldest question first), In motion, Finished (each newest first), each starting with a heading that
|
|
180
|
+
* says how many; runs on their own and compares are the items. The headings are items of the one flat list, so a run's card is never moved into a section.
|
|
178
181
|
* @param {ViewContext} ctx
|
|
179
182
|
* @param {object[]} runs
|
|
180
183
|
*/
|
|
181
184
|
export function runsHtml(ctx, runs) {
|
|
182
|
-
return
|
|
185
|
+
return runGroups(runs).map((group) => runGroupHeadingHtml(group) + group.items.map((g) => {
|
|
183
186
|
if (g.kind === 'run') return runHtml(ctx, g.run, runs);
|
|
184
187
|
const id = `cmp-${g.runs[0].runId}`;
|
|
185
188
|
return `<li class="hx-run-group" data-key="${ctx.esc(id)}"><section class="hx-run-compare" aria-labelledby="${ctx.esc(id)}">
|
|
186
189
|
<h4 class="hx-run-compare-title" id="${ctx.esc(id)}">${ctx.esc(compareTitle(g.runs))}</h4>
|
|
187
190
|
<p class="hx-forge-meta hx-faint">The same request under each profile, side by side.</p>
|
|
188
191
|
<ul class="hx-run-columns" aria-label="${ctx.esc(g.runs.length)} profiles compared">${g.runs.map((r) => runHtml(ctx, r, runs)).join('')}</ul></section></li>`;
|
|
189
|
-
}).join('');
|
|
192
|
+
}).join('')).join('');
|
|
190
193
|
}
|
package/explorer/scenario-ui.js
CHANGED
|
@@ -225,16 +225,16 @@ function showBar(speed) {
|
|
|
225
225
|
bar.innerHTML = `
|
|
226
226
|
<div class="hx-player-head">
|
|
227
227
|
<span class="hx-player-title"></span>
|
|
228
|
-
<select class="hx-player-speed" data-action="scenario-speed" aria-label="Time for each step" title="Time for each step">${SPEED_CHOICES.map((c) => `<option value="${c.value}">${c.label}</option>`).join('')}</select>
|
|
228
|
+
<select data-corn="control" class="hx-player-speed" data-action="scenario-speed" aria-label="Time for each step" title="Time for each step">${SPEED_CHOICES.map((c) => `<option value="${c.value}">${c.label}</option>`).join('')}</select>
|
|
229
229
|
<button type="button" class="hx-close" data-action="scenario-close" aria-label="Close the scenario" data-corn-kind="icon">✕</button>
|
|
230
230
|
</div>
|
|
231
231
|
<p class="hx-player-text" aria-live="polite"><span class="hx-player-count" data-corn="count"></span> · <span class="hx-player-step"></span></p>
|
|
232
232
|
<div class="hx-player-controls">
|
|
233
|
-
<button type="button" class="hx-btn" data-action="scenario-prev" data-peek-ok>◀ Previous</button>
|
|
233
|
+
<button data-corn-kind="secondary" type="button" class="hx-btn" data-action="scenario-prev" data-peek-ok>◀ Previous</button>
|
|
234
234
|
<button type="button" class="hx-btn hx-btn--active" data-action="scenario-toggle" data-peek-ok data-corn-kind="primary"></button>
|
|
235
|
-
<button type="button" class="hx-btn" data-action="scenario-next" data-peek-ok>Next ▶</button>
|
|
235
|
+
<button data-corn-kind="secondary" type="button" class="hx-btn" data-action="scenario-next" data-peek-ok>Next ▶</button>
|
|
236
236
|
</div>
|
|
237
|
-
<div class="hx-player-track" aria-hidden="true"><span class="hx-player-fill"></span></div>`;
|
|
237
|
+
<div class="hx-player-track" data-corn="scenario-track" aria-hidden="true"><span class="hx-player-fill" data-corn="scenario-fill"></span></div>`;
|
|
238
238
|
bar.addEventListener('click', (e) => {
|
|
239
239
|
const button = e.target.closest('[data-action]');
|
|
240
240
|
if (button) act(button.dataset.action);
|
|
@@ -402,6 +402,7 @@ export function refreshList() {
|
|
|
402
402
|
list = document.createElement('div');
|
|
403
403
|
list.id = 'proposal-scenarios';
|
|
404
404
|
list.className = 'hx-scenarios glass';
|
|
405
|
+
list.dataset.corn = 'scenario-list';
|
|
405
406
|
list.dataset.key = key;
|
|
406
407
|
list.hidden = !!document.getElementById('proposal-play') && (!wasOpen || scenarios.length < 2); // behind Play when the toolbar has one
|
|
407
408
|
scenarios.forEach((s) => {
|
package/explorer/sheet-model.js
CHANGED
|
@@ -1,47 +1,95 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module explorer/sheet-model
|
|
3
3
|
*
|
|
4
|
-
* The state machine of the phone's bottom sheets (TOPO-18), with no DOM: which sheets exist,
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* The state machine of the phone's bottom sheets (TOPO-18, spec 0010 D7), with no DOM: which sheets exist, which are open, and which one is
|
|
5
|
+
* expanded. sheets.js puts this on the page.
|
|
6
|
+
*
|
|
7
|
+
* - Every sheet starts as a **peek** (a handle and a line or two). At most one is **expanded**; expanding one folds the sheets of the *other*
|
|
8
|
+
* group to a **stub** (one 44px row with a title and a badge). Tapping a stub expands it, and the one that was expanded becomes the stub.
|
|
9
|
+
* - **At most two sheets are open**: the *review* (the proposal bar, or the scenario player) and one *other* (Work, or the node panel).
|
|
10
|
+
* Opening Work displaces the node panel, and the reverse (`show` says which sheets it displaced); the node stays selected.
|
|
11
|
+
* - **The map keeps at least 35% of the screen** in every state (`sheetCap`): an expanded sheet's height is capped to leave it.
|
|
7
12
|
*/
|
|
8
13
|
|
|
14
|
+
/** The map keeps at least this share of the screen's height (spec 0010 D7) */
|
|
15
|
+
export const MAP_FLOOR = 0.35;
|
|
16
|
+
/** The height of a stub, in px: a row a thumb can hit */
|
|
17
|
+
export const STUB_PX = 44;
|
|
18
|
+
|
|
19
|
+
/** The groups: the sheets of the review, and the one other sheet (open one at a time) */
|
|
20
|
+
export const SHEET_GROUPS = Object.freeze({ proposal: 'review', player: 'review', forge: 'other', drawer: 'other' });
|
|
21
|
+
/** Groups that hold one open sheet at most: opening one displaces the other */
|
|
22
|
+
const EXCLUSIVE = new Set(['other']);
|
|
23
|
+
|
|
24
|
+
/** The tallest an expanded sheet may be, in px, for a screen `viewportPx` tall with `stubs` stubs under or over it: the rest is the map's 35% */
|
|
25
|
+
export const sheetCap = (viewportPx, stubs = 0) => Math.max(0, Math.floor(viewportPx - Math.ceil(viewportPx * MAP_FLOOR) - stubs * STUB_PX));
|
|
26
|
+
|
|
27
|
+
/** The map's smallest share of the screen, in px, for a screen `viewportPx` tall */
|
|
28
|
+
export const mapFloorPx = (viewportPx) => Math.ceil(viewportPx * MAP_FLOOR);
|
|
29
|
+
|
|
9
30
|
/**
|
|
31
|
+
* @param {Record<string, string>} [groups] the group of each sheet id (a sheet not named is its own group)
|
|
10
32
|
* @returns {{
|
|
11
33
|
* add(id: string): void, remove(id: string): void, has(id: string): boolean,
|
|
34
|
+
* show(id: string): string[], hide(id: string): void, isShown(id: string): boolean, shown(): string[],
|
|
12
35
|
* expand(id: string): boolean, collapse(id: string): boolean, collapseAll(): boolean, toggle(id: string): boolean,
|
|
13
|
-
* isExpanded(id: string): boolean, expanded(): string|null, ids(): string[],
|
|
14
|
-
* }} every change method answers whether anything changed
|
|
36
|
+
* isExpanded(id: string): boolean, expanded(): string|null, stateOf(id: string): 'expanded'|'peek'|'stub'|'hidden'|undefined, stubs(): number, ids(): string[],
|
|
37
|
+
* }} every change method answers whether anything changed (`show`: the ids it displaced)
|
|
15
38
|
*/
|
|
16
|
-
export function createSheetModel() {
|
|
39
|
+
export function createSheetModel(groups = SHEET_GROUPS) {
|
|
17
40
|
const known = new Set();
|
|
18
|
-
|
|
41
|
+
const open = new Set(); // the sheets that are open (a sheet is open from `add` until `hide`)
|
|
42
|
+
let expandedId = null;
|
|
43
|
+
const groupOf = (id) => groups[id] || id;
|
|
19
44
|
return {
|
|
20
|
-
add: (id) => { known.add(id); },
|
|
21
|
-
remove: (id) => { known.delete(id); if (
|
|
45
|
+
add: (id) => { known.add(id); open.add(id); },
|
|
46
|
+
remove: (id) => { known.delete(id); open.delete(id); if (expandedId === id) expandedId = null; },
|
|
22
47
|
has: (id) => known.has(id),
|
|
48
|
+
/** Opens a sheet. In an exclusive group the other open sheet is displaced (closed): its id is returned */
|
|
49
|
+
show(id) {
|
|
50
|
+
if (!known.has(id)) return [];
|
|
51
|
+
open.add(id);
|
|
52
|
+
if (!EXCLUSIVE.has(groupOf(id))) return [];
|
|
53
|
+
const gone = [...open].filter((o) => o !== id && groupOf(o) === groupOf(id));
|
|
54
|
+
for (const g of gone) { open.delete(g); if (expandedId === g) expandedId = null; }
|
|
55
|
+
return gone;
|
|
56
|
+
},
|
|
57
|
+
hide(id) { open.delete(id); if (expandedId === id) expandedId = null; },
|
|
58
|
+
isShown: (id) => open.has(id),
|
|
59
|
+
shown: () => [...open],
|
|
23
60
|
expand(id) {
|
|
24
|
-
if (!known.has(id) || open === id) return false;
|
|
25
|
-
|
|
61
|
+
if (!known.has(id) || !open.has(id) || expandedId === id) return false;
|
|
62
|
+
expandedId = id;
|
|
26
63
|
return true;
|
|
27
64
|
},
|
|
28
65
|
collapse(id) {
|
|
29
|
-
if (
|
|
30
|
-
|
|
66
|
+
if (expandedId !== id) return false;
|
|
67
|
+
expandedId = null;
|
|
31
68
|
return true;
|
|
32
69
|
},
|
|
33
70
|
collapseAll() {
|
|
34
|
-
if (
|
|
35
|
-
|
|
71
|
+
if (expandedId === null) return false;
|
|
72
|
+
expandedId = null;
|
|
36
73
|
return true;
|
|
37
74
|
},
|
|
38
75
|
toggle(id) {
|
|
39
|
-
if (!known.has(id)) return false;
|
|
40
|
-
|
|
76
|
+
if (!known.has(id) || !open.has(id)) return false;
|
|
77
|
+
expandedId = expandedId === id ? null : id;
|
|
41
78
|
return true;
|
|
42
79
|
},
|
|
43
|
-
isExpanded: (id) =>
|
|
44
|
-
expanded: () =>
|
|
80
|
+
isExpanded: (id) => expandedId === id,
|
|
81
|
+
expanded: () => expandedId,
|
|
82
|
+
/** `stub` for an open sheet of the other group while one is expanded; `peek` otherwise; undefined for a sheet that is not known */
|
|
83
|
+
stateOf(id) {
|
|
84
|
+
if (!known.has(id)) return undefined;
|
|
85
|
+
if (!open.has(id)) return 'hidden';
|
|
86
|
+
if (expandedId === id) return 'expanded';
|
|
87
|
+
return expandedId !== null && groupOf(expandedId) !== groupOf(id) ? 'stub' : 'peek';
|
|
88
|
+
},
|
|
89
|
+
/** How many stubs there are now */
|
|
90
|
+
stubs() {
|
|
91
|
+
return [...open].filter((id) => expandedId !== null && id !== expandedId && groupOf(id) !== groupOf(expandedId)).length;
|
|
92
|
+
},
|
|
45
93
|
ids: () => [...known],
|
|
46
94
|
};
|
|
47
95
|
}
|