@basaltkit/deploy-ui 0.3.0 → 0.5.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/README.md +12 -1
- package/dist/client/api.js +6 -5
- package/dist/client/app.js +82 -38
- package/dist/client/dialog.js +3 -2
- package/dist/client/i18n-messages.js +14 -0
- package/dist/client/i18n.js +777 -0
- package/dist/client/icons.js +2 -0
- package/dist/client/main.js +12 -10
- package/dist/client/messages.d.ts +2 -0
- package/dist/client/reply.js +8 -7
- package/dist/client/version.js +70 -0
- package/dist/client/view-commits.js +10 -24
- package/dist/client/view-history.js +39 -34
- package/dist/client/view-plan.js +36 -35
- package/dist/client/view-run.js +52 -48
- package/dist/client/view-status.js +28 -26
- package/dist/client/view-targets.js +30 -25
- package/dist/page.d.ts +2 -2
- package/dist/page.js +10 -1
- package/dist/server.js +9 -3
- package/dist/targets.d.ts +6 -0
- package/dist/targets.js +8 -2
- package/package.json +7 -6
package/dist/client/view-plan.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { confirmDialog } from './dialog.js';
|
|
2
2
|
import { append, button, card, el, emptyState, pageHead, replace } from './dom.js';
|
|
3
|
+
import { t } from './i18n.js';
|
|
3
4
|
import { icon } from './icons.js';
|
|
4
5
|
import { banner, describe, diagnosticsBlock, problem } from './reply.js';
|
|
5
6
|
import { ApiError } from './api.js';
|
|
@@ -8,21 +9,21 @@ import { commitsBlock, rangeSpan, validCommits } from './view-commits.js';
|
|
|
8
9
|
export function renderPlan(app) {
|
|
9
10
|
const reply = app.planReply;
|
|
10
11
|
const plan = app.plan;
|
|
11
|
-
const root = el('section', { aria: { labelledby: 'plan-title' } }, pageHead('plan-title', '
|
|
12
|
+
const root = el('section', { aria: { labelledby: 'plan-title' } }, pageHead('plan-title', t('screen.plan'), t('plan.sub'), button(app.planBusy ? t('plan.planning') : plan ? t('plan.again') : t('plan.run'), () => { void app.runPlan(); }, { disabled: app.planBusy, class: plan ? '' : 'primary' })));
|
|
12
13
|
if (!reply) {
|
|
13
14
|
append(root, app.planBusy
|
|
14
|
-
? emptyState('refresh', '
|
|
15
|
-
: emptyState('plan', '
|
|
15
|
+
? emptyState('refresh', t('plan.planning'), t('plan.planningText'))
|
|
16
|
+
: emptyState('plan', t('plan.none'), t('plan.noneText')));
|
|
16
17
|
return root;
|
|
17
18
|
}
|
|
18
19
|
if (!plan) {
|
|
19
|
-
append(root, problem(reply) ?? el('p', {}, '
|
|
20
|
+
append(root, problem(reply) ?? el('p', {}, t('plan.noneBack')));
|
|
20
21
|
return root;
|
|
21
22
|
}
|
|
22
23
|
append(root, ...findings(plan.findings));
|
|
23
24
|
append(root, outgoing(plan.commits));
|
|
24
25
|
if (plan.lines.length > 0) {
|
|
25
|
-
append(root, card('
|
|
26
|
+
append(root, card(t('plan.wouldDo'), [el('div', { class: 'table-wrap' }, el('table', { class: 'plan-lines' }, el('tbody', {}, ...plan.lines.map((line) => el('tr', {}, el('th', { scope: 'row' }, el('span', { class: 'step-chip' }, line.step)), el('td', {}, line.text))))))], { bodyClass: 'flush' }));
|
|
26
27
|
}
|
|
27
28
|
if (reply.diagnostics.length > 0)
|
|
28
29
|
append(root, diagnosticsBlock(reply.diagnostics));
|
|
@@ -33,25 +34,25 @@ export function renderPlan(app) {
|
|
|
33
34
|
function outgoing(commits) {
|
|
34
35
|
const range = validCommits(commits) && commits.ok ? commits.range : undefined;
|
|
35
36
|
const summary = !range ? null
|
|
36
|
-
: range.relation === 'ahead' ?
|
|
37
|
-
: range.relation === 'diverged' ?
|
|
38
|
-
: range.relation === 'behind' ?
|
|
37
|
+
: range.relation === 'ahead' ? t('plan.commitCount', { count: range.addedTotal })
|
|
38
|
+
: range.relation === 'diverged' ? t('plan.diverged', { added: range.addedTotal, removed: range.removedTotal })
|
|
39
|
+
: range.relation === 'behind' ? t('plan.behindCount', { count: range.removedTotal })
|
|
39
40
|
: null;
|
|
40
|
-
return card('
|
|
41
|
-
range?.relation === 'diverged' ? banner('warn', '
|
|
42
|
-
range?.relation === 'behind' ? banner('warn', '
|
|
43
|
-
range?.held ? banner('warn', '
|
|
44
|
-
commitsBlock(commits, { added: '
|
|
41
|
+
return card(t('plan.goesOutTitle'), [
|
|
42
|
+
range?.relation === 'diverged' ? banner('warn', t('plan.rewritten'), [t('plan.rewrittenHelp')]) : null,
|
|
43
|
+
range?.relation === 'behind' ? banner('warn', t('plan.behind'), [t('plan.behindHelp')]) : null,
|
|
44
|
+
range?.held ? banner('warn', t('plan.heldByRollback'), [t('plan.heldByRollbackHelp')]) : null,
|
|
45
|
+
commitsBlock(commits, { added: t('plan.goesOut'), removed: t('plan.onlyOnServer'), same: t('plan.nothingNew') }),
|
|
45
46
|
], { actions: range && range.relation !== 'same' ? [summary ? el('span', { class: 'muted' }, summary) : null, rangeSpan(range)] : [] });
|
|
46
47
|
}
|
|
47
48
|
function findings(list) {
|
|
48
49
|
if (list.length === 0)
|
|
49
|
-
return [banner('ok', '
|
|
50
|
+
return [banner('ok', t('plan.noProblem'))];
|
|
50
51
|
const sorted = [...list].sort((a, b) => (a.level === b.level ? 0 : a.level === 'error' ? -1 : 1));
|
|
51
52
|
const errors = list.filter((f) => f.level === 'error').length;
|
|
52
|
-
return [card('
|
|
53
|
+
return [card(t('plan.findings'), [findingList(sorted)], {
|
|
53
54
|
bodyClass: 'flush',
|
|
54
|
-
actions: [el('span', { class: 'muted' }, `${errors
|
|
55
|
+
actions: [el('span', { class: 'muted' }, `${t('plan.errors', { count: errors })}, ${t('plan.warnings', { count: list.length - errors })}`)],
|
|
55
56
|
})];
|
|
56
57
|
}
|
|
57
58
|
/** Findings with a severity badge; the fix is copyable text, never run by the page. */
|
|
@@ -59,24 +60,24 @@ export function findingList(list, label) {
|
|
|
59
60
|
return el('ul', { class: 'findings', ...(label ? { aria: { label } } : {}) }, ...list.map((f) => findingItem(f)));
|
|
60
61
|
}
|
|
61
62
|
export function findingItem(f) {
|
|
62
|
-
return el('li', { class: 'finding' }, el('span', { class: `sev sev-${f.level === 'error' ? 'error' : 'warning'}` }, f.level === 'error' ? '
|
|
63
|
+
return el('li', { class: 'finding' }, el('span', { class: `sev sev-${f.level === 'error' ? 'error' : 'warning'}` }, f.level === 'error' ? t('sev.error') : t('sev.warning')), el('span', { class: 'finding-msg' }, f.id ? el('span', { class: 'finding-id' }, `[${f.id}] `) : null, f.message), f.fix ? el('div', { class: 'fix' }, el('span', { class: 'fix-label' }, t('plan.fix')), el('code', {}, f.fix)) : null);
|
|
63
64
|
}
|
|
64
65
|
function questionField(question, index) {
|
|
65
66
|
const id = `q-${index}`;
|
|
66
|
-
const label = el('label', { for: id }, question.message, question.optional ? '' : el('span', { class: 'required', title: 'required' }, ' *'), question.key ? el('span', { class: 'field-key' }, ` (${question.key})`) : null);
|
|
67
|
+
const label = el('label', { for: id }, question.message, question.optional ? '' : el('span', { class: 'required', title: t('form.required') }, ' *'), question.key ? el('span', { class: 'field-key' }, ` (${question.key})`) : null);
|
|
67
68
|
let input;
|
|
68
69
|
if (question.kind === 'secret') {
|
|
69
70
|
// No default, no autocomplete, no spellcheck: a secret is typed, sent once, and the field is emptied.
|
|
70
71
|
input = el('input', { type: 'password', id, autocomplete: 'off', spellcheck: false, required: !question.optional, aria: { describedby: `${id}-error` } });
|
|
71
72
|
}
|
|
72
73
|
else if (question.kind === 'choice') {
|
|
73
|
-
input = el('select', { id, aria: { describedby: `${id}-error` } }, ...(question.optional ? [el('option', { value: '' }, '
|
|
74
|
+
input = el('select', { id, aria: { describedby: `${id}-error` } }, ...(question.optional ? [el('option', { value: '' }, t('form.none'))] : []), ...(question.choices ?? []).map((c) => el('option', { value: c }, c)));
|
|
74
75
|
if (question.default !== undefined)
|
|
75
76
|
input.value = question.default;
|
|
76
77
|
}
|
|
77
78
|
else if (question.kind === 'confirm') {
|
|
78
79
|
input = el('input', { type: 'checkbox', id, checked: question.default === 'yes' || question.default === 'true', aria: { describedby: `${id}-error` } });
|
|
79
|
-
return { node: el('div', { class: 'field check' }, el('label', { for: id }, input, el('span', {}, question.message, question.optional ? '' : el('span', { class: 'required', title: 'required' }, ' *'), question.key ? el('span', { class: 'field-key' }, ` (${question.key})`) : null)), el('span', { id: `${id}-error`, class: 'field-error' })), field: { question, input } };
|
|
80
|
+
return { node: el('div', { class: 'field check' }, el('label', { for: id }, input, el('span', {}, question.message, question.optional ? '' : el('span', { class: 'required', title: t('form.required') }, ' *'), question.key ? el('span', { class: 'field-key' }, ` (${question.key})`) : null)), el('span', { id: `${id}-error`, class: 'field-error' })), field: { question, input } };
|
|
80
81
|
}
|
|
81
82
|
else {
|
|
82
83
|
input = el('input', { type: 'text', id, value: question.default ?? '', autocomplete: 'off', spellcheck: false, required: !question.optional, aria: { describedby: `${id}-error` } });
|
|
@@ -104,7 +105,7 @@ function clearFields(fields) {
|
|
|
104
105
|
}
|
|
105
106
|
}
|
|
106
107
|
function deployForm(app, questions, blocking) {
|
|
107
|
-
const
|
|
108
|
+
const target = app.current;
|
|
108
109
|
const fields = [];
|
|
109
110
|
const nodes = questions.map((q, i) => {
|
|
110
111
|
const { node, field } = questionField(q, i);
|
|
@@ -122,7 +123,7 @@ function deployForm(app, questions, blocking) {
|
|
|
122
123
|
replace(slot, text);
|
|
123
124
|
};
|
|
124
125
|
const send = async (route) => {
|
|
125
|
-
if (!
|
|
126
|
+
if (!target)
|
|
126
127
|
return;
|
|
127
128
|
replace(message);
|
|
128
129
|
for (let i = 0; i < questions.length; i++) {
|
|
@@ -132,33 +133,33 @@ function deployForm(app, questions, blocking) {
|
|
|
132
133
|
}
|
|
133
134
|
const deploy = route === 'run';
|
|
134
135
|
const ok = await confirmDialog({
|
|
135
|
-
title: deploy ?
|
|
136
|
-
context:
|
|
136
|
+
title: deploy ? t('plan.deployTo', { name: target.name }) : t('plan.writeEnvOn', { name: target.name }),
|
|
137
|
+
context: [target.ssh, target.dir, app.hello ? t('ctx.hostPart', { host: app.hello.host }) : null, app.status ? t('ctx.appPart', { app: app.status.app }) : null].filter(Boolean).join(' · '),
|
|
137
138
|
lines: [
|
|
138
|
-
deploy ? '
|
|
139
|
-
deploy && app.plan?.lines.some((l) => /migrat/i.test(l.step) || /migrat/i.test(l.text)) ? el('strong', {}, '
|
|
139
|
+
deploy ? t('plan.deployLine') : t('plan.envLine'),
|
|
140
|
+
deploy && app.plan?.lines.some((l) => /migrat/i.test(l.step) || /migrat/i.test(l.text)) ? el('strong', {}, t('plan.willMigrate')) : null,
|
|
140
141
|
],
|
|
141
|
-
confirmLabel: deploy ? '
|
|
142
|
+
confirmLabel: deploy ? t('plan.deploy') : t('plan.writeEnv'),
|
|
142
143
|
danger: true,
|
|
143
|
-
...(
|
|
144
|
+
...(target.protected ? { typeToConfirm: target.name } : {}),
|
|
144
145
|
});
|
|
145
146
|
if (!ok)
|
|
146
147
|
return;
|
|
147
148
|
const answers = collectAnswers(fields);
|
|
148
149
|
clearFields(fields);
|
|
149
|
-
const body = { target:
|
|
150
|
+
const body = { target: target.name, confirm: true, confirmedTarget: target, answers, ...(target.protected ? { confirmName: target.name } : {}) };
|
|
150
151
|
if (!deploy) {
|
|
151
|
-
app.attended(
|
|
152
|
+
app.attended(t('plan.envOn', { name: target.name }), 'env', body);
|
|
152
153
|
return;
|
|
153
154
|
}
|
|
154
155
|
if (unhold.checked)
|
|
155
156
|
body['unhold'] = true;
|
|
156
157
|
if (attended.checked) {
|
|
157
158
|
body['attended'] = true;
|
|
158
|
-
app.attended(
|
|
159
|
+
app.attended(t('plan.runAttended', { name: target.name }), 'run', body);
|
|
159
160
|
return;
|
|
160
161
|
}
|
|
161
|
-
replace(message, el('p', { class: 'muted' }, '
|
|
162
|
+
replace(message, el('p', { class: 'muted' }, t('plan.starting')));
|
|
162
163
|
let reply;
|
|
163
164
|
try {
|
|
164
165
|
reply = await app.api.post('run', body);
|
|
@@ -174,15 +175,15 @@ function deployForm(app, questions, blocking) {
|
|
|
174
175
|
const result = reply.result;
|
|
175
176
|
if (reply.ok && result?.runId) {
|
|
176
177
|
replace(message);
|
|
177
|
-
app.watch(result.runId,
|
|
178
|
+
app.watch(result.runId, t('run.title', { runId: result.runId }));
|
|
178
179
|
return;
|
|
179
180
|
}
|
|
180
181
|
if (reply.error && /^answer-/.test(reply.error.code)) {
|
|
181
182
|
const id = /env\.[A-Z_][A-Z0-9_]*/.exec(reply.error.message)?.[0];
|
|
182
183
|
if (id)
|
|
183
|
-
showFieldError(id,
|
|
184
|
+
showFieldError(id, t('plan.typeAgain', { message: reply.error.message }));
|
|
184
185
|
}
|
|
185
186
|
replace(message, problem(reply));
|
|
186
187
|
};
|
|
187
|
-
return el('form', { class: 'card', aria: { label: '
|
|
188
|
+
return el('form', { class: 'card', aria: { label: t('plan.deploy') }, on: { submit: (event) => { event.preventDefault(); void send('run'); } } }, el('div', { class: 'card-head' }, el('h3', {}, questions.length > 0 ? t('plan.willAsk') : t('plan.deploy')), target?.protected ? el('span', { class: 'badge badge-protected' }, icon('shield'), t('protected.badge')) : null), el('div', { class: 'card-body' }, el('p', { class: 'form-note' }, icon(questions.length > 0 ? 'lock' : 'ok'), questions.length > 0 ? t('plan.secrets') : t('plan.nothingToAnswer')), nodes.length > 0 ? el('div', { class: 'form-section' }, ...nodes) : null, el('div', { class: 'form-section' }, hold ? el('div', { class: 'field check' }, el('label', { for: 'unhold' }, unhold, el('span', {}, t('plan.unhold'), el('code', {}, hold.sha.slice(0, 12)), t('plan.unholdTail')))) : null, el('details', { class: 'advanced' }, el('summary', {}, t('plan.advanced')), el('div', { class: 'field check' }, el('label', { for: 'attended' }, attended, el('span', {}, t('plan.attended')))))), blocking ? banner('err', t('plan.blocks')) : null, message), el('div', { class: 'card-foot' }, button(t('plan.writeEnvOnly'), () => { void send('env'); }), el('button', { type: 'submit', class: 'primary', disabled: blocking }, t('plan.deployEllipsis'))));
|
|
188
189
|
}
|
package/dist/client/view-run.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ApiError } from './api.js';
|
|
2
2
|
import { confirmDialog } from './dialog.js';
|
|
3
3
|
import { append, button, el, quiet, replace } from './dom.js';
|
|
4
|
+
import { serverText, t } from './i18n.js';
|
|
4
5
|
import { icon } from './icons.js';
|
|
5
6
|
import { findingItem } from './view-plan.js';
|
|
6
7
|
import { banner, describe, errorBanner, problem } from './reply.js';
|
|
@@ -45,14 +46,14 @@ export class RunView {
|
|
|
45
46
|
this.target = target;
|
|
46
47
|
this.runId = runId;
|
|
47
48
|
this.stateLine = el('p', { class: 'run-state', role: 'status', aria: { live: 'polite' } });
|
|
48
|
-
this.steps = el('ol', { class: 'steps', aria: { label: '
|
|
49
|
-
this.findings = el('ul', { class: 'findings', aria: { label: '
|
|
50
|
-
this.log = el('ol', { class: 'log', aria: { label: '
|
|
49
|
+
this.steps = el('ol', { class: 'steps', aria: { label: t('run.steps') } });
|
|
50
|
+
this.findings = el('ul', { class: 'findings', aria: { label: t('run.findings') } });
|
|
51
|
+
this.log = el('ol', { class: 'log', aria: { label: t('run.log') } });
|
|
51
52
|
this.outcome = el('div', { class: 'run-outcome' });
|
|
52
53
|
this.actions = el('div', { class: 'page-actions' });
|
|
53
54
|
this.diagnostics = el('pre', { class: 'diagnostics', hidden: true });
|
|
54
|
-
this.findingsCard = el('div', { class: 'card', hidden: true }, el('div', { class: 'card-head' }, el('h3', {}, '
|
|
55
|
-
this.element = el('section', { aria: { labelledby: 'run-title' } }, el('header', { class: 'page-head' }, el('div', { class: 'page-title' }, el('h2', { id: 'run-title', class: 'mono-title' }, title), el('p', { class: 'page-sub' }, `${target.name} · ${target.ssh} · ${target.dir}`)), this.actions), this.stateLine, this.outcome, el('div', { class: 'run-grid' }, el('div', { class: 'card' }, el('div', { class: 'card-head' }, el('h3', {}, '
|
|
55
|
+
this.findingsCard = el('div', { class: 'card', hidden: true }, el('div', { class: 'card-head' }, el('h3', {}, t('run.findings'))), el('div', { class: 'card-body flush' }, this.findings));
|
|
56
|
+
this.element = el('section', { aria: { labelledby: 'run-title' } }, el('header', { class: 'page-head' }, el('div', { class: 'page-title' }, el('h2', { id: 'run-title', class: 'mono-title' }, title), el('p', { class: 'page-sub' }, `${target.name} · ${target.ssh} · ${target.dir}`)), this.actions), this.stateLine, this.outcome, el('div', { class: 'run-grid' }, el('div', { class: 'card' }, el('div', { class: 'card-head' }, el('h3', {}, t('run.steps'))), el('div', { class: 'card-body' }, this.steps)), el('div', { class: 'console' }, el('div', { class: 'console-head' }, el('h3', {}, icon('terminal'), t('run.log')), el('span', { class: 'console-meta' }, target.name)), this.log)), this.findingsCard, this.diagnostics);
|
|
56
57
|
this.renderActions();
|
|
57
58
|
}
|
|
58
59
|
/** Where to resume: the seq after the last one this tab saw for this run, kept in sessionStorage (not a secret). */
|
|
@@ -76,7 +77,7 @@ export class RunView {
|
|
|
76
77
|
if (!this.runId)
|
|
77
78
|
return;
|
|
78
79
|
if (fromSeq > 0)
|
|
79
|
-
this.note(
|
|
80
|
+
this.note(t('run.resuming', { seq: fromSeq }));
|
|
80
81
|
await this.consume('attach', { target: this.target.name, runId: this.runId, fromSeq });
|
|
81
82
|
}
|
|
82
83
|
async streamAttended(route, body) {
|
|
@@ -102,7 +103,7 @@ export class RunView {
|
|
|
102
103
|
this.following = false;
|
|
103
104
|
if (!this.ended) {
|
|
104
105
|
this.settleSteps();
|
|
105
|
-
this.setState(this.controller.signal.aborted ? '
|
|
106
|
+
this.setState(this.controller.signal.aborted ? t('run.stoppedWatching') : t('run.streamEnded'));
|
|
106
107
|
}
|
|
107
108
|
this.renderActions();
|
|
108
109
|
}
|
|
@@ -125,9 +126,9 @@ export class RunView {
|
|
|
125
126
|
}
|
|
126
127
|
state(message) {
|
|
127
128
|
if (message.state === 'connecting')
|
|
128
|
-
return this.setState(
|
|
129
|
+
return this.setState(t('run.connecting', { ssh: this.target.ssh }), 'live');
|
|
129
130
|
if (message.state === 'reconnecting') {
|
|
130
|
-
return this.setState(
|
|
131
|
+
return this.setState(t('run.reconnecting', { reason: clean(message.reason), seconds: Math.round((message.retryInMs ?? 0) / 1000), seq: this.lastSeq === undefined ? 0 : this.lastSeq + 1 }), 'live');
|
|
131
132
|
}
|
|
132
133
|
this.ended = true;
|
|
133
134
|
if (message.exitCode !== undefined)
|
|
@@ -135,7 +136,7 @@ export class RunView {
|
|
|
135
136
|
if (this.runId && message.exitCode !== undefined && !message.code) {
|
|
136
137
|
this.runFinished = true;
|
|
137
138
|
if (message.reason)
|
|
138
|
-
this.note(`(${clean(message.reason)})`);
|
|
139
|
+
this.note(`(${serverText(clean(message.reason))})`);
|
|
139
140
|
}
|
|
140
141
|
if (message.code) {
|
|
141
142
|
this.failed = { code: message.code, ...(message.reason ? { reason: message.reason } : {}), ...(message.hint ? { hint: message.hint } : {}) };
|
|
@@ -153,16 +154,16 @@ export class RunView {
|
|
|
153
154
|
}
|
|
154
155
|
}
|
|
155
156
|
if (!known)
|
|
156
|
-
return this.line('warn',
|
|
157
|
+
return this.line('warn', t('run.unknownEvent', { type: event.type }));
|
|
157
158
|
switch (event.type) {
|
|
158
159
|
case 'hello':
|
|
159
160
|
return;
|
|
160
161
|
case 'step-start': {
|
|
161
|
-
const node = el('li', { class: 'step is-running' }, el('span', { class: 'step-icon', aria: { hidden: 'true' } }, '▸'), ' ', el('span', { class: 'step-title' }, event.title), el('span', { class: 'step-meta' }, quiet(' '), quiet('…'), el('span', { class: 'step-status', aria: { hidden: 'true' } }, 'running')));
|
|
162
|
+
const node = el('li', { class: 'step is-running' }, el('span', { class: 'step-icon', aria: { hidden: 'true' } }, '▸'), ' ', el('span', { class: 'step-title' }, event.title), el('span', { class: 'step-meta' }, quiet(' '), quiet('…'), el('span', { class: 'step-status', aria: { hidden: 'true' } }, t('step.running'))));
|
|
162
163
|
this.stepNodes.set(event.id, node);
|
|
163
164
|
this.stepTitles.set(event.id, event.title);
|
|
164
165
|
this.steps.append(node);
|
|
165
|
-
this.setState(
|
|
166
|
+
this.setState(t('run.step', { title: event.title }), 'live');
|
|
166
167
|
return;
|
|
167
168
|
}
|
|
168
169
|
case 'step-end': {
|
|
@@ -172,7 +173,7 @@ export class RunView {
|
|
|
172
173
|
const title = this.stepTitles.get(event.id) ?? event.id;
|
|
173
174
|
node.className = `step is-${event.status === 'ok' ? 'ok' : event.status === 'skipped' ? 'skipped' : 'failed'}`;
|
|
174
175
|
// The text reads "✓ build — ok, 1.5 s"; the layout draws the mark as an icon and the duration in a column.
|
|
175
|
-
replace(node, el('span', { class: 'step-icon', aria: { hidden: 'true' } }, mark), quiet(' '), el('span', { class: 'step-title' }, title), el('span', { class: 'step-meta' }, quiet(' — '), el('span', { class: 'step-status' }, event.status), quiet(', '), el('span', { class: 'step-dur' }, `${(event.durationMs / 1000).toFixed(1)} s`)));
|
|
176
|
+
replace(node, el('span', { class: 'step-icon', aria: { hidden: 'true' } }, mark), quiet(' '), el('span', { class: 'step-title' }, title), el('span', { class: 'step-meta' }, quiet(' — '), el('span', { class: 'step-status' }, stepStatus(event.status)), quiet(', '), el('span', { class: 'step-dur' }, `${(event.durationMs / 1000).toFixed(1)} s`)));
|
|
176
177
|
if (!node.parentNode)
|
|
177
178
|
this.steps.append(node);
|
|
178
179
|
return;
|
|
@@ -184,7 +185,7 @@ export class RunView {
|
|
|
184
185
|
this.findings.append(findingItem(event));
|
|
185
186
|
return;
|
|
186
187
|
case 'prompt':
|
|
187
|
-
return this.line('warn',
|
|
188
|
+
return this.line('warn', t('run.asks', { message: event.message }));
|
|
188
189
|
case 'result':
|
|
189
190
|
this.outcome.append(resultBanner(event.command, event.data, this.runId ? this.app.previewedRollbacks.get(this.runId) : undefined));
|
|
190
191
|
return;
|
|
@@ -199,7 +200,7 @@ export class RunView {
|
|
|
199
200
|
return;
|
|
200
201
|
case 'event':
|
|
201
202
|
// Only the server unwraps attach; a nested wrapper here is a log-worthy oddity.
|
|
202
|
-
return this.line('warn', '
|
|
203
|
+
return this.line('warn', t('run.wrapped'));
|
|
203
204
|
}
|
|
204
205
|
}
|
|
205
206
|
line(level, textValue, source, ts) {
|
|
@@ -227,7 +228,7 @@ export class RunView {
|
|
|
227
228
|
node.classList.replace('is-running', 'is-aborted');
|
|
228
229
|
const status = node.querySelector('.step-status');
|
|
229
230
|
if (status)
|
|
230
|
-
replace(status, '
|
|
231
|
+
replace(status, t('run.noEnd'));
|
|
231
232
|
}
|
|
232
233
|
}
|
|
233
234
|
setDropped() {
|
|
@@ -235,7 +236,7 @@ export class RunView {
|
|
|
235
236
|
}
|
|
236
237
|
setState(textValue, tone) {
|
|
237
238
|
this.stateLine.className = `run-state${tone ? ` is-${tone}` : ''}`;
|
|
238
|
-
replace(this.stateLine, textValue, this.dropped > 0 ?
|
|
239
|
+
replace(this.stateLine, textValue, this.dropped > 0 ? t('run.dropped', { count: this.dropped }) : '');
|
|
239
240
|
}
|
|
240
241
|
finish() {
|
|
241
242
|
// Status is refreshed once after any action (no polling loop).
|
|
@@ -243,34 +244,36 @@ export class RunView {
|
|
|
243
244
|
this.settleSteps();
|
|
244
245
|
if (this.failed && this.exitCode === undefined) {
|
|
245
246
|
const reconnectable = this.runId !== undefined;
|
|
246
|
-
|
|
247
|
-
this.
|
|
247
|
+
const reason = this.failed.reason === undefined ? undefined : serverText(clean(this.failed.reason));
|
|
248
|
+
this.setState(t('run.stoppedBecause', { why: reason ?? clean(this.failed.code) }), 'err');
|
|
249
|
+
this.outcome.append(banner('err', reason ?? t('run.streamEndedLower'), [this.failed.hint ? serverText(clean(this.failed.hint)) : '', reconnectable ? t('run.mayStillRun') : ''], [], this.failed.code));
|
|
248
250
|
}
|
|
249
251
|
else if (this.exitCode === 0) {
|
|
250
|
-
this.setState('
|
|
251
|
-
this.outcome.append(banner('ok', '
|
|
252
|
+
this.setState(t('run.done'), 'ok');
|
|
253
|
+
this.outcome.append(banner('ok', t('run.finishedOk')));
|
|
252
254
|
}
|
|
253
255
|
else {
|
|
254
|
-
|
|
256
|
+
const finished = t('run.finishedWith', { code: this.exitCode ?? t('unknown') });
|
|
257
|
+
this.setState(finished, 'err');
|
|
255
258
|
if (!this.lastError)
|
|
256
|
-
this.outcome.append(banner('err',
|
|
259
|
+
this.outcome.append(banner('err', finished));
|
|
257
260
|
}
|
|
258
261
|
this.renderActions();
|
|
259
262
|
}
|
|
260
263
|
renderActions() {
|
|
261
264
|
const buttons = [];
|
|
262
265
|
if (this.runId && !this.ended && this.following) {
|
|
263
|
-
buttons.push(button(this.cancels > 0 ? '
|
|
264
|
-
buttons.push(button('
|
|
266
|
+
buttons.push(button(this.cancels > 0 ? t('run.cancelAgain') : t('run.cancel'), () => { void this.cancel(this.cancels > 0); }, { class: 'danger' }));
|
|
267
|
+
buttons.push(button(t('run.stopWatching'), () => this.stop()));
|
|
265
268
|
}
|
|
266
269
|
if (this.runId && !this.following) {
|
|
267
270
|
// A finished run has nothing more to attach to: only a replay makes sense.
|
|
268
271
|
if (!this.runFinished)
|
|
269
|
-
buttons.push(button('
|
|
270
|
-
buttons.push(button('
|
|
272
|
+
buttons.push(button(t('run.reattach'), () => { void this.attach(this.lastSeq === undefined ? 0 : this.lastSeq + 1); }, { class: 'primary' }));
|
|
273
|
+
buttons.push(button(t('run.fromStart'), () => { this.app.watch(this.runId, t('run.title', { runId: this.runId }), true); }, this.runFinished ? { class: 'primary' } : {}));
|
|
271
274
|
}
|
|
272
275
|
if (!this.following)
|
|
273
|
-
buttons.push(button('
|
|
276
|
+
buttons.push(button(t('run.refreshStatus'), () => { void this.app.refreshStatus().then(() => this.app.show('status')); }));
|
|
274
277
|
replace(this.actions, ...buttons);
|
|
275
278
|
}
|
|
276
279
|
/** Two separate confirmations: the second one ends the deploy at once. */
|
|
@@ -279,22 +282,19 @@ export class RunView {
|
|
|
279
282
|
return;
|
|
280
283
|
const ok = await confirmDialog(second
|
|
281
284
|
? {
|
|
282
|
-
title: '
|
|
285
|
+
title: t('run.stopNowTitle'),
|
|
283
286
|
lines: [
|
|
284
|
-
'
|
|
285
|
-
el('strong', {}, '
|
|
286
|
-
'
|
|
287
|
+
t('run.stopNowLine'),
|
|
288
|
+
el('strong', {}, t('run.halfApplied')),
|
|
289
|
+
t('run.restoreInLog'),
|
|
287
290
|
],
|
|
288
|
-
confirmLabel: '
|
|
291
|
+
confirmLabel: t('run.stopItNow'),
|
|
289
292
|
danger: true,
|
|
290
293
|
}
|
|
291
294
|
: {
|
|
292
|
-
title:
|
|
293
|
-
lines: [
|
|
294
|
-
|
|
295
|
-
'A second cancel would stop it at once. If this run was already cancelled once (from a terminal or another session), nothing is sent now: you are asked again first.',
|
|
296
|
-
],
|
|
297
|
-
confirmLabel: 'Cancel the run',
|
|
295
|
+
title: t('run.cancelTitle', { name: this.target.name }),
|
|
296
|
+
lines: [t('run.cancelLine'), t('run.cancelSecondLine')],
|
|
297
|
+
confirmLabel: t('run.cancelRun'),
|
|
298
298
|
danger: true,
|
|
299
299
|
});
|
|
300
300
|
if (!ok)
|
|
@@ -312,7 +312,7 @@ export class RunView {
|
|
|
312
312
|
if (reply.ok) {
|
|
313
313
|
this.cancels++;
|
|
314
314
|
const result = reply.result;
|
|
315
|
-
this.note(result?.second ? '
|
|
315
|
+
this.note(result?.second ? t('run.cancelSentTwice') : t('run.cancelSent'));
|
|
316
316
|
this.renderActions();
|
|
317
317
|
return;
|
|
318
318
|
}
|
|
@@ -322,23 +322,27 @@ export class RunView {
|
|
|
322
322
|
function resultBanner(command, data, previewed) {
|
|
323
323
|
const d = (data ?? {});
|
|
324
324
|
if (command === 'run') {
|
|
325
|
-
return banner(d['status'] === 'ok' ? 'ok' : 'err',
|
|
325
|
+
return banner(d['status'] === 'ok' ? 'ok' : 'err', t('run.release', { sha: clean(d['sha']).slice(0, 12), status: stepStatus(clean(d['status'])) }), [
|
|
326
326
|
d['url'] ? `${clean(d['url'])}` : '',
|
|
327
|
-
Array.isArray(d['migrations']) && d['migrations'].length > 0 ?
|
|
327
|
+
Array.isArray(d['migrations']) && d['migrations'].length > 0 ? t('run.migrations', { list: d['migrations'].map(clean).join(', ') }) : '',
|
|
328
328
|
d['note'] ? clean(d['note']) : '',
|
|
329
329
|
]);
|
|
330
330
|
}
|
|
331
331
|
if (command === 'rollback') {
|
|
332
332
|
const to = clean(d['to']);
|
|
333
|
-
return banner(d['status'] === 'ok' ? 'ok' : 'err',
|
|
334
|
-
|
|
333
|
+
return banner(d['status'] === 'ok' ? 'ok' : 'err', t('run.rolledBack', { sha: to.slice(0, 12), status: stepStatus(clean(d['status'])) }), [
|
|
334
|
+
t('run.isHeld', { sha: clean(d['held']).slice(0, 12) }),
|
|
335
335
|
// The releases moved between the preview and the run: say which commit the deploy chose.
|
|
336
|
-
previewed && to && previewed !== to ? el('strong', {},
|
|
336
|
+
previewed && to && previewed !== to ? el('strong', {}, t('run.deployChose', { to: to.slice(0, 12), previewed: clean(previewed).slice(0, 12) })) : '',
|
|
337
337
|
]);
|
|
338
338
|
}
|
|
339
339
|
if (command === 'env') {
|
|
340
340
|
const changes = Array.isArray(d['changes']) ? d['changes'] : [];
|
|
341
|
-
return banner('ok',
|
|
341
|
+
return banner('ok', t('run.envWritten', { count: changes.length }), changes.map((c) => `${clean(c['kind'])} ${clean(c['key'])}: ${clean(c['reason'])}`));
|
|
342
342
|
}
|
|
343
|
-
return banner('ok',
|
|
343
|
+
return banner('ok', t('run.result', { command: clean(command) }));
|
|
344
|
+
}
|
|
345
|
+
/** A step's or a release's status in the page's language; one this UI does not know is shown as the server wrote it. */
|
|
346
|
+
function stepStatus(status) {
|
|
347
|
+
return status === 'ok' || status === 'skipped' || status === 'failed' ? t(`step.${status}`) : status;
|
|
344
348
|
}
|
|
@@ -1,60 +1,62 @@
|
|
|
1
1
|
import { button, card, el, emptyState, kv, pageHead, pill, quiet, when } from './dom.js';
|
|
2
|
+
import { t } from './i18n.js';
|
|
2
3
|
import { icon } from './icons.js';
|
|
3
4
|
import { banner, diagnosticsBlock, problem } from './reply.js';
|
|
4
5
|
import { short } from './sanitize.js';
|
|
6
|
+
import { driftBanner } from './version.js';
|
|
5
7
|
/** Status: from `StatusResult` — release, process, lock, active and last run, hold. Refresh is manual (and once after an action). */
|
|
6
8
|
export function renderStatus(app) {
|
|
7
9
|
const reply = app.statusReply;
|
|
8
10
|
const status = app.status;
|
|
9
|
-
return el('section', { aria: { labelledby: 'status-title' } }, pageHead('status-title', '
|
|
11
|
+
return el('section', { aria: { labelledby: 'status-title' } }, pageHead('status-title', t('screen.status'), t('status.sub'), el('button', { type: 'button', disabled: app.statusBusy, on: { click: () => { void app.refreshStatus(); } } }, icon('refresh'), app.statusBusy ? t('refreshing') : t('refresh'))), !reply && !app.statusBusy ? emptyState('status', t('status.notLoaded'), t('status.notLoadedText')) : null, !reply && app.statusBusy ? emptyState('refresh', t('status.asking'), t('status.askingText')) : null, app.hello ? driftBanner(app.hello.version) : null, reply && !status ? problem(reply) : null, ...(status ? statusPanels(app, status) : []), status && reply?.error ? problem(reply) : null, reply && reply.diagnostics.length > 0 && status ? diagnosticsBlock(reply.diagnostics) : null);
|
|
10
12
|
}
|
|
11
13
|
function statusPanels(app, s) {
|
|
12
14
|
const current = s.releases.find((r) => r.status === 'ok');
|
|
13
15
|
const panels = [];
|
|
14
16
|
if (s.hold) {
|
|
15
|
-
panels.push(banner('warn',
|
|
17
|
+
panels.push(banner('warn', t('status.held', { sha: short(s.hold.sha), at: when(s.hold.at), actor: s.hold.actor }), [
|
|
16
18
|
s.hold.note,
|
|
17
|
-
'
|
|
19
|
+
t('status.heldHelp'),
|
|
18
20
|
]));
|
|
19
21
|
}
|
|
20
22
|
if (s.activeRun) {
|
|
21
23
|
const run = s.activeRun;
|
|
22
|
-
panels.push(card('
|
|
23
|
-
el('p', { class: 'lead' }, run.alive ? pill('run', 'alive') : pill('warn', '
|
|
24
|
-
kv([['
|
|
25
|
-
], { class: 'accent', actions: [button('
|
|
24
|
+
panels.push(card(t('status.activeRun'), [
|
|
25
|
+
el('p', { class: 'lead' }, run.alive ? pill('run', t('status.alive')) : pill('warn', t('status.notSeenAlive')), el('span', { class: 'mono' }, run.runId)),
|
|
26
|
+
kv([[t('status.command'), run.command], [t('status.actor'), run.actor], [t('status.started'), el('span', { class: 'num' }, when(run.startedAt))]]),
|
|
27
|
+
], { class: 'accent', actions: [button(t('status.attach'), () => { app.watch(run.runId, `${run.command} ${run.runId}`); }, { class: 'primary' })] }));
|
|
26
28
|
}
|
|
27
|
-
const releaseCard = card('
|
|
29
|
+
const releaseCard = card(t('status.currentRelease'), current
|
|
28
30
|
? [
|
|
29
|
-
el('p', { class: 'lead' }, pill('ok', 'healthy'), el('code', {}, short(current.sha))),
|
|
31
|
+
el('p', { class: 'lead' }, pill('ok', t('status.healthy')), el('code', {}, short(current.sha))),
|
|
30
32
|
kv([
|
|
31
|
-
['
|
|
32
|
-
['
|
|
33
|
-
current.migrations.length > 0 ? ['
|
|
33
|
+
[t('status.deployed'), el('span', { class: 'num' }, when(current.at))],
|
|
34
|
+
[t('status.by'), current.via ? t('status.via', { who: current.actor ?? current.user, via: current.via }) : current.actor ?? current.user],
|
|
35
|
+
current.migrations.length > 0 ? [t('status.migrations'), el('span', { class: 'mono' }, current.migrations.join(', '))] : null,
|
|
34
36
|
]),
|
|
35
37
|
]
|
|
36
|
-
: [el('p', { class: 'muted' }, '
|
|
37
|
-
const processCard = card('
|
|
38
|
+
: [el('p', { class: 'muted' }, t('status.noHealthy'))]);
|
|
39
|
+
const processCard = card(t('status.process'), s.process.kind === 'pm2'
|
|
38
40
|
? [
|
|
39
|
-
el('p', { class: 'lead' }, el('span', { class: 'mono' }, `pm2 ${s.process.name}`), quiet(': '), s.process.running ? pill('ok', 'running') : pill('err', '
|
|
40
|
-
kv([['
|
|
41
|
+
el('p', { class: 'lead' }, el('span', { class: 'mono' }, `pm2 ${s.process.name}`), quiet(': '), s.process.running ? pill('ok', t('status.running')) : pill('err', t('status.notRunning')), s.process.status ? el('span', { class: 'muted' }, ` (${s.process.status})`) : ''),
|
|
42
|
+
kv([[t('status.manager'), 'pm2'], [t('status.name'), el('span', { class: 'mono' }, s.process.name)], s.process.pid !== undefined ? ['PID', el('span', { class: 'num mono' }, String(s.process.pid))] : null]),
|
|
41
43
|
]
|
|
42
44
|
: [el('pre', { class: 'diagnostics' }, s.process.lines.join('\n'))]);
|
|
43
45
|
const lock = s.lock;
|
|
44
|
-
const lockCard = card('
|
|
45
|
-
? [el('p', { class: 'lead' }, pill('ok', 'free'), el('span', { class: 'muted' }, '
|
|
46
|
+
const lockCard = card(t('status.lock'), !lock
|
|
47
|
+
? [el('p', { class: 'lead' }, pill('ok', t('status.free')), el('span', { class: 'muted' }, t('status.freeText')))]
|
|
46
48
|
: [
|
|
47
|
-
el('p', { class: 'lead' }, lock.corrupt ? pill('err', 'corrupt') : lock.stale ? pill('warn', 'stale') : pill('run', '
|
|
48
|
-
lock.holder ? el('p', {},
|
|
49
|
-
lock.stale ? el('p', { class: 'status-warn' }, el('strong', {},
|
|
49
|
+
el('p', { class: 'lead' }, lock.corrupt ? pill('err', t('status.corrupt')) : lock.stale ? pill('warn', t('status.stale')) : pill('run', t('status.heldPill')), lock.corrupt ? el('strong', { class: 'status-err' }, t('status.corruptLock')) : null),
|
|
50
|
+
lock.holder ? el('p', {}, t('status.lockHolder', { ...lock.holder, since: when(lock.holder.startedAt) })) : null,
|
|
51
|
+
lock.stale ? el('p', { class: 'status-warn' }, el('strong', {}, t('status.staleNote'))) : null,
|
|
50
52
|
]);
|
|
51
|
-
const lastRunCard = s.lastRun ? lastRun(app, s.lastRun) : card('
|
|
53
|
+
const lastRunCard = s.lastRun ? lastRun(app, s.lastRun) : card(t('status.lastRun'), [el('p', { class: 'muted' }, t('status.noRun'))]);
|
|
52
54
|
panels.push(el('div', { class: 'grid-2' }, releaseCard, processCard, lockCard, lastRunCard));
|
|
53
55
|
return panels;
|
|
54
56
|
}
|
|
55
57
|
function lastRun(app, run) {
|
|
56
|
-
return card('
|
|
57
|
-
el('p', { class: 'lead' }, run.complete ? pill(run.exitCode === 0 ? 'ok' : 'err',
|
|
58
|
-
kv([['
|
|
59
|
-
], { actions: [button('
|
|
58
|
+
return card(t('status.lastRun'), [
|
|
59
|
+
el('p', { class: 'lead' }, run.complete ? pill(run.exitCode === 0 ? 'ok' : 'err', t('status.exit', { code: run.exitCode })) : pill('warn', t('status.noDone')), el('span', { class: 'mono' }, run.runId)),
|
|
60
|
+
kv([[t('status.command'), run.command || t('status.unknownCommand')], run.endedAt ? [t('status.ended'), el('span', { class: 'num' }, when(run.endedAt))] : null]),
|
|
61
|
+
], { actions: [button(t('status.showLog'), () => { app.watch(run.runId, `${run.command} ${run.runId}`, true); }, { class: 'sm' })] });
|
|
60
62
|
}
|