@intentius/behold 0.29.40 → 0.29.41
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/AGENTS.md +148 -10
- package/README.md +6 -2
- package/dist/cli.js +15965 -13076
- package/example-writes/README.md +1 -1
- package/example-writes/chant.config.ts +0 -6
- package/package.json +5 -2
- package/web/app.js +327 -21
- package/web/carve-export.js +142 -0
- package/web/carve-narration.js +268 -0
- package/web/carve-narration.test.js +18 -0
- package/web/change-set-overlay.js +147 -0
- package/web/change-set-overlay.test.js +83 -0
- package/web/dots-border.js +66 -0
- package/web/dots-border.test.js +27 -0
- package/web/dots-kiosk.js +279 -0
- package/web/dots-kiosk.test.js +60 -0
- package/web/dots-layout.d.ts +10 -0
- package/web/dots-layout.js +201 -0
- package/web/dots-live.js +316 -0
- package/web/dots-live.test.js +220 -0
- package/web/dots-lod.js +122 -0
- package/web/dots-lod.test.js +78 -0
- package/web/dots-recording.d.ts +7 -0
- package/web/dots-recording.js +247 -0
- package/web/dots-recording.test.js +71 -0
- package/web/dots-scene.js +294 -0
- package/web/dots-scene.test.js +118 -0
- package/web/dots-timeline.js +128 -0
- package/web/dots-timeline.test.js +83 -0
- package/web/dots-tour.js +153 -0
- package/web/dots.js +2124 -0
- package/web/dots.test.js +15 -0
- package/web/index.html +29 -0
- package/web/kiosk-carve.js +219 -0
- package/web/kiosk-carve.test.js +26 -0
- package/web/kiosk-event-help-ui.js +6 -0
- package/web/kiosk.js +21 -6
- package/web/operator.js +1 -1
- package/web/run-playhead.js +102 -19
- package/web/run-playhead.test.js +81 -11
- package/web/tour-player.js +204 -0
- package/web/tour-player.test.js +115 -0
- package/web/tours/behold.tour.v1.schema.json +182 -0
- package/web/tours/terralith.json +330 -0
- package/web/trunk-lane.js +254 -0
- package/web/trunk-lane.test.js +117 -0
- package/web/workspace-gates.js +29 -4
- package/web/workspace-gates.test.js +23 -2
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schema": "behold.tour/v1",
|
|
3
|
+
"name": "terralith",
|
|
4
|
+
"title": "The terralith's story",
|
|
5
|
+
"match": {
|
|
6
|
+
"tool": "terralith"
|
|
7
|
+
},
|
|
8
|
+
"home": "demo-terralith",
|
|
9
|
+
"steps": [
|
|
10
|
+
"pull-request",
|
|
11
|
+
"planned",
|
|
12
|
+
"merged",
|
|
13
|
+
"applying",
|
|
14
|
+
"waiting",
|
|
15
|
+
"approved",
|
|
16
|
+
"resumed",
|
|
17
|
+
"applied"
|
|
18
|
+
],
|
|
19
|
+
"runs": {
|
|
20
|
+
"stock": {
|
|
21
|
+
"repo": "{repo}",
|
|
22
|
+
"stage": "tf-apply",
|
|
23
|
+
"pull": null,
|
|
24
|
+
"pick": "first"
|
|
25
|
+
},
|
|
26
|
+
"adopt": {
|
|
27
|
+
"migration": "adopt"
|
|
28
|
+
},
|
|
29
|
+
"split": {
|
|
30
|
+
"migration": "split"
|
|
31
|
+
},
|
|
32
|
+
"team": {
|
|
33
|
+
"repo": "{repo}-team-b",
|
|
34
|
+
"stage": "tf-plan",
|
|
35
|
+
"pick": "first"
|
|
36
|
+
},
|
|
37
|
+
"teamApply": {
|
|
38
|
+
"repo": "{repo}-team-b",
|
|
39
|
+
"stage": "tf-apply",
|
|
40
|
+
"pick": "first"
|
|
41
|
+
},
|
|
42
|
+
"crossPlan": {
|
|
43
|
+
"repo": "{repo}",
|
|
44
|
+
"stage": "tf-plan",
|
|
45
|
+
"after": "teamApply",
|
|
46
|
+
"pick": "last"
|
|
47
|
+
},
|
|
48
|
+
"cross1": {
|
|
49
|
+
"repo": "{repo}",
|
|
50
|
+
"stage": "tf-apply",
|
|
51
|
+
"wave": 1,
|
|
52
|
+
"after": "crossPlan",
|
|
53
|
+
"pick": "last"
|
|
54
|
+
},
|
|
55
|
+
"cross2": {
|
|
56
|
+
"repo": "{repo}",
|
|
57
|
+
"stage": "tf-apply",
|
|
58
|
+
"wave": 2,
|
|
59
|
+
"after": "crossPlan",
|
|
60
|
+
"pick": "last"
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"facts": {
|
|
64
|
+
"planned": {
|
|
65
|
+
"run": "stock",
|
|
66
|
+
"value": "planned"
|
|
67
|
+
},
|
|
68
|
+
"of": {
|
|
69
|
+
"run": "stock",
|
|
70
|
+
"value": "planned"
|
|
71
|
+
},
|
|
72
|
+
"stamped": {
|
|
73
|
+
"migration": "adopt",
|
|
74
|
+
"value": "stamped_resources"
|
|
75
|
+
},
|
|
76
|
+
"moved": {
|
|
77
|
+
"migration": "split",
|
|
78
|
+
"value": "moved_resources"
|
|
79
|
+
},
|
|
80
|
+
"refused": {
|
|
81
|
+
"migration": "split",
|
|
82
|
+
"value": "refused_resources"
|
|
83
|
+
},
|
|
84
|
+
"teamPlanned": {
|
|
85
|
+
"run": "team",
|
|
86
|
+
"value": "planned"
|
|
87
|
+
},
|
|
88
|
+
"teamChanged": {
|
|
89
|
+
"run": "team",
|
|
90
|
+
"value": "changed"
|
|
91
|
+
},
|
|
92
|
+
"value": {
|
|
93
|
+
"run": "crossPlan",
|
|
94
|
+
"value": "output",
|
|
95
|
+
"output": "log_retention_days"
|
|
96
|
+
},
|
|
97
|
+
"adoptRecreated": {
|
|
98
|
+
"run": "adopt",
|
|
99
|
+
"value": "recreated"
|
|
100
|
+
},
|
|
101
|
+
"splitRecreated": {
|
|
102
|
+
"run": "split",
|
|
103
|
+
"value": "recreated"
|
|
104
|
+
},
|
|
105
|
+
"recreated": {
|
|
106
|
+
"sum": [
|
|
107
|
+
"adoptRecreated",
|
|
108
|
+
"splitRecreated"
|
|
109
|
+
]
|
|
110
|
+
},
|
|
111
|
+
"approvals": {
|
|
112
|
+
"approvals": true
|
|
113
|
+
},
|
|
114
|
+
"cycleTime": {
|
|
115
|
+
"duration": {
|
|
116
|
+
"from": "started_at",
|
|
117
|
+
"to": "cross2"
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
"tagged": {
|
|
121
|
+
"tagged": [
|
|
122
|
+
"adopt",
|
|
123
|
+
"split"
|
|
124
|
+
]
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
"chapters": [
|
|
128
|
+
{
|
|
129
|
+
"id": "stock",
|
|
130
|
+
"trigger": {
|
|
131
|
+
"beat": "stock"
|
|
132
|
+
},
|
|
133
|
+
"title": "One state for everything",
|
|
134
|
+
"text": [
|
|
135
|
+
"Every resource lives in one state file.",
|
|
136
|
+
"Any change plans {planned} of {of} and waits on one lock."
|
|
137
|
+
],
|
|
138
|
+
"focus": {
|
|
139
|
+
"boxes": "source"
|
|
140
|
+
},
|
|
141
|
+
"show": [
|
|
142
|
+
{
|
|
143
|
+
"light": [
|
|
144
|
+
"stock"
|
|
145
|
+
]
|
|
146
|
+
}
|
|
147
|
+
]
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"id": "adopt",
|
|
151
|
+
"trigger": {
|
|
152
|
+
"beat": "adopt"
|
|
153
|
+
},
|
|
154
|
+
"title": "Adopt: claim every resource without touching it",
|
|
155
|
+
"text": [
|
|
156
|
+
"Each resource gets its owner's tags. Nothing is rebuilt.",
|
|
157
|
+
"{stamped} resources tagged, and the state file stays as it was."
|
|
158
|
+
],
|
|
159
|
+
"focus": {
|
|
160
|
+
"boxes": "source"
|
|
161
|
+
},
|
|
162
|
+
"show": [
|
|
163
|
+
{
|
|
164
|
+
"state": "adopt"
|
|
165
|
+
}
|
|
166
|
+
]
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
"id": "split",
|
|
170
|
+
"trigger": {
|
|
171
|
+
"beat": "split"
|
|
172
|
+
},
|
|
173
|
+
"title": "Split: move ownership, not resources",
|
|
174
|
+
"text": [
|
|
175
|
+
"Each team's resources move to its own estate by a tag write.",
|
|
176
|
+
"{moved} resources moved, {refused} refused."
|
|
177
|
+
],
|
|
178
|
+
"focus": {
|
|
179
|
+
"boxes": "all"
|
|
180
|
+
},
|
|
181
|
+
"show": [
|
|
182
|
+
{
|
|
183
|
+
"counts": "estates"
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
"checks": "split",
|
|
187
|
+
"when": {
|
|
188
|
+
"migration": "split",
|
|
189
|
+
"line": "last"
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
]
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
"id": "team",
|
|
196
|
+
"trigger": {
|
|
197
|
+
"beat": "team"
|
|
198
|
+
},
|
|
199
|
+
"title": "A small change stays small",
|
|
200
|
+
"text": [
|
|
201
|
+
"Team B changes one policy, and only team B is planned.",
|
|
202
|
+
"Planned {teamPlanned} of {of} · chapter 1: {planned} of {of}"
|
|
203
|
+
],
|
|
204
|
+
"focus": {
|
|
205
|
+
"boxes": "lit"
|
|
206
|
+
},
|
|
207
|
+
"show": [
|
|
208
|
+
{
|
|
209
|
+
"light": [
|
|
210
|
+
"team"
|
|
211
|
+
]
|
|
212
|
+
}
|
|
213
|
+
]
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
"id": "cross",
|
|
217
|
+
"trigger": {
|
|
218
|
+
"beat": "cross"
|
|
219
|
+
},
|
|
220
|
+
"title": "A change across estates",
|
|
221
|
+
"text": [
|
|
222
|
+
"The terralith publishes a value, and each team reads it.",
|
|
223
|
+
"Wave 1 plans the terralith; wave 2 plans the teams on {value}."
|
|
224
|
+
],
|
|
225
|
+
"focus": {
|
|
226
|
+
"boxes": "all"
|
|
227
|
+
},
|
|
228
|
+
"show": [
|
|
229
|
+
{
|
|
230
|
+
"pulse": "crossPlan",
|
|
231
|
+
"wave": 1,
|
|
232
|
+
"when": {
|
|
233
|
+
"wave": 1,
|
|
234
|
+
"edge": "start",
|
|
235
|
+
"after": "crossPlan"
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
"travel": "crossPlan",
|
|
240
|
+
"output": "log_retention_days",
|
|
241
|
+
"when": {
|
|
242
|
+
"wave": 1,
|
|
243
|
+
"edge": "end",
|
|
244
|
+
"after": "crossPlan"
|
|
245
|
+
}
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
"light": [
|
|
249
|
+
"cross2",
|
|
250
|
+
"crossPlan"
|
|
251
|
+
],
|
|
252
|
+
"wave": 2,
|
|
253
|
+
"when": {
|
|
254
|
+
"wave": 2,
|
|
255
|
+
"edge": "start",
|
|
256
|
+
"after": "crossPlan"
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
]
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
"id": "epilogue",
|
|
263
|
+
"trigger": {
|
|
264
|
+
"any": [
|
|
265
|
+
{
|
|
266
|
+
"beat": "cross",
|
|
267
|
+
"step": "applied"
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
"step": "reset"
|
|
271
|
+
}
|
|
272
|
+
]
|
|
273
|
+
},
|
|
274
|
+
"title": "This cycle, in numbers",
|
|
275
|
+
"text": [
|
|
276
|
+
"Then the reset: the next cycle starts from a new terralith."
|
|
277
|
+
],
|
|
278
|
+
"focus": {
|
|
279
|
+
"boxes": "all"
|
|
280
|
+
},
|
|
281
|
+
"show": [
|
|
282
|
+
{
|
|
283
|
+
"travel": "crossPlan",
|
|
284
|
+
"output": "log_retention_days",
|
|
285
|
+
"when": {
|
|
286
|
+
"wave": 1,
|
|
287
|
+
"edge": "end",
|
|
288
|
+
"after": "crossPlan"
|
|
289
|
+
}
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
"light": [
|
|
293
|
+
"cross2",
|
|
294
|
+
"crossPlan"
|
|
295
|
+
],
|
|
296
|
+
"wave": 2,
|
|
297
|
+
"when": {
|
|
298
|
+
"wave": 2,
|
|
299
|
+
"edge": "start",
|
|
300
|
+
"after": "crossPlan"
|
|
301
|
+
}
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
"card": [
|
|
305
|
+
{
|
|
306
|
+
"label": "cycle time",
|
|
307
|
+
"text": "{cycleTime}"
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
"label": "resources tagged",
|
|
311
|
+
"text": "{tagged}"
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
"label": "resources recreated",
|
|
315
|
+
"text": "{recreated}"
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
"label": "approvals",
|
|
319
|
+
"text": "{approvals}"
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
"label": "planned per change",
|
|
323
|
+
"text": "{planned} before, {teamPlanned} after"
|
|
324
|
+
}
|
|
325
|
+
]
|
|
326
|
+
}
|
|
327
|
+
]
|
|
328
|
+
}
|
|
329
|
+
]
|
|
330
|
+
}
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
// #680: the trunk lane. Pure words from /api/workspace/lane, and one render.
|
|
2
|
+
// First the trunk's recent commits, each green, revoked or undecided, with its
|
|
3
|
+
// work items and runs and where it is now. Then one lane per environment in
|
|
4
|
+
// the promotion order chant declares: what the environment runs, and the
|
|
5
|
+
// gates waiting there, each with the approve button the gate strip uses
|
|
6
|
+
// (approveAffordance, #690), and the change set it binds as the link that
|
|
7
|
+
// draws it on the graph (#681). Nothing here is behold's own state.
|
|
8
|
+
|
|
9
|
+
import { ago, clock } from "./terragucci.js";
|
|
10
|
+
import { approveAffordance, HOST_APPROVES, overrideCard } from "./workspace-gates.js";
|
|
11
|
+
|
|
12
|
+
const short = (s) => (s ? String(s).replace(/^(jcs1-)?sha256:/, "").slice(0, 12) : "");
|
|
13
|
+
const sha7 = (s) => (s ? String(s).slice(0, 7) : "");
|
|
14
|
+
const plural = (n, one, many = `${one}s`) => `${n} ${n === 1 ? one : many}`;
|
|
15
|
+
|
|
16
|
+
/** The note under the legend: chant ci list reads local tags only. */
|
|
17
|
+
export const UNDECIDED_NOTE = "undecided: no ci tag yet. chant ci list reads local tags, so a commit that failed without ever going green also reads undecided.";
|
|
18
|
+
|
|
19
|
+
/** The lane's first line: what was read, or why it wasn't. */
|
|
20
|
+
export function laneLegend(a, now = new Date()) {
|
|
21
|
+
if (!a || a.error) return { text: `lane not read${a && a.error ? `: ${a.error}` : ""}`, title: "", tone: "refusal" };
|
|
22
|
+
if (a.refusal) return { text: `lane not read: ${a.refusal.error}`, title: a.refusal.remedy || "", tone: "refusal" };
|
|
23
|
+
const when = a.read ? ` · read ${ago(a.read.at, now)}` : "";
|
|
24
|
+
if (!a.trunk) return { text: `trunk not read: ${a.trunkRefusal ? a.trunkRefusal.error : "chant ci list gave no answer"}${when}`, title: (a.trunkRefusal && a.trunkRefusal.remedy) || "", tone: "refusal" };
|
|
25
|
+
const span = a.trunk.since ? `after ${sha7(a.trunk.since)}` : `within ${a.trunk.window}`;
|
|
26
|
+
return { text: `trunk ${a.trunk.branch} · ${plural(a.commits.length, "commit")} ${span}${when}`, title: UNDECIDED_NOTE, tone: "quiet" };
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** A commit's work items in words, as chant#4029 links them; null when chant said nothing. */
|
|
30
|
+
export function workWords(work) {
|
|
31
|
+
if (!work) return null;
|
|
32
|
+
if (work.state === "linked") return { text: `work ${work.ids.join(", ")}`, title: "" };
|
|
33
|
+
if (work.state === "unlinked") return { text: "no work item", title: "No Chant-Record or Chant-Lease trailer names one." };
|
|
34
|
+
if (work.state === "wrong") return { text: "names a work item that does not exist", title: work.problems.map((p) => `${p.trailer}: ${p.message}`).join("\n") };
|
|
35
|
+
if (work.state === "merge") return { text: "merge commit", title: "Its work is the commits it brings." };
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Where a commit is, in words: "runs in staging, waits in prod". */
|
|
40
|
+
export function whereWords(where) {
|
|
41
|
+
return (where || []).map((w) => (w.what === "runs" ? `runs in ${w.env}` : `waits in ${w.env}`)).join(", ");
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** The runs behind a commit's state, each a link: every phase's runs, and the run a revoked tag names. */
|
|
45
|
+
export function commitRuns(c) {
|
|
46
|
+
const out = [];
|
|
47
|
+
const seen = new Set();
|
|
48
|
+
const add = (r) => {
|
|
49
|
+
if (!r || !r.url || seen.has(r.url)) return;
|
|
50
|
+
seen.add(r.url);
|
|
51
|
+
out.push({ text: r.name, href: r.url, title: r.conclusion ? `${r.name}: ${r.conclusion}` : r.name });
|
|
52
|
+
};
|
|
53
|
+
for (const p of c.phases || []) for (const r of p.runs) add(r);
|
|
54
|
+
if (c.revoked) add(c.revoked.run);
|
|
55
|
+
return out;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** One trunk commit's row. */
|
|
59
|
+
export function commitRow(c, now = new Date()) {
|
|
60
|
+
const facts = [];
|
|
61
|
+
const work = workWords(c.work);
|
|
62
|
+
if (c.revoked) facts.push({ text: `revoked: ${c.revoked.phase || "a phase"} failed`, title: "" });
|
|
63
|
+
if (work) facts.push(work);
|
|
64
|
+
if (c.ignored && c.ignored.length) facts.push({ text: `${plural(c.ignored.length, "ci tag")} not counted`, title: c.ignored.map((t) => `${t.tag} (${t.status}): ${t.reason}`).join("\n") });
|
|
65
|
+
return {
|
|
66
|
+
sha: c.sha,
|
|
67
|
+
head: `${sha7(c.sha)} ${c.state}`,
|
|
68
|
+
state: c.state,
|
|
69
|
+
when: ago(c.committed, now),
|
|
70
|
+
title: `${c.sha}\ncommitted ${clock(c.committed, now)}${c.state === "undecided" ? `\n${UNDECIDED_NOTE}` : ""}`,
|
|
71
|
+
where: whereWords(c.where),
|
|
72
|
+
facts,
|
|
73
|
+
runs: commitRuns(c),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** What one environment runs, line by line; `no deploy record` when chant has none. */
|
|
78
|
+
export function runsLines(e, now = new Date()) {
|
|
79
|
+
const lines = [];
|
|
80
|
+
for (const r of e.releases || []) {
|
|
81
|
+
lines.push({
|
|
82
|
+
text: `runs ${r.label || short(r.releaseDigest)}, cut from ${sha7(r.commit)}${r.listed ? "" : " (older than the trunk list)"} · ${r.components.join(", ")}`,
|
|
83
|
+
title: [`release ${r.releaseDigest} of ${r.member}`, r.cutBy ? `cut by ${r.cutBy}${r.cutAt ? ` ${clock(r.cutAt, now)}` : ""}` : "", r.approver ? `deploy approved by ${r.approver}` : ""].filter(Boolean).join("\n"),
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
for (const d of e.deploys || []) {
|
|
87
|
+
lines.push({
|
|
88
|
+
text: `runs ${d.component} ${short(d.digest)} from ${sha7(d.gitSha)}${d.listed ? "" : " (older than the trunk list)"}`,
|
|
89
|
+
title: `deploy record of ${d.member}, run ${d.runId}, by ${d.actor} ${ago(d.timestamp, now)}${d.approver ? `, approved by ${d.approver}` : ""}`,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
if (!lines.length) lines.push({ text: "no deploy record", title: "chant has no deploy record for this environment, so behold does not say what runs here." });
|
|
93
|
+
return lines;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** One waiting gate as a card, with the gate strip's approve button (or the note in its place). */
|
|
97
|
+
export function laneGateCard(g, answer, { embed = false } = {}) {
|
|
98
|
+
if (g.override) {
|
|
99
|
+
const o = overrideCard(g);
|
|
100
|
+
return { key: g.key, title: o.title, facts: o.facts, note: o.note, command: o.command };
|
|
101
|
+
}
|
|
102
|
+
const facts = [];
|
|
103
|
+
facts.push(g.gitSha ? `for ${sha7(g.gitSha)}${g.commitState ? ` (${g.commitState})` : ""}` : "commit unknown");
|
|
104
|
+
facts.push(`${g.approvals.length} of ${plural(g.needed, "approval")}`);
|
|
105
|
+
if (g.runId) facts.push(`run ${g.runId}`);
|
|
106
|
+
if (g.releaseDigest) facts.push(`release ${short(g.releaseDigest)}`);
|
|
107
|
+
if (g.approvals.length) facts.push(`approved by ${g.approvals.map((a) => a.principal).join(", ")}`);
|
|
108
|
+
const show = g.changeSet ? `chant change-set show ${g.changeSet} --member ${g.member}` : null;
|
|
109
|
+
const card = {
|
|
110
|
+
key: g.key,
|
|
111
|
+
title: `${g.member}: ${g.op} waits at gate ${g.gate}`,
|
|
112
|
+
facts: facts.join(" · "),
|
|
113
|
+
command: show ? `${g.approve}\n${show}` : g.approve,
|
|
114
|
+
};
|
|
115
|
+
// #681: the change set is a link that draws it on the graph.
|
|
116
|
+
if (g.changeSet) card.changeSet = { text: `change set ${short(g.changeSet)}`, title: `Draw this change set on the graph, as a preview.\n${show}` };
|
|
117
|
+
if (embed) card.note = HOST_APPROVES;
|
|
118
|
+
else Object.assign(card, approveAffordance(g, answer));
|
|
119
|
+
return card;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** The whole lane as words: the legend, the commits, and a lane per environment. Pure. */
|
|
123
|
+
export function laneView(a, now = new Date(), opts = {}) {
|
|
124
|
+
const legend = laneLegend(a, now);
|
|
125
|
+
if (!a || a.error || a.refusal) return { legend, notes: [], commits: [], environments: [] };
|
|
126
|
+
const notes = [];
|
|
127
|
+
if (a.order === "env" && a.environments.length) notes.push(`no member declares a promotion order, so this is ${a.environments[0].env} alone`);
|
|
128
|
+
for (const r of a.releaseRefusals || []) notes.push(`releases of ${r.member} not read: ${r.refusal.error}`);
|
|
129
|
+
return {
|
|
130
|
+
legend,
|
|
131
|
+
notes,
|
|
132
|
+
commits: (a.commits || []).map((c) => commitRow(c, now)),
|
|
133
|
+
empty: a.trunk && !(a.commits || []).length ? `no commits ${a.trunk.since ? `after ${sha7(a.trunk.since)}` : `within ${a.trunk.window}`}` : null,
|
|
134
|
+
environments: (a.environments || []).map((e) => ({
|
|
135
|
+
env: e.env,
|
|
136
|
+
heading: e.canary ? `${e.env} (canary)` : e.env,
|
|
137
|
+
refusal: e.refusal ? `not read: ${e.refusal.error}` : null,
|
|
138
|
+
runs: e.refusal ? [] : runsLines(e, now),
|
|
139
|
+
gates: (e.waiting || []).filter((g) => g.state === "pending" || g.override).map((g) => laneGateCard(g, a, opts)),
|
|
140
|
+
})),
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Render into `host`. `ui.button(label, cls, onClick)` and `ui.link(text,
|
|
146
|
+
* href)` are app.js's; `ui.approve(key, env, button)` posts the approval;
|
|
147
|
+
* `ui.embed` and `ui.canApprove` say whether a button may be drawn;
|
|
148
|
+
* `ui.openChangeSet(key, env)` draws a gate's change set on the graph (#681).
|
|
149
|
+
*/
|
|
150
|
+
export function renderTrunkLane(host, a, now, ui) {
|
|
151
|
+
host.replaceChildren();
|
|
152
|
+
const v = laneView(a, now, { embed: !!(ui && ui.embed) });
|
|
153
|
+
const line = (cls, text, title) => {
|
|
154
|
+
const d = document.createElement("div");
|
|
155
|
+
d.className = cls;
|
|
156
|
+
d.textContent = text;
|
|
157
|
+
if (title) d.title = title;
|
|
158
|
+
host.appendChild(d);
|
|
159
|
+
return d;
|
|
160
|
+
};
|
|
161
|
+
line(v.legend.tone === "refusal" ? "tg-refusal" : "tg-legend", v.legend.text, v.legend.title);
|
|
162
|
+
for (const n of v.notes) line("tg-legend", n);
|
|
163
|
+
if (!v.commits.length && !v.environments.length) return;
|
|
164
|
+
|
|
165
|
+
const h = document.createElement("h3");
|
|
166
|
+
h.textContent = "trunk";
|
|
167
|
+
host.appendChild(h);
|
|
168
|
+
if (v.empty) line("tg-legend", v.empty);
|
|
169
|
+
for (const c of v.commits) {
|
|
170
|
+
const row = document.createElement("div");
|
|
171
|
+
row.className = "lane-commit";
|
|
172
|
+
row.dataset.sha = c.sha;
|
|
173
|
+
row.title = c.title;
|
|
174
|
+
const head = document.createElement("div");
|
|
175
|
+
const state = document.createElement("span");
|
|
176
|
+
state.className = `lane-sha lane-${c.state}`;
|
|
177
|
+
state.textContent = c.head;
|
|
178
|
+
head.append(state, document.createTextNode(` · ${c.when}`));
|
|
179
|
+
if (c.where) {
|
|
180
|
+
const where = document.createElement("span");
|
|
181
|
+
where.className = "lane-where";
|
|
182
|
+
where.textContent = ` · ${c.where}`;
|
|
183
|
+
head.appendChild(where);
|
|
184
|
+
}
|
|
185
|
+
row.appendChild(head);
|
|
186
|
+
if (c.facts.length || c.runs.length) {
|
|
187
|
+
const facts = document.createElement("div");
|
|
188
|
+
facts.className = "lane-facts";
|
|
189
|
+
c.facts.forEach((f, i) => {
|
|
190
|
+
const s = document.createElement("span");
|
|
191
|
+
s.textContent = `${i ? " · " : ""}${f.text}`;
|
|
192
|
+
if (f.title) s.title = f.title;
|
|
193
|
+
facts.appendChild(s);
|
|
194
|
+
});
|
|
195
|
+
for (const r of c.runs) {
|
|
196
|
+
if (facts.childNodes.length) facts.appendChild(document.createTextNode(" · "));
|
|
197
|
+
const a = ui && ui.link ? ui.link(r.text, r.href) : document.createTextNode(r.text);
|
|
198
|
+
if (a.title !== undefined) a.title = r.title;
|
|
199
|
+
facts.appendChild(a);
|
|
200
|
+
}
|
|
201
|
+
row.appendChild(facts);
|
|
202
|
+
}
|
|
203
|
+
host.appendChild(row);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
for (const e of v.environments) {
|
|
207
|
+
const eh = document.createElement("h3");
|
|
208
|
+
eh.textContent = e.heading;
|
|
209
|
+
host.appendChild(eh);
|
|
210
|
+
if (e.refusal) line("tg-refusal", e.refusal);
|
|
211
|
+
for (const r of e.runs) line("lane-runs", r.text, r.title);
|
|
212
|
+
for (const g of e.gates) {
|
|
213
|
+
const box = document.createElement("div");
|
|
214
|
+
box.className = "ws-gate";
|
|
215
|
+
box.dataset.gate = g.key;
|
|
216
|
+
const title = document.createElement("div");
|
|
217
|
+
title.className = "ws-gate-title";
|
|
218
|
+
title.textContent = g.title;
|
|
219
|
+
const facts = document.createElement("div");
|
|
220
|
+
facts.className = "ws-gate-facts";
|
|
221
|
+
facts.textContent = g.facts;
|
|
222
|
+
facts.title = g.command;
|
|
223
|
+
// #681: the change set the gate binds, as the link that opens the overlay.
|
|
224
|
+
if (g.changeSet) {
|
|
225
|
+
facts.appendChild(document.createTextNode(" · "));
|
|
226
|
+
if (ui && ui.openChangeSet) {
|
|
227
|
+
const a = document.createElement("a");
|
|
228
|
+
a.href = "#";
|
|
229
|
+
a.className = "lane-change-set";
|
|
230
|
+
a.textContent = g.changeSet.text;
|
|
231
|
+
a.title = g.changeSet.title;
|
|
232
|
+
a.addEventListener("click", (ev) => {
|
|
233
|
+
ev.preventDefault();
|
|
234
|
+
ui.openChangeSet(g.key, e.env);
|
|
235
|
+
});
|
|
236
|
+
facts.appendChild(a);
|
|
237
|
+
} else facts.appendChild(document.createTextNode(g.changeSet.text));
|
|
238
|
+
}
|
|
239
|
+
box.append(title, facts);
|
|
240
|
+
if (g.note) {
|
|
241
|
+
const note = document.createElement("div");
|
|
242
|
+
note.className = "ws-gate-note";
|
|
243
|
+
note.textContent = g.note;
|
|
244
|
+
box.appendChild(note);
|
|
245
|
+
}
|
|
246
|
+
if (g.button && ui && ui.canApprove && ui.button && ui.approve) {
|
|
247
|
+
const b = ui.button(g.button.label, "approve", () => ui.approve(g.key, e.env, b));
|
|
248
|
+
b.title = g.button.title;
|
|
249
|
+
box.appendChild(b);
|
|
250
|
+
}
|
|
251
|
+
host.appendChild(box);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|