cornfield 0.27.0 → 0.28.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/config.js +5 -0
- package/core/strings.js +117 -0
- package/explorer/forge-panel.js +11 -10
- package/explorer/index.html +33 -33
- package/explorer/main.js +1 -1
- package/explorer/panels.js +3 -2
- package/explorer/plugins.js +6 -2
- package/explorer/proposal.js +2 -1
- package/explorer/review.js +11 -5
- package/explorer/runs-view.js +6 -5
- package/explorer/strings.js +68 -0
- package/explorer/view.js +2 -1
- package/package.json +1 -1
- package/server/server.js +4 -1
package/core/config.js
CHANGED
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
* links: [], // [{ label, href }] shown in the explorer's header
|
|
29
29
|
* theme: {}, // { css, fonts, fontHosts, names, default, icons, pixelated, contrast }: a repo's own look, CSS only (docs/config.md#theme)
|
|
30
30
|
* brand: {}, // { logo, wordmark, favicon, appName, color, background }: a repo's own logo and name, images from the repo (docs/config.md#brand)
|
|
31
|
+
* strings: {}, // { approve: 'Ship it', … }: a repo's own words for the visible labels, plain text (core/strings.js, docs/theming.md#words)
|
|
31
32
|
* proxy: {}, // { '/api/': 'http://127.0.0.1:3245' }: same-origin paths for a live source
|
|
32
33
|
* importMap: {}, // bare imports a repo-local browser module needs: { name: '/repo/path.js' }
|
|
33
34
|
* dataDir: null, // where cornfield keeps its own state (reviews; the SQLite file in v1)
|
|
@@ -44,6 +45,7 @@ import path from 'node:path';
|
|
|
44
45
|
import { pathToFileURL, fileURLToPath } from 'node:url';
|
|
45
46
|
import { themeProblems } from './theme.js';
|
|
46
47
|
import { brandProblems } from './brand.js';
|
|
48
|
+
import { stringsProblems } from './strings.js';
|
|
47
49
|
import { PROFILE_SOURCE, MAX_NUMBER, MAX_BRIEF_CHARS, RUN_KINDS, TRIGGER_EVENTS, CREDENTIAL_VALUE_SOURCE } from './agent-contract.js';
|
|
48
50
|
|
|
49
51
|
export { TRIGGER_EVENTS };
|
|
@@ -170,6 +172,7 @@ export const DEFAULTS = Object.freeze({
|
|
|
170
172
|
links: [],
|
|
171
173
|
theme: { css: null, fonts: [], fontHosts: [], names: {}, default: null, icons: {}, pixelated: false, contrast: 'error' },
|
|
172
174
|
brand: { logo: null, wordmark: null, favicon: null, appName: null, color: null, background: null },
|
|
175
|
+
strings: {},
|
|
173
176
|
proxy: {},
|
|
174
177
|
importMap: {},
|
|
175
178
|
dataDir: null,
|
|
@@ -344,6 +347,7 @@ export function configProblems(c) {
|
|
|
344
347
|
}
|
|
345
348
|
out.push(...themeProblems(c.theme));
|
|
346
349
|
out.push(...brandProblems(c.brand));
|
|
350
|
+
out.push(...stringsProblems(c.strings));
|
|
347
351
|
if (c.proxy !== undefined) {
|
|
348
352
|
if (!isObject(c.proxy)) out.push('"proxy" is { "/path/": "http://upstream" }.');
|
|
349
353
|
else for (const [p, t] of Object.entries(c.proxy)) {
|
|
@@ -532,6 +536,7 @@ export async function loadConfig(root, { env = process.env, file } = {}) {
|
|
|
532
536
|
};
|
|
533
537
|
config.theme = { ...structuredClone(DEFAULTS.theme), ...(raw.theme || {}) };
|
|
534
538
|
config.brand = { ...DEFAULTS.brand, ...(raw.brand || {}) };
|
|
539
|
+
config.strings = { ...(raw.strings || {}) };
|
|
535
540
|
// `threads: false` stays false; an object is read over the default
|
|
536
541
|
config.threads = raw.threads === false ? false : { ...DEFAULTS.threads, ...(raw.threads || {}) };
|
|
537
542
|
// `hookPoll: false` is `{ specs: false }`; an object is read over the default
|
package/core/strings.js
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/strings
|
|
3
|
+
*
|
|
4
|
+
* The words a repo may say in its own voice (`strings` in cornfield.config.js, docs/theming.md "Words"). ONE table, `STRINGS`,
|
|
5
|
+
* holds every overridable label and its default. The config check (core/config.js, so `cornfield validate`), the browser
|
|
6
|
+
* (explorer/strings.js; this file is served to it, server/server.js BROWSER_CORE) and the docs table (`stringsTable`, kept in step by
|
|
7
|
+
* a test) all read it, so the three cannot drift.
|
|
8
|
+
*
|
|
9
|
+
* A value is plain text: it reaches the page through textContent and attributes only, never as HTML, so `<b>` is shown as the
|
|
10
|
+
* characters it is. One line, at most MAX_STRING_LENGTH characters. A missing key means the default; an unknown key is refused.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/** Overridable label by key: the default words. Keys are camelCase; add one here and the docs test says what else to update. */
|
|
14
|
+
export const STRINGS = Object.freeze({
|
|
15
|
+
// The header
|
|
16
|
+
layers: 'Layers',
|
|
17
|
+
dataFlow: 'Data flow',
|
|
18
|
+
house: 'House',
|
|
19
|
+
proposals: 'Proposals',
|
|
20
|
+
issuesAndPrs: 'Issues & PRs',
|
|
21
|
+
searchPlaceholder: 'Search...',
|
|
22
|
+
signOut: 'Sign out',
|
|
23
|
+
poweredBy: 'powered by cornfield',
|
|
24
|
+
// The proposal bar and the review
|
|
25
|
+
before: 'Before',
|
|
26
|
+
diff: 'Diff',
|
|
27
|
+
after: 'After',
|
|
28
|
+
closeProposal: 'Close',
|
|
29
|
+
approve: 'Approve',
|
|
30
|
+
sendBack: 'Send back',
|
|
31
|
+
reviewNoteLabel: 'Note for the drafting agent',
|
|
32
|
+
reviewNotePlaceholder: 'What should change? Needed to send it back, optional to approve.',
|
|
33
|
+
// The issues and pull requests panel
|
|
34
|
+
tabPulls: 'Pull requests',
|
|
35
|
+
tabIssues: 'Issues',
|
|
36
|
+
tabThreads: 'Threads',
|
|
37
|
+
tabDeploys: 'Deploys',
|
|
38
|
+
tabAgents: 'Agents',
|
|
39
|
+
tabNotes: 'Release notes',
|
|
40
|
+
newIdea: 'New idea',
|
|
41
|
+
landIt: 'Land it',
|
|
42
|
+
// Agent runs
|
|
43
|
+
startAgent: 'Start an agent',
|
|
44
|
+
askRunner: 'Ask the runner',
|
|
45
|
+
startAgain: 'Start again',
|
|
46
|
+
stop: 'Stop',
|
|
47
|
+
continueRun: 'Continue',
|
|
48
|
+
reply: 'Reply',
|
|
49
|
+
// The node panel
|
|
50
|
+
propsTitle: 'Properties & Attributes',
|
|
51
|
+
detailsTitle: 'Details',
|
|
52
|
+
openRoute: 'Open Live Route',
|
|
53
|
+
copySpec: 'Copy Spec',
|
|
54
|
+
// The hint, loading and errors
|
|
55
|
+
hintInspect: 'Tap node to inspect live spec',
|
|
56
|
+
hintDrag: 'Drag nodes to move • Double-tap to inspect',
|
|
57
|
+
hintDataFlow: 'Data flow: browser → servers → API → tables → services → outside',
|
|
58
|
+
loading: 'Loading topology.json …',
|
|
59
|
+
errorTitle: 'The map could not be loaded',
|
|
60
|
+
retry: 'Retry',
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
/** The longest a value may be, in characters */
|
|
64
|
+
export const MAX_STRING_LENGTH = 80;
|
|
65
|
+
|
|
66
|
+
const isObject = (v) => v !== null && typeof v === 'object' && !Array.isArray(v);
|
|
67
|
+
/** Whether `key` is one of the table's (an own key: `__proto__` and `toString` are not) */
|
|
68
|
+
export const isStringKey = (key) => typeof key === 'string' && Object.hasOwn(STRINGS, key);
|
|
69
|
+
/** A line break or any other control character */
|
|
70
|
+
const CONTROL = new RegExp('[\\u0000-\\u001f\\u007f-\\u009f\\u2028\\u2029]');
|
|
71
|
+
/**
|
|
72
|
+
* What is wrong with one value, or null.
|
|
73
|
+
* @param {unknown} v
|
|
74
|
+
* @returns {string|null}
|
|
75
|
+
*/
|
|
76
|
+
export function stringProblem(v) {
|
|
77
|
+
if (typeof v !== 'string') return 'is text';
|
|
78
|
+
if (!v.trim()) return 'is empty (leave the key out to keep the default)';
|
|
79
|
+
if (CONTROL.test(v)) return 'is one line of plain text (no line break or control character)';
|
|
80
|
+
if ([...v].length > MAX_STRING_LENGTH) return `is at most ${MAX_STRING_LENGTH} characters`;
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* What is wrong with a `strings` value (as the config file wrote it). HTML is not a problem: it is shown as text.
|
|
86
|
+
* @param {unknown} s
|
|
87
|
+
* @returns {string[]}
|
|
88
|
+
*/
|
|
89
|
+
export function stringsProblems(s) {
|
|
90
|
+
if (s === undefined) return [];
|
|
91
|
+
if (!isObject(s)) return ['"strings" is an object of labels: { approve: \'Ship it\' }.'];
|
|
92
|
+
const out = [];
|
|
93
|
+
for (const [key, value] of Object.entries(s)) {
|
|
94
|
+
if (!isStringKey(key)) { out.push(`strings: unknown key "${key}". Known: ${Object.keys(STRINGS).join(', ')}.`); continue; }
|
|
95
|
+
const problem = stringProblem(value);
|
|
96
|
+
if (problem) out.push(`strings.${key} ${problem}.`);
|
|
97
|
+
}
|
|
98
|
+
return out;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* The overrides the browser is sent: known keys with a good value, nothing else (the defaults live in the browser already).
|
|
103
|
+
* @param {unknown} s
|
|
104
|
+
* @returns {Record<string, string>}
|
|
105
|
+
*/
|
|
106
|
+
export function clientStrings(s) {
|
|
107
|
+
const out = {};
|
|
108
|
+
if (!isObject(s)) return out;
|
|
109
|
+
for (const [key, value] of Object.entries(s)) if (isStringKey(key) && !stringProblem(value)) out[key] = value;
|
|
110
|
+
return out;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** The docs' key table (docs/theming.md "Words"), generated from STRINGS; a test fails when the docs hold anything else */
|
|
114
|
+
export function stringsTable() {
|
|
115
|
+
const cell = (v) => v.replace(/\|/g, '\\|');
|
|
116
|
+
return ['| Key | Default |', '|---|---|', ...Object.entries(STRINGS).map(([k, v]) => `| \`${k}\` | ${cell(v)} |`)].join('\n');
|
|
117
|
+
}
|
package/explorer/forge-panel.js
CHANGED
|
@@ -82,6 +82,7 @@ import {
|
|
|
82
82
|
threadsUrl, threadUrl, issueUrl, IDEAS_URL, threadKindWords, threadMeta, litForThread, mentionsIndex, ideaRequest, ideaWords,
|
|
83
83
|
} from './forge-panel-model.js';
|
|
84
84
|
import { cornStateAttr } from './corn-state.js';
|
|
85
|
+
import { t } from './strings.js';
|
|
85
86
|
|
|
86
87
|
const $ = (id) => document.getElementById(id);
|
|
87
88
|
const FORGE_NAMES = { github: 'GitHub', forgejo: 'Forgejo' };
|
|
@@ -883,7 +884,7 @@ function itemHtml(item, before = '', after = '') {
|
|
|
883
884
|
? `<button type="button" class="hx-btn hx-forge-act hx-forge-startspec" data-forge-spec="${item.number}" aria-label="Start a spec for issue ${item.number}"${ui.busy ? ' disabled' : ''}>Start a spec …</button>`
|
|
884
885
|
: '';
|
|
885
886
|
const agent = item.state === 'open'
|
|
886
|
-
? `<button type="button" class="hx-btn hx-forge-act hx-forge-startspec" data-forge-agent="issue:${item.number}" aria-label="
|
|
887
|
+
? `<button type="button" class="hx-btn hx-forge-act hx-forge-startspec" data-forge-agent="issue:${item.number}" aria-label="${escHtml(t('startAgent'))} on issue ${item.number}">${escHtml(t('startAgent'))} …</button>`
|
|
887
888
|
: '';
|
|
888
889
|
return link
|
|
889
890
|
? `<li class="hx-forge-item"><a class="hx-forge-row" href="${escHtml(link)}" target="_blank" rel="noreferrer" data-corn="row">${inner}<span class="hx-sr-only"> (opens ${escHtml(forgeName())} in a new tab)</span></a>${spec}${agent}</li>`
|
|
@@ -906,7 +907,7 @@ function groupsHtml(groups) {
|
|
|
906
907
|
return groups.map((g, i) => {
|
|
907
908
|
const link = g.issue && safeUrl(g.issue.url) ? ` <a class="hx-link hx-forge-gout" href="${escHtml(g.issue.url)}" target="_blank" rel="noreferrer" aria-label="Open issue ${g.number} on ${escHtml(forgeName())} (new tab)">↗</a>` : '';
|
|
908
909
|
const startRef = g.kind === 'issue' && g.issue && g.issue.state === 'open' ? `issue:${g.number}` : g.kind === 'proposal' ? `proposal:${g.slug}` : null;
|
|
909
|
-
const start = startRef ? ` <button type="button" class="hx-btn hx-forge-act" data-forge-agent="${escHtml(startRef)}" aria-label="
|
|
910
|
+
const start = startRef ? ` <button type="button" class="hx-btn hx-forge-act" data-forge-agent="${escHtml(startRef)}" aria-label="${escHtml(t('startAgent'))} on ${escHtml(g.kind === 'issue' ? `issue ${g.number}` : `proposal ${g.slug}`)}">${escHtml(t('startAgent'))} …</button>` : '';
|
|
910
911
|
return `<li class="hx-forge-group"><h3 class="hx-forge-gtitle" id="forge-group-${i}">${escHtml(g.title)}${link}</h3>${start}<p class="hx-forge-meta">${escHtml(groupWords(g))}</p><ul class="hx-forge-list" aria-labelledby="forge-group-${i}">${g.entries.map(workHtml).join('')}</ul></li>`;
|
|
911
912
|
}).join('');
|
|
912
913
|
}
|
|
@@ -1012,7 +1013,7 @@ function detailHtml() {
|
|
|
1012
1013
|
const block = mergeBlock(ui.detail);
|
|
1013
1014
|
const act = block
|
|
1014
1015
|
? `<p class="hx-forge-why hx-faint">${pull.state === 'merged' ? '' : 'Cannot be landed from here. '}${escHtml(block)}</p>`
|
|
1015
|
-
: `<button type="button" class="hx-btn hx-btn--approve hx-forge-act" data-forge-merge="${pull.number}"${ui.busy ? ' disabled' : ''} data-corn-kind="approve"
|
|
1016
|
+
: `<button type="button" class="hx-btn hx-btn--approve hx-forge-act" data-forge-merge="${pull.number}"${ui.busy ? ' disabled' : ''} data-corn-kind="approve">${escHtml(t('landIt'))} …</button><p class="hx-forge-why hx-faint">Opens a confirm step that shows what will land. Never forced, never deployed.</p>`;
|
|
1016
1017
|
// A spec approved with `proposals.approveLands` waits for its checks: said here, with a way to stop it
|
|
1017
1018
|
const waiting = ui.landing && pull.state === 'open'
|
|
1018
1019
|
? `<div class="hx-forge-step"><p class="hx-forge-notice hx-forge-notice--ok" role="status" data-corn="notice" data-corn-state="success">${escHtml(landingWords(ui.landing, now()))}</p><button type="button" class="hx-btn hx-forge-act" data-forge-landing-cancel="${pull.number}"${ui.busy ? ' disabled' : ''}>Cancel</button></div>`
|
|
@@ -1034,7 +1035,7 @@ function detailHtml() {
|
|
|
1034
1035
|
<h4 class="hx-forge-sub">Checks: ${escHtml(checksWords(checks))}</h4>
|
|
1035
1036
|
${checks.length ? `<ul class="hx-forge-checks">${checkRows}</ul>` : ''}
|
|
1036
1037
|
${build}
|
|
1037
|
-
<h4 class="hx-forge-subact"
|
|
1038
|
+
<h4 class="hx-forge-subact">${escHtml(t('landIt'))}</h4>
|
|
1038
1039
|
${note}
|
|
1039
1040
|
${waiting}
|
|
1040
1041
|
${act}
|
|
@@ -1322,7 +1323,7 @@ function showConfirm(what, goLabel, state) {
|
|
|
1322
1323
|
/** Opens the confirm step for landing the selected pull request: what will land, exactly */
|
|
1323
1324
|
function openConfirm(opener) {
|
|
1324
1325
|
if (!confirmEl() || ui.confirm || ui.busy || !ui.detail || mergeBlock(ui.detail)) return;
|
|
1325
|
-
showConfirm(confirmMerge(ui.detail, forgeName(), ui.config && ui.config.forge && ui.config.forge.mergeMethod), '
|
|
1326
|
+
showConfirm(confirmMerge(ui.detail, forgeName(), ui.config && ui.config.forge && ui.config.forge.mergeMethod), t('landIt'), { opener, kind: 'merge' });
|
|
1326
1327
|
}
|
|
1327
1328
|
|
|
1328
1329
|
/** What a pipeline step came to, on the panel (with a link to what it made) and through the live region */
|
|
@@ -1483,7 +1484,7 @@ async function openAgent(ref, opener, again = null, brief = null) {
|
|
|
1483
1484
|
$('agent-profile').innerHTML = option('', 'No profile', !(again && again.profile)) + shown.map((p) => option(p, p, !!again && p === again.profile)).join('');
|
|
1484
1485
|
$('agent-profile-field').hidden = !shown.length;
|
|
1485
1486
|
$('agent-profile').value = again && again.profile ? again.profile : ''; // as well as `selected`, which not every DOM honours
|
|
1486
|
-
$('agent-start-title').textContent = again ? '
|
|
1487
|
+
$('agent-start-title').textContent = again ? t('startAgain') : t('startAgent');
|
|
1487
1488
|
const note = $('agent-retry-note');
|
|
1488
1489
|
note.hidden = !again;
|
|
1489
1490
|
note.textContent = again ? retryWords(again) : '';
|
|
@@ -1497,11 +1498,11 @@ async function openAgent(ref, opener, again = null, brief = null) {
|
|
|
1497
1498
|
const go = $('agent-start-go');
|
|
1498
1499
|
go.disabled = false;
|
|
1499
1500
|
go.removeAttribute('aria-busy');
|
|
1500
|
-
go.textContent = '
|
|
1501
|
+
go.textContent = t('askRunner');
|
|
1501
1502
|
document.addEventListener('focusin', keepFocusInAgent);
|
|
1502
1503
|
agentEl().hidden = false;
|
|
1503
1504
|
$('agent-kind').focus();
|
|
1504
|
-
announce(`${again ? '
|
|
1505
|
+
announce(`${again ? t('startAgain') : t('startAgent')} on ${aboutWords(refs)}. ${confirmStartWords(refs, forgeName())}`);
|
|
1505
1506
|
}
|
|
1506
1507
|
|
|
1507
1508
|
/** "Start again" on a run that failed or was stopped. A brief the list shows cut is read whole first: the dialog never starts from part of one */
|
|
@@ -1587,7 +1588,7 @@ async function submitAgent(e) {
|
|
|
1587
1588
|
ui.agent.posting = false;
|
|
1588
1589
|
go.disabled = false;
|
|
1589
1590
|
go.removeAttribute('aria-busy');
|
|
1590
|
-
go.textContent = '
|
|
1591
|
+
go.textContent = t('askRunner');
|
|
1591
1592
|
const bad = $('agent-start-msg');
|
|
1592
1593
|
bad.textContent = `A limit is a number above zero, or blank for the config's (${wrong.join(', ')}).`;
|
|
1593
1594
|
bad.hidden = false;
|
|
@@ -1612,7 +1613,7 @@ async function submitAgent(e) {
|
|
|
1612
1613
|
}
|
|
1613
1614
|
go.disabled = false;
|
|
1614
1615
|
go.removeAttribute('aria-busy');
|
|
1615
|
-
go.textContent = '
|
|
1616
|
+
go.textContent = t('askRunner');
|
|
1616
1617
|
const msg = $('agent-start-msg');
|
|
1617
1618
|
msg.textContent = text;
|
|
1618
1619
|
msg.hidden = false;
|
package/explorer/index.html
CHANGED
|
@@ -32,11 +32,11 @@
|
|
|
32
32
|
</button>
|
|
33
33
|
|
|
34
34
|
<div class="hx-menu-wrap">
|
|
35
|
-
<button type="button" id="legend-toggle-btn" class="hx-btn" data-action="toggle-layers-menu" aria-label="Layers" aria-expanded="false" aria-controls="legend-dropdown" title="Toggle Architecture Layers" data-corn="layers-button">
|
|
35
|
+
<button type="button" id="legend-toggle-btn" class="hx-btn" data-action="toggle-layers-menu" aria-label="Layers" data-corn-string-aria-label="layers" aria-expanded="false" aria-controls="legend-dropdown" title="Toggle Architecture Layers" data-corn="layers-button">
|
|
36
36
|
<span class="hx-dots" aria-hidden="true">
|
|
37
37
|
<span style="background:#6366f1"></span><span style="background:#06b6d4"></span><span style="background:#38bdf8"></span><span style="background:#10b981"></span><span style="background:#a855f7"></span><span style="background:#ec4899"></span><span style="background:#fb923c"></span>
|
|
38
38
|
</span>
|
|
39
|
-
<span class="hx-only-wide">Layers</span>
|
|
39
|
+
<span class="hx-only-wide" data-corn-string="layers">Layers</span>
|
|
40
40
|
<span class="hx-faint" aria-hidden="true">▾</span>
|
|
41
41
|
</button>
|
|
42
42
|
|
|
@@ -89,31 +89,31 @@
|
|
|
89
89
|
</div>
|
|
90
90
|
|
|
91
91
|
<!-- The data-flow preset: browser -> servers -> API -> tables -> services -> outside, animated -->
|
|
92
|
-
<button type="button" id="preset-dataflow-btn" class="hx-btn hx-btn--preset" data-action="preset-dataflow" aria-pressed="false" aria-label="Data flow" title="Show only how data moves: browser, app servers, API, tables, services, outside systems" data-corn="preset-dataflow">
|
|
92
|
+
<button type="button" id="preset-dataflow-btn" class="hx-btn hx-btn--preset" data-action="preset-dataflow" aria-pressed="false" aria-label="Data flow" data-corn-string-aria-label="dataFlow" title="Show only how data moves: browser, app servers, API, tables, services, outside systems" data-corn="preset-dataflow">
|
|
93
93
|
<span aria-hidden="true">⇄</span>
|
|
94
|
-
<span class="hx-only-wide">Data flow</span>
|
|
94
|
+
<span class="hx-only-wide" data-corn-string="dataFlow">Data flow</span>
|
|
95
95
|
</button>
|
|
96
96
|
|
|
97
97
|
<!-- The House preset (explorer/house.js, spec 0029): the floor plan with its devices, machines and people, the software around it -->
|
|
98
|
-
<button type="button" id="preset-house-btn" class="hx-btn hx-btn--preset" data-action="preset-house" aria-pressed="false" aria-label="House" title="Show the house: each floor's rooms with their devices and machines, the people beside it, the software around it" data-corn="preset-house">
|
|
98
|
+
<button type="button" id="preset-house-btn" class="hx-btn hx-btn--preset" data-action="preset-house" aria-pressed="false" aria-label="House" data-corn-string-aria-label="house" title="Show the house: each floor's rooms with their devices and machines, the people beside it, the software around it" data-corn="preset-house">
|
|
99
99
|
<span aria-hidden="true">⌂</span>
|
|
100
|
-
<span class="hx-only-wide">House</span>
|
|
100
|
+
<span class="hx-only-wide" data-corn-string="house">House</span>
|
|
101
101
|
</button>
|
|
102
102
|
|
|
103
103
|
<!-- Proposals: what a change would add, change and remove, drawn on the map (proposal.js) -->
|
|
104
104
|
<div id="proposal-wrap" class="hx-menu-wrap">
|
|
105
|
-
<button type="button" id="proposal-btn" class="hx-btn hx-btn--proposal" data-action="toggle-proposals-menu" aria-haspopup="true" aria-expanded="false" aria-label="Proposals" title="Open a proposal: what a change would add, change and remove" data-corn="proposals-button">
|
|
105
|
+
<button type="button" id="proposal-btn" class="hx-btn hx-btn--proposal" data-action="toggle-proposals-menu" aria-haspopup="true" aria-expanded="false" aria-label="Proposals" data-corn-string-aria-label="proposals" title="Open a proposal: what a change would add, change and remove" data-corn="proposals-button">
|
|
106
106
|
<span aria-hidden="true">✎</span>
|
|
107
|
-
<span class="hx-only-wide">Proposals</span>
|
|
107
|
+
<span class="hx-only-wide" data-corn-string="proposals">Proposals</span>
|
|
108
108
|
<span class="hx-faint">▾</span>
|
|
109
109
|
</button>
|
|
110
110
|
<div id="proposal-menu" class="hx-menu hx-menu--proposals glass" hidden data-corn="proposals-menu"></div>
|
|
111
111
|
</div>
|
|
112
112
|
|
|
113
113
|
<!-- Issues and pull requests (explorer/forge-panel.js): shown only when the config names a forge -->
|
|
114
|
-
<button type="button" id="forge-btn" class="hx-btn hx-btn--forge" data-action="toggle-forge" aria-expanded="false" aria-controls="forge-panel" aria-label="Issues and pull requests" title="Issues, pull requests and deploys: a pull request lights the nodes it changes, a deploy the nodes it restarted" hidden data-corn="forge-button">
|
|
114
|
+
<button type="button" id="forge-btn" class="hx-btn hx-btn--forge" data-action="toggle-forge" aria-expanded="false" aria-controls="forge-panel" aria-label="Issues and pull requests" data-corn-string-aria-label="issuesAndPrs" title="Issues, pull requests and deploys: a pull request lights the nodes it changes, a deploy the nodes it restarted" hidden data-corn="forge-button">
|
|
115
115
|
<span aria-hidden="true">⎇</span>
|
|
116
|
-
<span class="hx-only-wide">Issues & PRs</span>
|
|
116
|
+
<span class="hx-only-wide" data-corn-string="issuesAndPrs">Issues & PRs</span>
|
|
117
117
|
<span id="forge-btn-lit" class="hx-forge-lit" hidden></span>
|
|
118
118
|
</button>
|
|
119
119
|
|
|
@@ -137,7 +137,7 @@
|
|
|
137
137
|
<button type="button" id="mobile-search-toggle" class="hx-btn hx-btn--icon hx-only-mobile" data-action="toggle-mobile-search" aria-label="Open Search" title="Search nodes" data-corn-kind="icon">⌕</button>
|
|
138
138
|
|
|
139
139
|
<div class="hx-search hx-only-desktop" role="search" data-corn="search">
|
|
140
|
-
<input type="text" id="node-search" class="hx-input" placeholder="Search..." aria-label="Search nodes" data-corn="search-input" />
|
|
140
|
+
<input type="text" id="node-search" class="hx-input" placeholder="Search..." data-corn-string-placeholder="searchPlaceholder" aria-label="Search nodes" data-corn="search-input" />
|
|
141
141
|
</div>
|
|
142
142
|
|
|
143
143
|
<button type="button" id="freeform-toggle-btn" class="hx-btn" data-action="toggle-freeform" title="Toggle between Orbit parent clustering and freeform node dragging" data-corn="layout-toggle">
|
|
@@ -201,11 +201,11 @@
|
|
|
201
201
|
<strong id="proposal-title" class="hx-proposal-name"></strong>
|
|
202
202
|
<button type="button" id="proposal-chip" class="hx-proposal-chip" data-action="toggle-proposal-changes" aria-expanded="false"></button>
|
|
203
203
|
<div class="hx-seg" role="group" aria-label="Compare">
|
|
204
|
-
<button type="button" class="hx-seg-btn" data-action="proposal-view" data-view="before" aria-pressed="false">Before</button>
|
|
205
|
-
<button type="button" class="hx-seg-btn" data-action="proposal-view" data-view="diff" aria-pressed="true">Diff</button>
|
|
206
|
-
<button type="button" class="hx-seg-btn" data-action="proposal-view" data-view="after" aria-pressed="false">After</button>
|
|
204
|
+
<button type="button" class="hx-seg-btn" data-action="proposal-view" data-view="before" aria-pressed="false" data-corn-string="before">Before</button>
|
|
205
|
+
<button type="button" class="hx-seg-btn" data-action="proposal-view" data-view="diff" aria-pressed="true" data-corn-string="diff">Diff</button>
|
|
206
|
+
<button type="button" class="hx-seg-btn" data-action="proposal-view" data-view="after" aria-pressed="false" data-corn-string="after">After</button>
|
|
207
207
|
</div>
|
|
208
|
-
<button type="button" class="hx-btn hx-btn--quiet" data-action="close-proposal" title="Close the proposal and go back to the map" data-corn-kind="quiet">Close</button>
|
|
208
|
+
<button type="button" class="hx-btn hx-btn--quiet" data-action="close-proposal" title="Close the proposal and go back to the map" data-corn-kind="quiet" data-corn-string="closeProposal">Close</button>
|
|
209
209
|
</div>
|
|
210
210
|
<p id="proposal-summary" class="hx-proposal-summary" hidden></p>
|
|
211
211
|
<details id="proposal-errors" class="hx-proposal-errors" hidden>
|
|
@@ -228,12 +228,12 @@
|
|
|
228
228
|
<p id="forge-status" class="hx-forge-status hx-faint"></p>
|
|
229
229
|
<div class="hx-forge-controls">
|
|
230
230
|
<div class="hx-forge-tabs" role="group" aria-label="Show" data-corn="tabs">
|
|
231
|
-
<button type="button" class="hx-forge-tab" data-forge-kind="pulls" aria-pressed="true" data-corn="tab">Pull requests</button>
|
|
232
|
-
<button type="button" class="hx-forge-tab" data-forge-kind="issues" aria-pressed="false" data-corn="tab">Issues</button>
|
|
233
|
-
<button type="button" class="hx-forge-tab" data-forge-kind="threads" aria-pressed="false" title="Ideas and spec conversations, with the nodes they mention" data-corn="tab">Threads</button>
|
|
234
|
-
<button type="button" class="hx-forge-tab" data-forge-kind="deploys" aria-pressed="false" data-corn="tab">Deploys</button>
|
|
235
|
-
<button type="button" class="hx-forge-tab" data-forge-kind="work" aria-pressed="false" title="Work grouped by issue and proposal, agent-made work marked" data-corn="tab">Agents</button>
|
|
236
|
-
<button type="button" class="hx-forge-tab" data-forge-kind="notes" aria-pressed="false" data-corn="tab">Release notes</button>
|
|
231
|
+
<button type="button" class="hx-forge-tab" data-forge-kind="pulls" aria-pressed="true" data-corn="tab" data-corn-string="tabPulls">Pull requests</button>
|
|
232
|
+
<button type="button" class="hx-forge-tab" data-forge-kind="issues" aria-pressed="false" data-corn="tab" data-corn-string="tabIssues">Issues</button>
|
|
233
|
+
<button type="button" class="hx-forge-tab" data-forge-kind="threads" aria-pressed="false" title="Ideas and spec conversations, with the nodes they mention" data-corn="tab" data-corn-string="tabThreads">Threads</button>
|
|
234
|
+
<button type="button" class="hx-forge-tab" data-forge-kind="deploys" aria-pressed="false" data-corn="tab" data-corn-string="tabDeploys">Deploys</button>
|
|
235
|
+
<button type="button" class="hx-forge-tab" data-forge-kind="work" aria-pressed="false" title="Work grouped by issue and proposal, agent-made work marked" data-corn="tab" data-corn-string="tabAgents">Agents</button>
|
|
236
|
+
<button type="button" class="hx-forge-tab" data-forge-kind="notes" aria-pressed="false" data-corn="tab" data-corn-string="tabNotes">Release notes</button>
|
|
237
237
|
</div>
|
|
238
238
|
<div id="forge-work-filters" class="hx-forge-work-filters" hidden>
|
|
239
239
|
<label class="hx-forge-toggle"><input type="checkbox" id="forge-work-agents" /> Agent-made only</label>
|
|
@@ -249,13 +249,13 @@
|
|
|
249
249
|
<p id="forge-notice" class="hx-forge-notice" hidden data-corn="notice"></p>
|
|
250
250
|
<p id="forge-act-note" class="hx-forge-notice" hidden data-corn="notice"></p>
|
|
251
251
|
<!-- New idea (forge-panel.js): opens an issue with the threads label as you, on the forge; the thread itself lives there -->
|
|
252
|
-
<section id="forge-idea" class="hx-forge-notes" aria-label="New idea" hidden>
|
|
252
|
+
<section id="forge-idea" class="hx-forge-notes" aria-label="New idea" data-corn-string-aria-label="newIdea" hidden>
|
|
253
253
|
<div class="hx-forge-actions">
|
|
254
|
-
<button type="button" id="idea-open" class="hx-btn hx-btn--approve" data-action="idea-open" aria-expanded="false" aria-controls="idea-form" data-corn-kind="approve">New idea …</button>
|
|
254
|
+
<button type="button" id="idea-open" class="hx-btn hx-btn--approve" data-action="idea-open" aria-expanded="false" aria-controls="idea-form" data-corn-kind="approve"><span data-corn-string="newIdea">New idea</span> …</button>
|
|
255
255
|
</div>
|
|
256
256
|
<p id="idea-message" class="hx-forge-msg" role="status" hidden data-corn="message"></p>
|
|
257
257
|
<div id="idea-form" class="hx-forge-confirm" role="group" aria-labelledby="idea-form-title" hidden>
|
|
258
|
-
<h3 id="idea-form-title" class="hx-forge-confirm-title">New idea</h3>
|
|
258
|
+
<h3 id="idea-form-title" class="hx-forge-confirm-title" data-corn-string="newIdea">New idea</h3>
|
|
259
259
|
<p id="idea-words"></p>
|
|
260
260
|
<label class="hx-forge-field" data-corn="field">Title<input type="text" id="idea-title" class="hx-forge-input" maxlength="256" autocomplete="off" /></label>
|
|
261
261
|
<label class="hx-forge-field" data-corn="field">What is the idea?<textarea id="idea-body" class="hx-forge-preview hx-thread-compose" rows="6" maxlength="20000" spellcheck="true"></textarea></label>
|
|
@@ -315,19 +315,19 @@
|
|
|
315
315
|
<p id="drawer-description" class="hx-faint hx-lead"></p>
|
|
316
316
|
|
|
317
317
|
<div class="hx-block">
|
|
318
|
-
<h3 class="hx-block-title">Properties & Attributes</h3>
|
|
318
|
+
<h3 class="hx-block-title" data-corn-string="propsTitle">Properties & Attributes</h3>
|
|
319
319
|
<div id="drawer-props-list" class="hx-props"></div>
|
|
320
320
|
</div>
|
|
321
321
|
|
|
322
322
|
<div class="hx-block">
|
|
323
|
-
<h3 class="hx-block-title">Details</h3>
|
|
323
|
+
<h3 class="hx-block-title" data-corn-string="detailsTitle">Details</h3>
|
|
324
324
|
<div id="drawer-meta-list" class="hx-meta"></div>
|
|
325
325
|
</div>
|
|
326
326
|
</div>
|
|
327
327
|
|
|
328
328
|
<div class="hx-drawer-foot">
|
|
329
329
|
<a id="drawer-open-btn" class="hx-open" href="#" target="_blank" rel="noreferrer">Open ↗</a>
|
|
330
|
-
<button type="button" class="hx-btn hx-btn--copy" data-action="copy-spec">Copy Spec</button>
|
|
330
|
+
<button type="button" class="hx-btn hx-btn--copy" data-action="copy-spec" data-corn-string="copySpec">Copy Spec</button>
|
|
331
331
|
</div>
|
|
332
332
|
</aside>
|
|
333
333
|
</div>
|
|
@@ -345,12 +345,12 @@
|
|
|
345
345
|
</div>
|
|
346
346
|
|
|
347
347
|
<!-- Loading and error states: a failed load never leaves a blank canvas -->
|
|
348
|
-
<div id="loading-state" class="hx-state" role="status" data-corn="loading">Loading topology.json …</div>
|
|
348
|
+
<div id="loading-state" class="hx-state" role="status" data-corn="loading" data-corn-string="loading">Loading topology.json …</div>
|
|
349
349
|
<div id="error-state" class="hx-state hx-state--error glass" role="alert" hidden data-corn="error">
|
|
350
|
-
<strong>The map could not be loaded</strong>
|
|
350
|
+
<strong data-corn-string="errorTitle">The map could not be loaded</strong>
|
|
351
351
|
<p id="error-message"></p>
|
|
352
352
|
<p class="hx-faint">The explorer reads /topology.json from the cornfield server (cornfield serve). Run cornfield sync if the repo has no map yet, check that the server is up, then retry.</p>
|
|
353
|
-
<button type="button" class="hx-btn hx-btn--active" data-action="retry" data-corn-kind="primary">Retry</button>
|
|
353
|
+
<button type="button" class="hx-btn hx-btn--active" data-action="retry" data-corn-kind="primary" data-corn-string="retry">Retry</button>
|
|
354
354
|
</div>
|
|
355
355
|
|
|
356
356
|
<div id="drawer-backdrop" class="hx-backdrop" data-action="close-drawer" hidden data-corn="backdrop"></div>
|
|
@@ -364,7 +364,7 @@
|
|
|
364
364
|
<div id="forge-confirm-body"></div>
|
|
365
365
|
<div class="hx-confirm-actions">
|
|
366
366
|
<button type="button" class="hx-btn" data-action="forge-confirm-cancel">Cancel</button>
|
|
367
|
-
<button type="button" class="hx-btn hx-btn--approve" data-action="forge-confirm-go" data-corn-kind="approve">Land it</button>
|
|
367
|
+
<button type="button" class="hx-btn hx-btn--approve" data-action="forge-confirm-go" data-corn-kind="approve" data-corn-string="landIt">Land it</button>
|
|
368
368
|
</div>
|
|
369
369
|
</div>
|
|
370
370
|
</div>
|
|
@@ -372,7 +372,7 @@
|
|
|
372
372
|
<!-- Start an agent (forge-panel.js): kind, profile, a brief, and a confirm step; a modal dialog over a scrim, the focus stays in it -->
|
|
373
373
|
<div id="agent-start" class="hx-confirm-scrim" hidden data-corn="dialog-scrim">
|
|
374
374
|
<div class="hx-confirm glass" role="dialog" aria-modal="true" aria-labelledby="agent-start-title" aria-describedby="agent-start-words" data-corn="agent-dialog">
|
|
375
|
-
<h2 id="agent-start-title" class="hx-confirm-title">Start an agent</h2>
|
|
375
|
+
<h2 id="agent-start-title" class="hx-confirm-title" data-corn-string="startAgent">Start an agent</h2>
|
|
376
376
|
<p id="agent-start-about" class="hx-forge-meta"></p>
|
|
377
377
|
<p id="agent-start-runner" class="hx-forge-meta" hidden></p>
|
|
378
378
|
<p id="agent-retry-note" class="hx-forge-meta" hidden></p>
|
|
@@ -391,7 +391,7 @@
|
|
|
391
391
|
<p id="agent-start-msg" class="hx-forge-msg hx-forge-msg--bad" role="alert" hidden data-corn="message" data-corn-state="failure"></p>
|
|
392
392
|
<div class="hx-confirm-actions">
|
|
393
393
|
<button type="button" class="hx-btn" data-action="agent-start-cancel">Cancel</button>
|
|
394
|
-
<button type="submit" class="hx-btn hx-btn--approve" id="agent-start-go" data-corn-kind="approve">Ask the runner</button>
|
|
394
|
+
<button type="submit" class="hx-btn hx-btn--approve" id="agent-start-go" data-corn-kind="approve" data-corn-string="askRunner">Ask the runner</button>
|
|
395
395
|
</div>
|
|
396
396
|
</form>
|
|
397
397
|
</div>
|
package/explorer/main.js
CHANGED
|
@@ -207,7 +207,7 @@ $('mobile-node-search').addEventListener('input', (e) => handleSearch(e.target.v
|
|
|
207
207
|
resize();
|
|
208
208
|
syncViewUi();
|
|
209
209
|
// /?proposal=<slug> opens a proposal over the map, /?view=dataflow the data-flow preset: both have a link
|
|
210
|
-
const configReady = loadClientConfig().then((config) => { applyBranding(document, config); applyMapTheme(document, config.theme); return config; }); // the brand, then the theme's icons for the map
|
|
210
|
+
const configReady = loadClientConfig().then((config) => { applyBranding(document, config); applyMapTheme(document, config.theme); syncViewUi(); return config; }); // the brand, then the theme's icons for the map; the hint again, in the repo's words
|
|
211
211
|
loadTopology().then(async (ok) => {
|
|
212
212
|
if (!ok) return;
|
|
213
213
|
// The sources the repo's cornfield.config.js names (plugins.js): a live layer, a house, devices, a checker; each optional
|
package/explorer/panels.js
CHANGED
|
@@ -15,6 +15,7 @@ import { nodeMockupsHtml } from './mockups-model.js';
|
|
|
15
15
|
import { collapseSheet } from './sheets.js';
|
|
16
16
|
import { liveSection, hydrateLivePhotos } from './live.js';
|
|
17
17
|
import { cloudPanelHtml } from './cloud-model.js';
|
|
18
|
+
import { t } from './strings.js';
|
|
18
19
|
|
|
19
20
|
const $ = (id) => document.getElementById(id);
|
|
20
21
|
|
|
@@ -189,7 +190,7 @@ export async function selectNode(node) {
|
|
|
189
190
|
${dataSummary(node)}`;
|
|
190
191
|
if (node.url && /^https?:\/\//.test(node.url)) {
|
|
191
192
|
openBtn.href = node.url;
|
|
192
|
-
openBtn.textContent = '
|
|
193
|
+
openBtn.textContent = `${t('openRoute')} ↗`;
|
|
193
194
|
} else {
|
|
194
195
|
openBtn.removeAttribute('href');
|
|
195
196
|
openBtn.textContent = 'Internal Workspace Node';
|
|
@@ -238,5 +239,5 @@ export async function copySpec(button) {
|
|
|
238
239
|
} catch {
|
|
239
240
|
button.textContent = 'Copy blocked';
|
|
240
241
|
}
|
|
241
|
-
setTimeout(() => { button.textContent = '
|
|
242
|
+
setTimeout(() => { button.textContent = t('copySpec'); }, 1500);
|
|
242
243
|
}
|
package/explorer/plugins.js
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
import { escHtml } from './state.js';
|
|
18
18
|
import { initThemePicker } from './theme-names.js';
|
|
19
|
+
import { setStrings, applyStrings, t } from './strings.js';
|
|
19
20
|
|
|
20
21
|
/** What the live layer shows when the repo names no live source */
|
|
21
22
|
export const NO_SOURCE = Object.freeze({
|
|
@@ -71,12 +72,15 @@ function applyBrand(doc, brand, title) {
|
|
|
71
72
|
/** The small "powered by cornfield" link that stays in the header when a repo brands cornfield */
|
|
72
73
|
function poweredBy(brand) {
|
|
73
74
|
if (!brand || typeof brand.poweredBy !== 'string' || !/^https:\/\//.test(brand.poweredBy)) return '';
|
|
74
|
-
return `<a class="hx-btn hx-btn--quiet" data-corn="powered-by" href="${escHtml(brand.poweredBy)}" target="_blank" rel="noreferrer"
|
|
75
|
+
return `<a class="hx-btn hx-btn--quiet" data-corn="powered-by" href="${escHtml(brand.poweredBy)}" target="_blank" rel="noreferrer">${escHtml(t('poweredBy'))}</a>`;
|
|
75
76
|
}
|
|
76
77
|
|
|
77
78
|
/** Puts the repo's title, brand and links in the header, and Sign out when the server says who is signed in */
|
|
78
79
|
export function applyBranding(doc, config) {
|
|
79
80
|
if (!config || !doc) return;
|
|
81
|
+
// The repo's words (core/strings.js) first: what is built below reads them, and the static markup is filled now
|
|
82
|
+
setStrings(config.strings);
|
|
83
|
+
applyStrings(doc);
|
|
80
84
|
const title = doc.getElementById('cf-title');
|
|
81
85
|
if (title && config.title) title.textContent = config.title;
|
|
82
86
|
const heading = doc.getElementById('cf-heading');
|
|
@@ -92,7 +96,7 @@ export function applyBranding(doc, config) {
|
|
|
92
96
|
// A plain form: signing out is a same-origin POST (server/auth.js), no script needed. On a narrow phone only its icon
|
|
93
97
|
// shows (explorer.css); the words stay in the button for a screen reader
|
|
94
98
|
const signOut = config.signIn && typeof config.signIn.login === 'string'
|
|
95
|
-
? `<form class="cf-sign-out" method="post" action="/auth/sign-out" data-corn="sign-out"><button type="submit" class="hx-btn hx-btn--quiet" title="Signed in as ${escHtml(config.signIn.login)}" data-corn-kind="quiet"><span class="cf-sign-out-icon" aria-hidden="true">⎋</span><span class="cf-sign-out-text"
|
|
99
|
+
? `<form class="cf-sign-out" method="post" action="/auth/sign-out" data-corn="sign-out"><button type="submit" class="hx-btn hx-btn--quiet" title="Signed in as ${escHtml(config.signIn.login)}" data-corn-kind="quiet"><span class="cf-sign-out-icon" aria-hidden="true">⎋</span><span class="cf-sign-out-text">${escHtml(t('signOut'))}</span></button></form>`
|
|
96
100
|
: '';
|
|
97
101
|
const powered = poweredBy(config.brand);
|
|
98
102
|
if (html || powered || signOut) links.innerHTML = html + powered + signOut;
|
package/explorer/proposal.js
CHANGED
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
import { applyProposal, edgeKey, proposalProblems, summarize } from '../core/proposal.js';
|
|
32
32
|
import { reviewWords } from './review-model.js';
|
|
33
33
|
import { collapseSheet } from './sheets.js';
|
|
34
|
+
import { t } from './strings.js';
|
|
34
35
|
|
|
35
36
|
const $ = (id) => document.getElementById(id);
|
|
36
37
|
|
|
@@ -370,7 +371,7 @@ function renderMenu(loading = false) {
|
|
|
370
371
|
else if (!listing || listing.length === 0) body = '<p class="hx-faint hx-proposal-empty">No proposals</p>';
|
|
371
372
|
else body = `<div class="hx-proposal-list" role="list">${listing.map((e) => `<div role="listitem">${proposalRowHtml(e, current)}</div>`).join('')}</div>`;
|
|
372
373
|
const forge = forgeProblem && !listingProblem ? `<p class="hx-error-text hx-proposal-empty">The spec PRs could not be listed: ${escHtml(forgeProblem)}</p>` : '';
|
|
373
|
-
menu.innerHTML = `<div class="hx-menu-title hx-menu-head"><span
|
|
374
|
+
menu.innerHTML = `<div class="hx-menu-title hx-menu-head"><span>${escHtml(t('proposals'))}</span></div>${forge}${body}`;
|
|
374
375
|
}
|
|
375
376
|
|
|
376
377
|
// ---------------------------------------------------------------------------
|
package/explorer/review.js
CHANGED
|
@@ -26,6 +26,7 @@ import { hooks } from './proposal.js';
|
|
|
26
26
|
import { refreshMockups } from './mockups.js';
|
|
27
27
|
import { getEdits, clearEdits } from './whatif.js';
|
|
28
28
|
import { reviewWords, sendBackProblem, reviewBody, editsHint, isReviewable, NOT_ON_A_PR } from './review-model.js';
|
|
29
|
+
import { t } from './strings.js';
|
|
29
30
|
|
|
30
31
|
const $ = (id) => document.getElementById(id);
|
|
31
32
|
|
|
@@ -61,18 +62,23 @@ function mount() {
|
|
|
61
62
|
root.id = 'review';
|
|
62
63
|
root.className = 'hx-review';
|
|
63
64
|
root.dataset.corn = 'review-bar';
|
|
64
|
-
root.setAttribute('aria-label', '
|
|
65
|
+
root.setAttribute('aria-label', `${t('approve')} or ${t('sendBack')}`);
|
|
65
66
|
root.innerHTML = `
|
|
66
|
-
<label class="hx-review-label" for="review-note"
|
|
67
|
-
<textarea id="review-note" class="hx-review-note" rows="2" maxlength="20000"
|
|
67
|
+
<label class="hx-review-label" for="review-note"></label>
|
|
68
|
+
<textarea id="review-note" class="hx-review-note" rows="2" maxlength="20000"></textarea>
|
|
68
69
|
<div class="hx-review-row">
|
|
69
|
-
<button type="button" class="hx-btn hx-btn--approve" data-review="approved" title="Sign this proposal off" data-corn-kind="approve"
|
|
70
|
-
<button type="button" class="hx-btn" data-review="notes" title="Send it back to the drafting agent with the note and your edits"
|
|
70
|
+
<button type="button" class="hx-btn hx-btn--approve" data-review="approved" title="Sign this proposal off" data-corn-kind="approve"></button>
|
|
71
|
+
<button type="button" class="hx-btn" data-review="notes" title="Send it back to the drafting agent with the note and your edits"></button>
|
|
71
72
|
<span class="hx-review-status" data-review-status role="status"></span>
|
|
72
73
|
</div>
|
|
73
74
|
<p class="hx-review-msg" data-review-msg role="alert" hidden></p>
|
|
74
75
|
<p class="hx-review-line" data-review-hint role="status" hidden></p>
|
|
75
76
|
`;
|
|
77
|
+
// The words are set as text and attributes, never parsed as HTML (a brand's `strings`, explorer/strings.js)
|
|
78
|
+
q('.hx-review-label').textContent = t('reviewNoteLabel');
|
|
79
|
+
q('#review-note').setAttribute('placeholder', t('reviewNotePlaceholder'));
|
|
80
|
+
q('[data-review="approved"]').textContent = t('approve');
|
|
81
|
+
q('[data-review="notes"]').textContent = t('sendBack');
|
|
76
82
|
body.appendChild(root);
|
|
77
83
|
root.addEventListener('click', onClick);
|
|
78
84
|
root.addEventListener('input', () => { if (ui.message) { ui.message = ''; paint(); } });
|
package/explorer/runs-view.js
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
import { relativeTime } from './review-model.js';
|
|
12
12
|
import { runTone, canRetry, aboutWords, statusWords, statusWhy, runMeta, canStop, canAnswer, groupRuns, compareTitle, limitRows, checksWords, timelineWords, nodeLabels, collisionWords, answerWords } from './runs-model.js';
|
|
13
13
|
import { cornStateAttr } from './corn-state.js';
|
|
14
|
+
import { t } from './strings.js';
|
|
14
15
|
|
|
15
16
|
|
|
16
17
|
/**
|
|
@@ -84,10 +85,10 @@ function answerHtml(ctx, run) {
|
|
|
84
85
|
const off = ctx.busy ? ' disabled' : '';
|
|
85
86
|
const reply = ctx.replies && ctx.replies.get(run.runId) || '';
|
|
86
87
|
return `${run.answer ? answeredHtml(ctx, run) : ''}<div class="hx-run-actions" role="group" aria-label="Answer run ${id}">
|
|
87
|
-
<button type="button" class="hx-btn hx-forge-act" data-run-answer="continue" data-run-id="${id}" aria-label="
|
|
88
|
-
<button type="button" class="hx-btn hx-forge-act" data-run-answer="stop" data-run-id="${id}" aria-label="
|
|
88
|
+
<button type="button" class="hx-btn hx-forge-act" data-run-answer="continue" data-run-id="${id}" aria-label="${ctx.esc(t('continueRun'))} run ${id}"${off}>${ctx.esc(t('continueRun'))}</button>
|
|
89
|
+
<button type="button" class="hx-btn hx-forge-act" data-run-answer="stop" data-run-id="${id}" aria-label="${ctx.esc(t('stop'))} run ${id}"${off} data-corn-kind="danger">${ctx.esc(t('stop'))}</button></div>
|
|
89
90
|
<label class="hx-forge-field" data-corn="field">Reply to run ${id}<input type="text" class="hx-forge-input" data-run-reply="${id}" value="${ctx.esc(reply)}" maxlength="4000" autocomplete="off" /></label>
|
|
90
|
-
<div class="hx-run-actions"><button type="button" class="hx-btn hx-forge-act" data-run-answer="reply" data-run-id="${id}" aria-label="
|
|
91
|
+
<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'))} to run ${id}"${off}>${ctx.esc(t('reply'))}</button></div>`;
|
|
91
92
|
}
|
|
92
93
|
|
|
93
94
|
/** The totals as plain lines (see `totalsLines`), escaped; '' when there are none */
|
|
@@ -103,8 +104,8 @@ export function runHtml(ctx, run, all) {
|
|
|
103
104
|
const why = statusWhy(run);
|
|
104
105
|
const note = run.report && run.report.note ? `<p class="hx-forge-meta">Runner: ${ctx.esc(run.report.note)}</p>` : '';
|
|
105
106
|
const answering = canAnswer(run);
|
|
106
|
-
const retry = canRetry(run) ? `<button type="button" class="hx-btn hx-forge-act" data-forge-retry="${ctx.esc(run.runId)}" aria-label="
|
|
107
|
-
const stop = canStop(run) && !answering ? `<button type="button" class="hx-btn hx-forge-act" data-forge-stop="${ctx.esc(run.runId)}" aria-label="
|
|
107
|
+
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'))} on run ${ctx.esc(run.runId)}"${ctx.busy ? ' disabled' : ''}>${ctx.esc(t('startAgain'))}</button>` : '';
|
|
108
|
+
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'))} run ${ctx.esc(run.runId)}"${ctx.busy ? ' disabled' : ''} data-corn-kind="danger">${ctx.esc(t('stop'))}</button>` : '';
|
|
108
109
|
const names = nodeLabels(run.nodes, ctx.nodes);
|
|
109
110
|
const collision = collisionWords(run, all, ctx.nodes);
|
|
110
111
|
const limits = limitRows(run);
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module explorer/strings
|
|
3
|
+
*
|
|
4
|
+
* The words a repo may say in its own voice (core/strings.js is the table; `strings` in cornfield.config.js the overrides, which
|
|
5
|
+
* `/cornfield/config.json` carries). Every overridable label is read through `t(key)`; the static markup in index.html marks what
|
|
6
|
+
* to replace with `data-corn-string` attributes, which `applyStrings` fills once the config is in.
|
|
7
|
+
*
|
|
8
|
+
* data-corn-string="key" the element's text
|
|
9
|
+
* data-corn-string-aria-label="key" its aria-label
|
|
10
|
+
* data-corn-string-placeholder="key" its placeholder
|
|
11
|
+
*
|
|
12
|
+
* The rule for accessible names: a control's name is its visible label. When a key is overridden the visible text and the
|
|
13
|
+
* aria-label carry the same words, and where a name adds a fixed target ("Stop run 7") only the label part is replaced
|
|
14
|
+
* ("Halt run 7"). So a screen reader says what is on the screen.
|
|
15
|
+
*
|
|
16
|
+
* Values are only ever set through textContent and attributes, never as HTML, and a value that fails core/strings.js
|
|
17
|
+
* `stringProblem` (not text, a line break, too long) is ignored here as well, whatever the server sent.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { STRINGS, isStringKey, stringProblem } from '../core/strings.js';
|
|
21
|
+
|
|
22
|
+
/** The overrides in force: key -> text */
|
|
23
|
+
let overrides = {};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Takes the overrides the config carries (`config.strings`). Anything that is not a known key with good text is left out.
|
|
27
|
+
* @param {unknown} strings
|
|
28
|
+
*/
|
|
29
|
+
export function setStrings(strings) {
|
|
30
|
+
overrides = {};
|
|
31
|
+
if (!strings || typeof strings !== 'object' || Array.isArray(strings)) return;
|
|
32
|
+
for (const [key, value] of Object.entries(strings)) if (isStringKey(key) && !stringProblem(value)) overrides[key] = value;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Whether the config overrides this key */
|
|
36
|
+
export const isOverridden = (key) => Object.hasOwn(overrides, key);
|
|
37
|
+
|
|
38
|
+
/** The words for a key: the override, else the default. A key that is not in the table gives the key itself (a test keeps the code to the table). */
|
|
39
|
+
export function t(key) {
|
|
40
|
+
if (Object.hasOwn(overrides, key)) return overrides[key];
|
|
41
|
+
return isStringKey(key) ? STRINGS[key] : String(key);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const TARGETS = [
|
|
45
|
+
['data-corn-string', (el, text) => { el.textContent = text; }],
|
|
46
|
+
['data-corn-string-aria-label', (el, text) => el.setAttribute('aria-label', text)],
|
|
47
|
+
['data-corn-string-placeholder', (el, text) => el.setAttribute('placeholder', text)],
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Puts the overrides in the static markup. Only an overridden key touches its element, so what index.html says is what shows
|
|
52
|
+
* without one.
|
|
53
|
+
* @param {ParentNode} root
|
|
54
|
+
*/
|
|
55
|
+
export function applyStrings(root) {
|
|
56
|
+
if (!root || typeof root.querySelectorAll !== 'function') return;
|
|
57
|
+
for (const [attr, set] of TARGETS) {
|
|
58
|
+
for (const el of root.querySelectorAll(`[${attr}]`)) {
|
|
59
|
+
const key = el.getAttribute(attr);
|
|
60
|
+
if (isOverridden(key)) set(el, overrides[key]);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** For tests: forget the overrides */
|
|
66
|
+
export function resetStringsForTests() {
|
|
67
|
+
overrides = {};
|
|
68
|
+
}
|
package/explorer/view.js
CHANGED
|
@@ -15,6 +15,7 @@ import { clearScenario } from './scenario-ui.js';
|
|
|
15
15
|
import { measureParams } from './bench.js';
|
|
16
16
|
import { mergeLive, placeLiveNodes } from './live-model.js';
|
|
17
17
|
import { applyHouseLayout } from './house-model.js';
|
|
18
|
+
import { t } from './strings.js';
|
|
18
19
|
|
|
19
20
|
const $ = (id) => document.getElementById(id);
|
|
20
21
|
|
|
@@ -166,5 +167,5 @@ export function syncViewUi() {
|
|
|
166
167
|
const note = $('layers-preset-note');
|
|
167
168
|
if (note) note.hidden = !preset;
|
|
168
169
|
const badge = $('instruction-badge-text');
|
|
169
|
-
if (badge) badge.textContent = preset ? '
|
|
170
|
+
if (badge) badge.textContent = preset ? t('hintDataFlow') : (state.isFreeform ? t('hintDrag') : t('hintInspect'));
|
|
170
171
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cornfield",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0",
|
|
4
4
|
"description": "A self-hostable dev dashboard with the topology map at its centre: proposals on the map, scenarios, outages and what-if edits, for any repo.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "popcorn245 (https://github.com/popcorn245)",
|
package/server/server.js
CHANGED
|
@@ -56,6 +56,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
56
56
|
import { browserSources, BUILTIN_SOURCES, parseDuration, specPollMs, triggersOf, DEFAULTS, hookWants, ideaLabel, runnerQuietAfterMs } from '../core/config.js';
|
|
57
57
|
import { CLOUD_FILE } from '../core/cloud.js';
|
|
58
58
|
import { BRAND_SVG_CSP, MANIFEST_PATH, appNameOf, brandAssetFile, brandImages, clientBrand, colorOf, manifestOf } from '../core/brand.js';
|
|
59
|
+
import { clientStrings } from '../core/strings.js';
|
|
59
60
|
import { MAX_THEME_ASSET_BYTES, MAX_THEME_BYTES, THEME_ASSET_PREFIX, THEME_NAME, THEME_SVG_CSP, clientTheme, cssProblems, fontOrigins, fontUrl, themeAssetFile, themeAssetPath } from '../core/theme.js';
|
|
60
61
|
import { decodePath, inside, notFound, sendFile } from './files.js';
|
|
61
62
|
import { serveProposals } from './proposals.js';
|
|
@@ -78,7 +79,7 @@ import { createTriggers } from './triggers.js';
|
|
|
78
79
|
export const CORNFIELD_DIR = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
79
80
|
const EXPLORER_DIR = path.join(CORNFIELD_DIR, 'explorer');
|
|
80
81
|
/** The pure core modules the explorer imports (no Node built-ins, no files): the only ones of core/ served */
|
|
81
|
-
export const BROWSER_CORE = ['schema.js', 'proposal.js', 'personas.js', 'cloud.js', 'text.js', 'mentions.js', 'color.js'];
|
|
82
|
+
export const BROWSER_CORE = ['schema.js', 'proposal.js', 'personas.js', 'cloud.js', 'text.js', 'mentions.js', 'color.js', 'strings.js'];
|
|
82
83
|
/** cornfield's own browser sources, by request path */
|
|
83
84
|
const BROWSER_PLUGINS = new Map(Object.values(BUILTIN_SOURCES).map((p) => [p, path.join(CORNFIELD_DIR, p)]));
|
|
84
85
|
const PKG = JSON.parse(fs.readFileSync(path.join(CORNFIELD_DIR, 'package.json'), 'utf8'));
|
|
@@ -264,6 +265,8 @@ export function clientConfig(config, signIn = false) {
|
|
|
264
265
|
theme: clientTheme(config.theme),
|
|
265
266
|
// The brand's image URLs and name, never a file's path (docs/config.md#brand)
|
|
266
267
|
brand: clientBrand(config.brand, PKG.homepage),
|
|
268
|
+
// Only the labels the config overrides, as text (core/strings.js); the defaults are in the browser
|
|
269
|
+
strings: clientStrings(config.strings),
|
|
267
270
|
forge: config.forge ? { type: config.forge.type, url: config.forge.url || (config.forge.type === 'github' ? 'https://github.com' : null), repo: config.forge.repo, mergeMethod: config.forge.mergeMethod || 'merge', ...(config.approveLands ? { approveLands: true } : {}) } : null,
|
|
268
271
|
// Threads (docs/threads.md): the idea label, or false when `threads: false` turns the Threads tab off
|
|
269
272
|
threads: config.threads === false ? false : { label: ideaLabel(config) },
|