@popcorn245/cornfield 0.55.0 → 0.56.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/contrast.js +12 -1
- package/core/schema.js +6 -0
- package/core/strings.js +0 -1
- package/explorer/css/page.css +0 -8
- package/explorer/css/work.css +3 -26
- package/explorer/deep-link.js +11 -24
- package/explorer/engine/map-style.js +4 -1
- package/explorer/forge-panel-model.js +2 -36
- package/explorer/forge-panel.js +3 -8
- package/explorer/index.html +1 -10
- package/explorer/instance-state.js +0 -6
- package/explorer/instance.js +9 -5
- package/explorer/page.js +5 -4
- package/explorer/pieces/node-panel.js +9 -5
- package/explorer/pieces/work-agent.js +3 -2
- package/explorer/pieces/work-common.js +14 -15
- package/explorer/pieces/work-confirm.js +11 -10
- package/explorer/pieces/work-data.js +24 -31
- package/explorer/pieces/work-deploys.js +42 -41
- package/explorer/pieces/work-issues.js +32 -29
- package/explorer/pieces/work-list.js +406 -0
- package/explorer/pieces/work-markup.js +9 -14
- package/explorer/pieces/work-notes.js +0 -1
- package/explorer/pieces/work-paint.js +57 -62
- package/explorer/pieces/work-prs.js +25 -66
- package/explorer/pieces/work-runs.js +47 -57
- package/explorer/pieces/work-specs.js +19 -2
- package/explorer/pieces/work-threads.js +28 -48
- package/explorer/pieces/work.js +28 -40
- package/explorer/proposal-model.js +5 -5
- package/explorer/runs-view.js +10 -18
- package/explorer/scene.js +1 -3
- package/explorer/tokens.css +4 -0
- package/explorer/waiting-view.js +3 -3
- package/explorer/work-model.js +79 -38
- package/explorer/work-view.css +3 -4
- package/explorer/work-view.js +77 -49
- package/package.json +1 -1
- package/explorer/pieces/work-events.js +0 -285
|
@@ -11,7 +11,7 @@ import { trapTab } from '../focusables.js';
|
|
|
11
11
|
import { escapeHtml as escHtml } from '../../core/text.js';
|
|
12
12
|
|
|
13
13
|
export function install(ctx) {
|
|
14
|
-
const { inst, ui, m, fn, $ } = ctx;
|
|
14
|
+
const { inst, ui, m, fn, root, $ } = ctx;
|
|
15
15
|
const { announce, t, trapFocus } = ctx.h;
|
|
16
16
|
|
|
17
17
|
const confirmEl = () => $('forge-confirm');
|
|
@@ -50,8 +50,8 @@ export function install(ctx) {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
/** What a pipeline step came to, on the panel (with a link to what it made) and through the live region */
|
|
53
|
-
function stepNote(text, ok, url = null) {
|
|
54
|
-
ui.actNote = { text, ok, url };
|
|
53
|
+
function stepNote(text, ok, url = null, ref = ui.ref) {
|
|
54
|
+
ui.actNote = { text, ok, url, ref }; // `ref`: the piece of work it is about, the only one whose node panel shows it
|
|
55
55
|
announce(text);
|
|
56
56
|
fn.paint();
|
|
57
57
|
}
|
|
@@ -67,6 +67,7 @@ export function install(ctx) {
|
|
|
67
67
|
*/
|
|
68
68
|
async function askPlan(action, n, slug, opener) {
|
|
69
69
|
if (ui.busy || ui.confirm || ui.agent || !confirmEl()) return;
|
|
70
|
+
const ref = ui.ref; // the node panel may show another piece of work by the time the plan is read
|
|
70
71
|
ui.busy = `plan:${action}`;
|
|
71
72
|
ui.actNote = null;
|
|
72
73
|
announce(action === 'spec' ? `Looking at what a spec for issue ${n} would make` : `Looking at the build issue for ${slug}`);
|
|
@@ -74,28 +75,28 @@ export function install(ctx) {
|
|
|
74
75
|
const res = await fn.request(planUrl(action, n, slug), true);
|
|
75
76
|
ui.busy = '';
|
|
76
77
|
// The button was off while it asked; it has the focus again whatever the answer is
|
|
77
|
-
const refocus = () => { const back =
|
|
78
|
+
const refocus = () => { const back = root.querySelector(opener); if (back && !back.disabled && !ui.confirm) back.focus(); };
|
|
78
79
|
if (!res.ok || !res.body || !res.body.plan) {
|
|
79
|
-
stepNote(actionWords(action, res.status, res.body, n), false);
|
|
80
|
+
stepNote(actionWords(action, res.status, res.body, n), false, null, ref);
|
|
80
81
|
refocus();
|
|
81
82
|
return;
|
|
82
83
|
}
|
|
83
84
|
const { plan } = res.body;
|
|
84
85
|
if (plan.existing) {
|
|
85
|
-
stepNote(existingWords(action, plan), true, plan.existing.url);
|
|
86
|
+
stepNote(existingWords(action, plan), true, plan.existing.url, ref);
|
|
86
87
|
refocus();
|
|
87
88
|
return;
|
|
88
89
|
}
|
|
89
90
|
fn.paint();
|
|
90
91
|
if (ui.agent) return; // Start an agent was opened while the plan was read: one dialog at a time, and that one has the focus
|
|
91
92
|
const what = action === 'spec' ? confirmSpec(plan, fn.forgeName()) : confirmBuild(plan, fn.forgeName());
|
|
92
|
-
showConfirm(what, what.go, { opener, kind: action, plan, n, slug });
|
|
93
|
+
showConfirm(what, what.go, { opener, kind: action, plan, n, slug, ref });
|
|
93
94
|
}
|
|
94
95
|
|
|
95
96
|
/** A pipeline step, second half: the plan that was shown is confirmed; the server plans again and must find the same */
|
|
96
97
|
async function confirmedStep() {
|
|
97
98
|
if (ui.busy || !ui.confirm || !ui.confirm.plan) return;
|
|
98
|
-
const { kind, plan, n } = ui.confirm;
|
|
99
|
+
const { kind, plan, n, ref } = ui.confirm;
|
|
99
100
|
ui.busy = kind;
|
|
100
101
|
ui.actNote = null;
|
|
101
102
|
const go = confirmEl().querySelector('[data-action="forge-confirm-go"]');
|
|
@@ -107,7 +108,7 @@ export function install(ctx) {
|
|
|
107
108
|
closeConfirm();
|
|
108
109
|
ui.busy = '';
|
|
109
110
|
const made = res.body && (kind === 'spec' ? res.body.pull : res.body.issue);
|
|
110
|
-
stepNote(actionWords(kind, res.status, res.body, n), res.ok, res.ok && made ? made.url : null);
|
|
111
|
+
stepNote(actionWords(kind, res.status, res.body, n), res.ok, res.ok && made ? made.url : null, ref);
|
|
111
112
|
// Whatever it came to, it is read again: a refusal says the issue or the pull request is not what was shown
|
|
112
113
|
if (res.status !== null) {
|
|
113
114
|
forgetOtherLists();
|
|
@@ -125,7 +126,7 @@ export function install(ctx) {
|
|
|
125
126
|
el.hidden = true;
|
|
126
127
|
if (m.confirmTrap) { m.confirmTrap(); m.confirmTrap = null; }
|
|
127
128
|
if (!restoreFocus) return;
|
|
128
|
-
const back =
|
|
129
|
+
const back = root.querySelector(opener) || $('forge-title');
|
|
129
130
|
if (back && !back.disabled) back.focus();
|
|
130
131
|
}
|
|
131
132
|
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module explorer/pieces/work-data
|
|
3
3
|
*
|
|
4
|
-
* The Work
|
|
4
|
+
* The Work list's asking: every request, the list a tab shows, what the piece of work in the node panel holds, the counts read quietly. Part of the Work piece (pieces/work.js): `install(ctx)` makes this part's functions for one mount, and hands the ones other parts call
|
|
5
5
|
* to `ctx.fn`; nothing is shared between two mounts.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { litOfRun } from '../runs-model.js';
|
|
9
8
|
import { listUrl, pullUrl, filterItems, litFor, errorWords, listKeyOf, litForDeploy, threadUrl, litForThread } from '../forge-panel-model.js';
|
|
10
9
|
import { plural, threadOf, FORGE_NAMES } from './work-common.js';
|
|
11
10
|
import { credentialed } from '../engine/connection.js';
|
|
12
11
|
|
|
13
12
|
export function install(ctx) {
|
|
14
13
|
const { inst, ui, m, fn, state, $ } = ctx;
|
|
15
|
-
const { announce,
|
|
14
|
+
const { announce, repaintThreads, isOffline } = ctx.h;
|
|
16
15
|
|
|
17
16
|
/** Every request carries the maintainer's session to the base's own origin only (engine/connection.js) */
|
|
18
17
|
const ask = credentialed(inst);
|
|
@@ -67,7 +66,7 @@ export function install(ctx) {
|
|
|
67
66
|
/** Loads the list the kind and state name (again, past the server's cache, on a refresh) */
|
|
68
67
|
async function loadList(refresh = false, quiet = false) {
|
|
69
68
|
const token = ++m.listToken;
|
|
70
|
-
if (ui.kind === 'work') return fn.loadWork(refresh, token);
|
|
69
|
+
if (ui.kind === 'work') return fn.loadWork(refresh, token, quiet);
|
|
71
70
|
if (ui.kind === 'specs') return fn.loadSpecs(token, quiet);
|
|
72
71
|
const key = listKey();
|
|
73
72
|
ui.loading = true;
|
|
@@ -83,7 +82,7 @@ export function install(ctx) {
|
|
|
83
82
|
// A thread's row names the state of the run that is about it (issue #104): the runs are read, once, when the tab is the first thing opened
|
|
84
83
|
if (!ui.runs) fn.loadRuns(false, { say: false }).then(() => { if (ui.open && ui.kind === 'threads') fn.paint(); }, () => {});
|
|
85
84
|
}
|
|
86
|
-
if (!quiet) announce(`${plural(filterItems(ui.lists[key].items, ui.kind, ui.filters).length, kindWords())} shown${ui.lists[key].stale ? '. This is an older answer' : ''}`);
|
|
85
|
+
if (!quiet && !(ui.actNote && !ui.actNote.ok)) announce(`${plural(filterItems(ui.lists[key].items, ui.kind, ui.filters).length, kindWords())} shown${ui.lists[key].stale ? '. This is an older answer' : ''}`); // a link that found nothing has said so: the count would cover it
|
|
87
86
|
} else {
|
|
88
87
|
ui.error = failWords(res, `the ${kindWords()}s`);
|
|
89
88
|
if (!quiet) announce(ui.error);
|
|
@@ -107,33 +106,26 @@ export function install(ctx) {
|
|
|
107
106
|
if (ui.kind !== 'specs') fn.readSpecsQuiet(); // the specs part of the number is read when Work opens (spec 0010 D2)
|
|
108
107
|
}
|
|
109
108
|
|
|
110
|
-
/**
|
|
111
|
-
function
|
|
109
|
+
/** The answer the Work list already read of a piece of work it is about to show (a pull request or a thread older than the graph's window is read to be made a node): used once, never kept */
|
|
110
|
+
function preloaded(kind, n) {
|
|
111
|
+
const got = m.preload && m.preload.kind === kind && m.preload.n === n ? m.preload.res : null;
|
|
112
|
+
m.preload = null;
|
|
113
|
+
return got;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** What the piece of work in the node panel holds, worked out again: for the nodes now on the map (its files, the nodes a thread or a deploy names) */
|
|
117
|
+
function figure() {
|
|
112
118
|
ui.nodesSeen = state.nodes;
|
|
113
|
-
if (ui.
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
ui.litThread = litForThread(ui.threadDetail.thread, state.nodes);
|
|
118
|
-
state.forgeLit = { changed: ui.litThread.changed, failing: ui.litThread.failing };
|
|
119
|
-
} else if (ui.deployItem) {
|
|
120
|
-
ui.litDeploy = litForDeploy(ui.deployItem, state.nodes);
|
|
121
|
-
state.forgeLit = { changed: ui.litDeploy.changed, failing: ui.litDeploy.failing };
|
|
122
|
-
} else if (ui.detail) {
|
|
123
|
-
ui.lit = litFor(ui.detail, state.nodes);
|
|
124
|
-
state.forgeLit = { changed: ui.lit.changed, failing: ui.lit.failing };
|
|
125
|
-
} else {
|
|
126
|
-
ui.lit = null;
|
|
127
|
-
state.forgeLit = null;
|
|
128
|
-
}
|
|
129
|
-
touchScene();
|
|
130
|
-
render();
|
|
119
|
+
if (ui.threadDetail && ui.threadDetail.thread) ui.litThread = litForThread(ui.threadDetail.thread, state.nodes);
|
|
120
|
+
else if (ui.deployItem) ui.litDeploy = litForDeploy(ui.deployItem, state.nodes);
|
|
121
|
+
else if (ui.detail) ui.lit = litFor(ui.detail, state.nodes);
|
|
122
|
+
else ui.lit = null;
|
|
131
123
|
fn.paint();
|
|
132
124
|
}
|
|
133
125
|
|
|
134
|
-
/** A proposal opening, or the live layer, changes the nodes: the
|
|
126
|
+
/** A proposal opening, or the live layer, changes the nodes: what the node panel holds follows them */
|
|
135
127
|
function onNodesChange() {
|
|
136
|
-
if ((ui.detail || ui.deployItem || ui.threadDetail) && state.nodes !== ui.nodesSeen)
|
|
128
|
+
if ((ui.detail || ui.deployItem || ui.threadDetail) && state.nodes !== ui.nodesSeen) figure();
|
|
137
129
|
repaintThreads();
|
|
138
130
|
}
|
|
139
131
|
|
|
@@ -143,10 +135,11 @@ export function install(ctx) {
|
|
|
143
135
|
if (ui.kind === 'notes') { await fn.loadNotes(true); return; }
|
|
144
136
|
const n = ui.selected;
|
|
145
137
|
await loadList(true, quiet);
|
|
138
|
+
if (ui.runShown) await fn.loadRuns(true, { say: false }); // the run in the node panel: as the runners now report it
|
|
146
139
|
if (ui.deployItem) {
|
|
147
140
|
// The list is read again: the deploy as the forge now has it (still running, now finished), else the last copy
|
|
148
141
|
const again = ui.lists.deploys && ui.lists.deploys.items.find((d) => d.id === ui.deploy);
|
|
149
|
-
if (again) { ui.deployItem = again;
|
|
142
|
+
if (again) { ui.deployItem = again; figure(); }
|
|
150
143
|
return;
|
|
151
144
|
}
|
|
152
145
|
if (ui.thread !== null) {
|
|
@@ -156,7 +149,7 @@ export function install(ctx) {
|
|
|
156
149
|
const thread = threadOf(res);
|
|
157
150
|
if (token !== m.threadToken || !thread) return;
|
|
158
151
|
ui.threadDetail = { thread, at: res.body.at, rate: res.body.rate || '', stale: res.body.stale || '' };
|
|
159
|
-
|
|
152
|
+
figure();
|
|
160
153
|
return;
|
|
161
154
|
}
|
|
162
155
|
if (n !== null && ui.selected === n) {
|
|
@@ -164,7 +157,7 @@ export function install(ctx) {
|
|
|
164
157
|
const res = await request(pullUrl(n), true);
|
|
165
158
|
if (token !== m.pullToken || !res.ok) return;
|
|
166
159
|
ui.detail = { pull: res.body.pull, files: res.body.files || [], checks: res.body.checks || [], specs: res.body.specs || [], at: res.body.at, rate: res.body.rate || '', stale: res.body.stale || '' };
|
|
167
|
-
|
|
160
|
+
figure();
|
|
168
161
|
await fn.loadLanding(n, token);
|
|
169
162
|
}
|
|
170
163
|
}
|
|
@@ -174,5 +167,5 @@ export function install(ctx) {
|
|
|
174
167
|
if (ui.open && (ui.error || (ui.runs && ui.runs.error) || ui.detailError || (ui.kind === 'notes' && ui.notes.error))) refreshForge({ quiet: true });
|
|
175
168
|
}
|
|
176
169
|
|
|
177
|
-
Object.assign(fn, { forgeName, listKey, current, kindWords, failWords, request, post, loadList, primeCounts,
|
|
170
|
+
Object.assign(fn, { preloaded, forgeName, listKey, current, kindWords, failWords, request, post, loadList, primeCounts, figure, onNodesChange, refreshForge, readOnline });
|
|
178
171
|
}
|
|
@@ -1,26 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module explorer/pieces/work-deploys
|
|
3
3
|
*
|
|
4
|
-
* The Deploys tab: the list and a deploy's detail,
|
|
4
|
+
* The Deploys tab: the list, and a deploy's detail in the node panel (what it restarted, its logs on the forge). Part of the Work piece (pieces/work.js): `install(ctx)` makes this part's functions for one mount, and hands the ones other parts call
|
|
5
5
|
* to `ctx.fn`; nothing is shared between two mounts.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { withParts } from '../engine/piece.js';
|
|
9
|
-
import {
|
|
10
|
-
import { cornStateAttr,
|
|
11
|
-
import { layerOn } from '../layer-model.js';
|
|
12
|
-
import { LAYER_DEFS } from '../engine/layers.js';
|
|
9
|
+
import { nodesForRestarts, deployWords, deployMeta, listUrl } from '../forge-panel-model.js';
|
|
10
|
+
import { cornStateAttr, stateIconHtml } from '../corn-state.js';
|
|
13
11
|
import { escapeHtml as escHtml } from '../../core/text.js';
|
|
14
|
-
import { plural, safeUrl
|
|
12
|
+
import { plural, safeUrl } from './work-common.js';
|
|
15
13
|
|
|
16
14
|
export function install(ctx) {
|
|
17
|
-
const { ui, m, fn, state
|
|
18
|
-
const { announce,
|
|
15
|
+
const { ui, m, fn, state } = ctx;
|
|
16
|
+
const { announce, isNodeVisible } = ctx.h;
|
|
19
17
|
|
|
20
|
-
/**
|
|
18
|
+
/** Shows a deploy in the node panel: nothing to ask once the list is read (it holds what the deploy restarted) */
|
|
21
19
|
function selectDeploy(id) {
|
|
22
20
|
const found = ui.lists.deploys && ui.lists.deploys.items.find((d) => d.id === id);
|
|
23
|
-
if (!found) return;
|
|
21
|
+
if (!found) return false;
|
|
24
22
|
m.pullToken++;
|
|
25
23
|
fn.dropThread();
|
|
26
24
|
ui.selected = null;
|
|
@@ -29,76 +27,79 @@ export function install(ctx) {
|
|
|
29
27
|
ui.lit = null;
|
|
30
28
|
ui.deploy = id;
|
|
31
29
|
ui.deployItem = found;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
fn.figure();
|
|
31
|
+
fn.sayDetail(deploySelectionWords());
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** The deploys list is read once for a deploy the node panel shows (the graph does not hold what a deploy restarted); a deploy older than the last hundred is said, never blank */
|
|
36
|
+
async function showDeploy(id) {
|
|
37
|
+
if (!ui.lists.deploys) {
|
|
38
|
+
const res = await fn.request(listUrl('deploys', 'all'), false);
|
|
39
|
+
if (res.ok) ui.lists.deploys = { items: res.body.items || [], at: res.body.at, rate: res.body.rate || '', stale: res.body.stale || '', problem: res.body.problem || '' };
|
|
40
|
+
}
|
|
41
|
+
if (ui.node === '') return; // the panel moved on while the list was read
|
|
42
|
+
if (!selectDeploy(id)) {
|
|
43
|
+
ui.deploy = null;
|
|
44
|
+
ui.deployItem = null;
|
|
45
|
+
ui.detailError = ui.lists.deploys ? 'This deploy is older than the last hundred the forge was asked for, so what it restarted is not known here.' : 'The deploys could not be read.';
|
|
46
|
+
fn.paint();
|
|
37
47
|
}
|
|
38
|
-
fn.relight();
|
|
39
|
-
$('forge-panel').querySelector('.hx-forge-body').scrollTop = 0; // the deploy's nodes are what was asked for, not the row that was tapped
|
|
40
|
-
announce(deploySelectionWords(turnedOn));
|
|
41
48
|
}
|
|
42
49
|
|
|
43
|
-
/** Lets go of the
|
|
50
|
+
/** Lets go of the deploy in the node panel */
|
|
44
51
|
function clearDeploy() {
|
|
45
|
-
const had = ui.deployItem;
|
|
46
52
|
ui.deploy = null;
|
|
47
53
|
ui.deployItem = null;
|
|
48
54
|
ui.litDeploy = null;
|
|
49
|
-
state.forgeLit = null;
|
|
50
|
-
touchScene();
|
|
51
|
-
render();
|
|
52
|
-
fn.paint();
|
|
53
|
-
if (had) announce(`Deploy ${had.name} cleared`);
|
|
54
55
|
}
|
|
55
56
|
|
|
56
|
-
/** What a deploy
|
|
57
|
-
function
|
|
57
|
+
/** What a deploy restarts, said short, for its row: how many nodes, or that it is not mapped */
|
|
58
|
+
function restartWords(deploy) {
|
|
58
59
|
if (!deploy.restarts.length) return 'Not mapped to a node';
|
|
59
60
|
const { nodes } = nodesForRestarts(deploy.restarts, state.nodes);
|
|
60
|
-
return nodes.length ? `
|
|
61
|
+
return nodes.length ? `Restarts ${plural(nodes.length, 'node')}` : 'Names nodes not on the map';
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
function deployHtml(d) {
|
|
64
65
|
const link = safeUrl(d.url);
|
|
65
66
|
const out = link ? `<a data-corn="out-link" class="hx-forge-out" href="${escHtml(link)}" target="_blank" rel="noreferrer" aria-label="Open deploy ${escHtml(d.name)} on ${escHtml(fn.forgeName())} (new tab)">↗</a>` : '';
|
|
66
|
-
return `<li class="hx-forge-item"><button type="button" class="hx-forge-row" data-
|
|
67
|
+
return `<li class="hx-forge-item"><button type="button" class="hx-forge-row" data-work-ref="deploy:${escHtml(d.id)}" aria-pressed="${fn.isShown(`deploy:${d.id}`)}" data-corn="row">
|
|
67
68
|
<span class="hx-forge-title">${escHtml(d.name)}${d.title && d.title !== d.name ? `<span class="hx-faint"> · ${escHtml(d.title)}</span>` : ''}</span>
|
|
68
69
|
<span class="hx-forge-meta"><span class="hx-forge-state hx-forge-state--${escHtml(d.state)}" data-corn="state-pill"${cornStateAttr(d.state)}>${stateIconHtml(d.state)}${escHtml(deployWords(d))}</span> ${escHtml(deployMeta(d, m.now()))}</span>
|
|
69
|
-
<span class="hx-forge-labels"><span class="hx-forge-label" data-corn="tag">${escHtml(
|
|
70
|
+
<span class="hx-forge-labels"><span class="hx-forge-label" data-corn="tag">${escHtml(restartWords(d))}</span></span></button>${out}</li>`;
|
|
70
71
|
}
|
|
71
72
|
|
|
72
|
-
/** The
|
|
73
|
+
/** 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) */
|
|
73
74
|
function deployDetailHtml() {
|
|
75
|
+
if (ui.detailError && !ui.deployItem) return `<p class="hx-forge-notice" data-corn="notice">${escHtml(ui.detailError)}</p>`;
|
|
74
76
|
const d = ui.deployItem;
|
|
77
|
+
if (!d) return '<p class="hx-faint">Loading what it restarted …</p>';
|
|
75
78
|
const lit = ui.litDeploy;
|
|
76
79
|
const url = safeUrl(d.url);
|
|
77
|
-
const head =
|
|
78
|
-
|
|
80
|
+
const head = `<p class="hx-forge-meta"><span class="hx-forge-state hx-forge-state--${escHtml(d.state)}" data-corn="state-pill"${cornStateAttr(d.state)}>${stateIconHtml(d.state)}${escHtml(deployWords(d))}</span> ${escHtml(deployMeta(d, m.now()))}</p>
|
|
81
|
+
${url ? `<div class="hx-forge-cta"><a data-corn="open-link" data-corn-kind="secondary" class="hx-btn hx-forge-open" href="${escHtml(url)}" target="_blank" rel="noreferrer">Open the logs on ${escHtml(fn.forgeName())} ↗</a></div>` : ''}`;
|
|
79
82
|
const stale = ui.lists.deploys && ui.lists.deploys.stale;
|
|
80
83
|
let body;
|
|
81
84
|
if (!d.restarts.length) {
|
|
82
|
-
body = '<p class="hx-forge-notice" data-corn="notice">No node is mapped to this deploy
|
|
85
|
+
body = '<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>';
|
|
83
86
|
} else {
|
|
84
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('');
|
|
85
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>` : '';
|
|
86
|
-
|
|
87
|
-
body = `<h4 class="hx-forge-sub">${escHtml(`Restarted: ${plural(lit.nodes.length, 'node')} on the map`)}</h4>${key}${rows ? `<ul class="hx-forge-files">${rows}</ul>` : ''}${missing}`;
|
|
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}`;
|
|
88
90
|
}
|
|
89
91
|
return `${head}${stale ? `<p class="hx-forge-notice" data-corn="notice">${escHtml(`This is an older answer. ${stale}`)}</p>` : ''}${body}`;
|
|
90
92
|
}
|
|
91
93
|
|
|
92
94
|
/** What a screen reader hears when a deploy is selected */
|
|
93
|
-
function deploySelectionWords(
|
|
95
|
+
function deploySelectionWords() {
|
|
94
96
|
const { name, branch } = ui.deployItem;
|
|
95
97
|
const lit = ui.litDeploy;
|
|
96
98
|
const head = `Deploy ${name}${branch ? ` of ${branch}` : ''}, ${deployWords(ui.deployItem).toLowerCase()}`;
|
|
97
|
-
if (!ui.deployItem.restarts.length) return `${head}. No node is mapped to it
|
|
98
|
-
|
|
99
|
-
return `${head}: ${plural(lit.nodes.length, 'node')} restarted and lit${lit.missing.length ? `, ${lit.missing.length} named that ${lit.missing.length === 1 ? 'is' : 'are'} not on the map` : ''}.${layers}`;
|
|
99
|
+
if (!ui.deployItem.restarts.length) return `${head}. No node is mapped to it.`;
|
|
100
|
+
return `${head}: ${plural(lit.nodes.length, 'node')} restarted on the map${lit.missing.length ? `, ${lit.missing.length} named that ${lit.missing.length === 1 ? 'is' : 'are'} not on the map` : ''}.`;
|
|
100
101
|
}
|
|
101
102
|
|
|
102
103
|
// what other parts put in the panel gets its parts (a hook is a part of the same name)
|
|
103
|
-
Object.assign(fn, { selectDeploy, clearDeploy,
|
|
104
|
+
Object.assign(fn, { selectDeploy, showDeploy, clearDeploy, restartWords, deployHtml: (...a) => withParts(deployHtml(...a)), deployDetailHtml: (...a) => withParts(deployDetailHtml(...a)), deploySelectionWords });
|
|
104
105
|
}
|
|
@@ -1,43 +1,46 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module explorer/pieces/work-issues
|
|
3
3
|
*
|
|
4
|
-
* The Issues tab
|
|
4
|
+
* The Issues tab (its rows are drawn with the PRs' in work-prs.js), an issue's actions in the node panel, and an issue older than the Work view's 14 days.
|
|
5
|
+
* Part of the Work piece (pieces/work.js): `install(ctx)` makes this part's functions for one mount, and hands the ones other parts call
|
|
5
6
|
* to `ctx.fn`; nothing is shared between two mounts.
|
|
6
7
|
*/
|
|
7
8
|
|
|
8
|
-
import {
|
|
9
|
+
import { escapeHtml as escHtml } from '../../core/text.js';
|
|
10
|
+
import { issueUrl, listUrl, listKeyOf, specBlock } from '../forge-panel-model.js';
|
|
9
11
|
|
|
10
12
|
export function install(ctx) {
|
|
11
|
-
const { ui, fn
|
|
12
|
-
const {
|
|
13
|
+
const { ui, fn } = ctx;
|
|
14
|
+
const { t } = ctx.h;
|
|
13
15
|
|
|
14
|
-
/** An issue the
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
if (
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
return fn.linkMissing(res.status === 404 ? `There is no issue ${n}.` : fn.failWords(res, `issue ${n}`));
|
|
16
|
+
/** An issue's actions in the node panel: Start a spec (step 1 of the pipeline) and Start an agent, each opening its confirm step; a closed issue has none */
|
|
17
|
+
function issueActionsHtml(item) {
|
|
18
|
+
const n = item.number;
|
|
19
|
+
if (!item.open) return `<p class="hx-faint">${escHtml(specBlock({ state: 'closed' }))}</p>`;
|
|
20
|
+
const spec = specBlock({ state: 'open' }) === null
|
|
21
|
+
? `<button data-corn-kind="secondary" type="button" class="hx-btn hx-forge-act hx-forge-startspec" data-forge-spec="${n}" aria-label="Start a spec for issue ${n}"${ui.busy ? ' disabled' : ''}>Start a spec …</button>`
|
|
22
|
+
: '';
|
|
23
|
+
const agent = `<button data-corn-kind="secondary" type="button" class="hx-btn hx-forge-act hx-forge-startspec" data-forge-agent="issue:${n}" aria-label="${escHtml(t('startAgent'))} on issue ${n}">${escHtml(t('startAgent'))} …</button>`;
|
|
24
|
+
return `<div class="hx-forge-cta">${agent}${spec}</div>`;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
/**
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
27
|
+
/**
|
|
28
|
+
* The issue the Work list names that the graph does not draw: a list already read holds it (the open one is read for this), else the issue's own route does (a closed one, or one past the end of the list).
|
|
29
|
+
* `null` says why in the list and through the live region when there is none.
|
|
30
|
+
*/
|
|
31
|
+
async function oldIssue(n) {
|
|
32
|
+
const key = listKeyOf('issues', 'open');
|
|
33
|
+
if (!ui.lists[key]) {
|
|
34
|
+
const res = await fn.request(listUrl('issues', 'open'), false);
|
|
35
|
+
if (res.ok && !ui.lists[key]) ui.lists[key] = { items: res.body.items || [], at: res.body.at, rate: res.body.rate || '', stale: res.body.stale || '', problem: res.body.problem || '' };
|
|
36
|
+
}
|
|
37
|
+
const hit = Object.entries(ui.lists).filter(([k]) => k.startsWith('issues|')).flatMap(([, list]) => list.items).find((i) => i.number === n); // any list read, whatever its state filter
|
|
38
|
+
if (hit) return hit;
|
|
39
|
+
const res = await fn.request(issueUrl(n));
|
|
40
|
+
if (res.ok && res.body.issue) return res.body.issue;
|
|
41
|
+
fn.linkMissing(res.status === 404 ? `There is no issue ${n}.` : fn.failWords(res, `issue ${n}`));
|
|
42
|
+
return null;
|
|
40
43
|
}
|
|
41
44
|
|
|
42
|
-
Object.assign(fn, {
|
|
45
|
+
Object.assign(fn, { issueActionsHtml, oldIssue });
|
|
43
46
|
}
|