@tacoshell/shell 0.0.0-stage → 0.1.1
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/LICENSE +28 -0
- package/README.md +6 -2
- package/package.json +40 -4
- package/src/background.ts +41 -0
- package/src/core/bus.ts +210 -0
- package/src/core/cards.ts +33 -0
- package/src/core/contrib.ts +70 -0
- package/src/core/cron.ts +63 -0
- package/src/core/cronfriendly.ts +70 -0
- package/src/core/csv.ts +36 -0
- package/src/core/csvfeature.ts +57 -0
- package/src/core/datasets.ts +367 -0
- package/src/core/domshot.ts +81 -0
- package/src/core/guards.ts +36 -0
- package/src/core/hosts.ts +15 -0
- package/src/core/hotkeys.ts +44 -0
- package/src/core/indicators.ts +62 -0
- package/src/core/jobs.ts +37 -0
- package/src/core/localdata.ts +88 -0
- package/src/core/log.ts +91 -0
- package/src/core/markdown.ts +57 -0
- package/src/core/nav.ts +105 -0
- package/src/core/notifyrules.ts +31 -0
- package/src/core/page.ts +91 -0
- package/src/core/prefs.ts +119 -0
- package/src/core/router.ts +78 -0
- package/src/core/search.ts +65 -0
- package/src/core/services.ts +178 -0
- package/src/core/sessions.ts +93 -0
- package/src/core/startpage.ts +28 -0
- package/src/core/storage.ts +54 -0
- package/src/core/systemtools.ts +85 -0
- package/src/core/tabfit.ts +30 -0
- package/src/core/templates.ts +48 -0
- package/src/core/text.ts +6 -0
- package/src/core/toasts.ts +13 -0
- package/src/core/vault.ts +208 -0
- package/src/env.d.ts +2 -0
- package/src/index.ts +58 -0
- package/src/styles.css +391 -0
- package/src/types.ts +133 -0
- package/src/ui/ActionModal.tsx +22 -0
- package/src/ui/App.tsx +241 -0
- package/src/ui/ClearableInput.tsx +23 -0
- package/src/ui/CsvFeature.tsx +151 -0
- package/src/ui/Icon.tsx +8 -0
- package/src/ui/ItemFeature.tsx +39 -0
- package/src/ui/Markdown.tsx +24 -0
- package/src/ui/Rail.tsx +135 -0
- package/src/ui/RelatedMenu.tsx +57 -0
- package/src/ui/Search.tsx +111 -0
- package/src/ui/Sessions.tsx +76 -0
- package/src/ui/SidePanel.tsx +150 -0
- package/src/ui/TabBar.tsx +56 -0
- package/src/ui/ViewHost.tsx +142 -0
- package/src/ui/hooks.ts +28 -0
- package/src/ui/settings/Datasets.tsx +172 -0
- package/src/ui/settings/ReleaseNotes.tsx +96 -0
- package/src/ui/settings/ScheduleEditor.tsx +57 -0
- package/src/ui/settings/Settings.tsx +339 -0
- package/src/ui/settings/SettingsTabs.tsx +63 -0
- package/src/ui/settings/Templates.tsx +52 -0
- package/src/ui/useContrib.ts +36 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { useRef, useState } from 'react';
|
|
2
|
+
import { createFramework } from '../../core/bus.ts';
|
|
3
|
+
import * as datasets from '../../core/datasets.ts';
|
|
4
|
+
import { download } from '../../core/localdata.ts';
|
|
5
|
+
import { href } from '../../core/router.ts';
|
|
6
|
+
import { toast } from '../../core/toasts.ts';
|
|
7
|
+
import * as vault from '../../core/vault.ts';
|
|
8
|
+
import type { RegistryDataset } from '../../types.ts';
|
|
9
|
+
import { useShell, useStore } from '../hooks.ts';
|
|
10
|
+
import { Markdown } from '../Markdown.tsx';
|
|
11
|
+
import { ScheduleEditor } from './ScheduleEditor.tsx';
|
|
12
|
+
|
|
13
|
+
const size = (n: number) => (n < 1024 ? `${n} B` : n < 1048576 ? `${(n / 1024).toFixed(1)} KB` : `${(n / 1048576).toFixed(1)} MB`);
|
|
14
|
+
const when = (iso?: string) => (iso ? `${new Date(iso).toLocaleString()} (${ago(iso)})` : 'never');
|
|
15
|
+
const signed = (n: number) => (n > 0 ? `+${n.toLocaleString()}` : n.toLocaleString());
|
|
16
|
+
|
|
17
|
+
interface Pending { name: string; bytes: number; modified: number; text: string; a: datasets.CsvAnalysis }
|
|
18
|
+
|
|
19
|
+
const vaultStore = { get: vault.status, subscribe: (fn: () => void) => vault.subscribe(fn) };
|
|
20
|
+
const ago = (iso?: string) => { if (!iso) return 'never'; const s = (Date.now() - new Date(iso).getTime()) / 1000; return s < 60 ? 'just now' : s < 3600 ? `${Math.round(s / 60)} min ago` : s < 86400 ? `${Math.round(s / 3600)} h ago` : new Date(iso).toLocaleDateString(); };
|
|
21
|
+
const cell = (v: unknown) => (v === null || v === undefined ? '—' : typeof v === 'object' ? JSON.stringify(v) : String(v));
|
|
22
|
+
|
|
23
|
+
/** Shown before any CSV replaces a dataset: what is in the file, what it will replace, and what looks off. Nothing is stored until Import is pressed. */
|
|
24
|
+
function ImportConfirm({ d, p, busy, onCancel, onConfirm }: { d: RegistryDataset; p: Pending; busy: boolean; onCancel: () => void; onConfirm: () => void }) {
|
|
25
|
+
const st = datasets.stateOf(d);
|
|
26
|
+
const { a } = p;
|
|
27
|
+
const delta = a.rows.length - st.rows;
|
|
28
|
+
const shrinks = st.rows > 0 && a.rows.length < st.rows * 0.5;
|
|
29
|
+
const cols = a.columns.slice(0, 8);
|
|
30
|
+
const row = (k: string, v: React.ReactNode) => <tr><td className="muted">{k}</td><td>{v}</td></tr>;
|
|
31
|
+
return (
|
|
32
|
+
<div className="backdrop" onKeyDown={(e) => e.key === 'Escape' && onCancel()}>
|
|
33
|
+
<div className="modal import-confirm" role="alertdialog" aria-labelledby="imp-title">
|
|
34
|
+
<button className="close" onClick={onCancel} aria-label="Close">×</button>
|
|
35
|
+
<h2 id="imp-title">Import into {d.label}?</h2>
|
|
36
|
+
<p className="muted small">A CSV import <strong>replaces every row</strong> in this dataset. Nothing changes until you press Import.</p>
|
|
37
|
+
<div className="import-cols">
|
|
38
|
+
<div><h3>The file</h3><table className="keys"><tbody>
|
|
39
|
+
{row('Name', <code>{p.name}</code>)}
|
|
40
|
+
{row('Size', size(p.bytes))}
|
|
41
|
+
{row('File modified', new Date(p.modified).toLocaleString())}
|
|
42
|
+
{row('Rows in file', a.fileRows.toLocaleString())}
|
|
43
|
+
{row('Rows to import', <strong>{a.rows.length.toLocaleString()}</strong>)}
|
|
44
|
+
{row('Columns', `${a.columns.length}${a.missing.length ? ` (${a.missing.length} missing)` : ''}${a.extra.length ? ` (${a.extra.length} not in the schema)` : ''}`)}
|
|
45
|
+
</tbody></table></div>
|
|
46
|
+
<div><h3>What it replaces</h3><table className="keys"><tbody>
|
|
47
|
+
{row('Current rows', st.rows.toLocaleString())}
|
|
48
|
+
{row('Last updated', when(st.updatedAt))}
|
|
49
|
+
{row('Last source', st.source ?? '—')}
|
|
50
|
+
{row('Change', <strong className={delta < 0 ? 'sched-warn' : ''}>{signed(delta)} rows</strong>)}
|
|
51
|
+
</tbody></table></div>
|
|
52
|
+
</div>
|
|
53
|
+
{shrinks && <p className="sched-warn small">⚠ The file has less than half as many rows as the dataset has now ({a.rows.length.toLocaleString()} vs {st.rows.toLocaleString()}). Is it the right file?</p>}
|
|
54
|
+
{d.kind === 'refreshable' && st.source === 'routine' && <p className="sched-warn small">⚠ These rows came from a refresh; the CSV replaces them until the next refresh.</p>}
|
|
55
|
+
{a.warnings.map((w) => <p key={w} className="sched-warn small">⚠ {w}</p>)}
|
|
56
|
+
{a.emptyKeys > 0 && <p className="sched-warn small">⚠ {a.emptyKeys} row(s) have an empty "{d.key}".</p>}
|
|
57
|
+
<h3>First rows</h3>
|
|
58
|
+
<div className="grid-wrap"><table className="grid"><thead><tr>{cols.map((c) => <th key={c}>{c}</th>)}</tr></thead>
|
|
59
|
+
<tbody>{a.rows.slice(0, 5).map((r, i) => <tr key={i}>{cols.map((c) => <td key={c}>{cell(r[c])}</td>)}</tr>)}</tbody></table>
|
|
60
|
+
{a.columns.length > cols.length && <p className="muted small">+{a.columns.length - cols.length} more column(s).</p>}</div>
|
|
61
|
+
<div className="actions"><button onClick={onCancel}>Cancel</button><button className="primary" autoFocus disabled={busy || !a.rows.length} onClick={onConfirm}>Import {a.rows.length.toLocaleString()} rows</button></div>
|
|
62
|
+
</div>
|
|
63
|
+
</div>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** When it refreshes, when it is next due, and a warning when a scheduled time has passed without an update. */
|
|
68
|
+
function Schedule({ d, onEdit }: { d: RegistryDataset; onEdit: () => void }) {
|
|
69
|
+
useStore(datasets.states);
|
|
70
|
+
const next = datasets.nextDue(d), c = datasets.compliance(d);
|
|
71
|
+
const custom = !!datasets.stateOf(d).schedule;
|
|
72
|
+
return (
|
|
73
|
+
<p className="schedule-line small">
|
|
74
|
+
<i className="fa-regular fa-clock" /> <strong>{datasets.describeSchedule(d)}</strong>{custom ? <span className="muted"> (your choice)</span> : d.schedule ? <span className="muted"> (default)</span> : null}
|
|
75
|
+
{next && <span className="muted"> · next {new Date(next).toLocaleString(undefined, { weekday: 'short', day: 'numeric', month: 'short', hour: 'numeric', minute: '2-digit' })}</span>}
|
|
76
|
+
{c.scheduled && (c.ok ? <span className="sched-ok"> ✓ up to date</span> : <span className="sched-warn"> ⚠ a scheduled refresh is overdue</span>)}
|
|
77
|
+
{' '}<button className="link" onClick={onEdit}>Schedule…</button>
|
|
78
|
+
</p>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function DatasetCard({ d }: { d: RegistryDataset }) {
|
|
83
|
+
useStore(datasets.states);
|
|
84
|
+
const st = datasets.stateOf(d);
|
|
85
|
+
const [open, setOpen] = useState<'preview' | 'schema' | 'instructions' | null>(null);
|
|
86
|
+
const [preview, setPreview] = useState<datasets.Row[]>([]);
|
|
87
|
+
const [busy, setBusy] = useState(false);
|
|
88
|
+
const [confirmClear, setConfirmClear] = useState(false);
|
|
89
|
+
const [scheduling, setScheduling] = useState(false);
|
|
90
|
+
const file = useRef<HTMLInputElement>(null);
|
|
91
|
+
const run = async (what: () => Promise<void>) => { setBusy(true); try { await what(); } catch (e) { toast((e as Error).message, 'error'); } finally { setBusy(false); } };
|
|
92
|
+
const [pending, setPending] = useState<Pending | null>(null);
|
|
93
|
+
// Picking a file only reads and analyses it; the import itself waits for the confirmation.
|
|
94
|
+
const stageFile = (f?: File) => f && run(async () => {
|
|
95
|
+
try { setPending({ name: f.name, bytes: f.size, modified: f.lastModified, text: await f.text(), a: datasets.analyzeCsv(d, await f.text()) }); }
|
|
96
|
+
finally { if (file.current) file.current.value = ''; }
|
|
97
|
+
});
|
|
98
|
+
const confirmImport = () => pending && run(async () => {
|
|
99
|
+
const r = await datasets.importCsv(d, pending.text);
|
|
100
|
+
setPending(null);
|
|
101
|
+
toast(`${d.label}: ${r.rows} row(s) imported.${r.warnings.length ? ` ${r.warnings.join(' ')}` : ''}`, r.warnings.length ? 'error' : 'info');
|
|
102
|
+
if (open === 'preview') setPreview((await datasets.rows(d)).slice(0, 20));
|
|
103
|
+
});
|
|
104
|
+
const toggle = (what: 'preview' | 'schema' | 'instructions') => run(async () => {
|
|
105
|
+
if (open === what) return setOpen(null);
|
|
106
|
+
if (what === 'preview') setPreview((await datasets.rows(d)).slice(0, 20));
|
|
107
|
+
setOpen(what);
|
|
108
|
+
});
|
|
109
|
+
const columns = st.columns.length ? st.columns : Object.keys(d.schema ?? {});
|
|
110
|
+
const est = datasets.estimateMs(d);
|
|
111
|
+
const prog = useStore(datasets.progressNow)[datasets.idOf(d)];
|
|
112
|
+
const cancelling = !!prog?.cancelling;
|
|
113
|
+
const load = datasets.loadOf(d);
|
|
114
|
+
const go = (ask?: 'full') => run(async () => {
|
|
115
|
+
try { const n = await datasets.refresh(d, createFramework(d.module), { load: ask }); toast(`${d.label} ${load === 'incremental' && !ask ? 'updated' : 'refreshed'}: ${n} row(s) loaded.`); }
|
|
116
|
+
catch (e) { if ((e as Error).message === 'Cancelled') toast(`${d.label}: refresh cancelled.`); else throw e; }
|
|
117
|
+
});
|
|
118
|
+
return (
|
|
119
|
+
<div className="card dataset">
|
|
120
|
+
<div className="dataset-head">
|
|
121
|
+
<div><strong>{d.label}</strong> <span className={`pill ${d.kind === 'refreshable' ? 'ok' : ''}`}>{d.kind === 'importOnly' ? 'Import only' : 'Refreshable'}</span>
|
|
122
|
+
<div className="muted small">{d.module}/{d.name}{d.key ? ` · key ${d.key}` : ''}</div></div>
|
|
123
|
+
<div className="dataset-stats"><strong>{st.rows.toLocaleString()}</strong> rows<div className="muted small">updated {ago(st.updatedAt)}{st.source ? ` (${st.source})` : ''}</div></div>
|
|
124
|
+
</div>
|
|
125
|
+
{d.kind === 'refreshable' && <Schedule d={d} onEdit={() => setScheduling(true)} />}
|
|
126
|
+
{scheduling && <ScheduleEditor title={d.label} description="When this dataset refreshes by itself. The developer ships a default; this is your choice for this install." current={datasets.cronOf(d)} defaultCron={d.schedule?.cron ?? null}
|
|
127
|
+
onSave={(cron) => datasets.setSchedule(d, cron)} onClose={() => setScheduling(false)} />}
|
|
128
|
+
{st.refreshing && <p className="muted small dataset-progress" role="status"><i className="fa-solid fa-circle-notch fa-spin" /> {prog?.text ?? 'Working…'}</p>}
|
|
129
|
+
{st.lastError && <p className="error small">Last refresh failed: {st.lastError}</p>}
|
|
130
|
+
<div className="actions">
|
|
131
|
+
<button className="primary" disabled={busy} onClick={() => file.current?.click()}><i className="fa-solid fa-file-csv" /> Import CSV</button>
|
|
132
|
+
<input ref={file} type="file" accept=".csv,text/csv" hidden onChange={(e) => void stageFile(e.target.files?.[0])} />
|
|
133
|
+
{pending && <ImportConfirm d={d} p={pending} busy={busy} onCancel={() => setPending(null)} onConfirm={() => void confirmImport()} />}
|
|
134
|
+
<button disabled={busy || !st.rows} onClick={() => void run(async () => download(`${d.name}.csv`, await datasets.exportCsv(d), 'text/csv'))}><i className="fa-solid fa-file-export" /> Export CSV</button>
|
|
135
|
+
{d.kind === 'refreshable' && <button disabled={busy || st.refreshing || !datasets.hasRoutine(d)} onClick={() => void go()}>
|
|
136
|
+
<i className={`fa-solid fa-rotate${st.refreshing ? ' fa-spin' : ''}`} /> {st.refreshing ? 'Refreshing…' : d.incremental && load === 'incremental' ? 'Refresh now (incremental)' : 'Refresh now'}{est && !st.refreshing ? ` (~${Math.max(1, Math.round(est / 1000))} s)` : ''}</button>}
|
|
137
|
+
{d.kind === 'refreshable' && d.incremental && !st.refreshing && st.rows > 0 && <button disabled={busy || !datasets.hasRoutine(d)} title="Replace every row instead of loading only what changed" onClick={() => void go('full')}><i className="fa-solid fa-arrows-rotate" /> Full Load</button>}
|
|
138
|
+
{st.refreshing && <button className="danger" disabled={cancelling} onClick={() => datasets.cancel(d)}>{cancelling ? 'Cancelling…' : 'Cancel'}</button>}
|
|
139
|
+
<button disabled={busy || !st.rows} onClick={() => void toggle('preview')}>{open === 'preview' ? 'Hide preview' : 'Preview'}</button>
|
|
140
|
+
<button onClick={() => void toggle('schema')}>{open === 'schema' ? 'Hide schema' : 'Schema'}</button>
|
|
141
|
+
{d.instructionsText && <button onClick={() => void toggle('instructions')}>{open === 'instructions' ? 'Hide instructions' : 'Instructions'}</button>}
|
|
142
|
+
<button className="danger" disabled={busy || !st.rows} onClick={() => { if (!confirmClear) return setConfirmClear(true); setConfirmClear(false); void run(() => datasets.clear(d)); }}>{confirmClear ? 'Click again to clear' : 'Clear'}</button>
|
|
143
|
+
</div>
|
|
144
|
+
{open === 'instructions' && <div className="help-body"><Markdown text={d.instructionsText} /></div>}
|
|
145
|
+
{open === 'schema' && (
|
|
146
|
+
<table className="grid"><thead><tr><th>Column</th><th>Type</th></tr></thead>
|
|
147
|
+
<tbody>{Object.entries(d.schema ?? {}).map(([c, t]) => <tr key={c}><td><code>{c}</code>{c === d.key ? ' (key)' : ''}</td><td>{t}</td></tr>)}</tbody></table>
|
|
148
|
+
)}
|
|
149
|
+
{open === 'preview' && (
|
|
150
|
+
<div className="grid-wrap"><table className="grid"><thead><tr>{columns.map((c) => <th key={c}>{c}</th>)}</tr></thead>
|
|
151
|
+
<tbody>{preview.map((r, i) => <tr key={i}>{columns.map((c) => <td key={c}>{cell(r[c])}</td>)}</tr>)}</tbody></table>
|
|
152
|
+
<p className="muted small">First {preview.length} of {st.rows} row(s).</p></div>
|
|
153
|
+
)}
|
|
154
|
+
</div>
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/** Settings → Datasets (ADR-043): every dataset the app's modules declare. Rows are only readable while the vault is unlocked. */
|
|
159
|
+
export function DatasetsPage() {
|
|
160
|
+
const { registry } = useShell();
|
|
161
|
+
const status = useStore(vaultStore);
|
|
162
|
+
return (
|
|
163
|
+
<div className="page">
|
|
164
|
+
<h1>Datasets</h1>
|
|
165
|
+
<p className="muted">Datasets are stored encrypted in the vault. <strong>Import only</strong> datasets are filled from a CSV; <strong>refreshable</strong> ones also refresh themselves from their services (a CSV import still works).</p>
|
|
166
|
+
{!registry.datasets.length && <p className="muted">No module in this app declares a dataset. Add one with <code>taco-cli add component --type=dataset</code>.</p>}
|
|
167
|
+
{status === 'uninitialized' && registry.datasets.length > 0 && <div className="card">Create the vault first: <a href={href.settings('getting-started')}>Getting Started</a>.</div>}
|
|
168
|
+
{status === 'locked' && registry.datasets.length > 0 && <div className="card">The vault is locked. <button className="primary" onClick={() => void vault.whenUnlocked()}><i className="fa-solid fa-lock-open" /> Unlock</button></div>}
|
|
169
|
+
{status === 'unlocked' && registry.datasets.map((d) => <DatasetCard key={`${d.module}/${d.name}`} d={d} />)}
|
|
170
|
+
</div>
|
|
171
|
+
);
|
|
172
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { href } from '../../core/router.ts';
|
|
3
|
+
import { useShell } from '../hooks.ts';
|
|
4
|
+
import { ContributedTab, TabStrip, tabKey, useContributedTabs } from './SettingsTabs.tsx';
|
|
5
|
+
import { Markdown } from '../Markdown.tsx';
|
|
6
|
+
|
|
7
|
+
/** What the build writes to `sbom.json` (CycloneDX 1.5): only the fields this page shows. */
|
|
8
|
+
interface Bom {
|
|
9
|
+
serialNumber?: string; specVersion?: string;
|
|
10
|
+
metadata?: { timestamp?: string; component?: { name?: string; version?: string } };
|
|
11
|
+
components?: { name: string; version: string; type: string; purl?: string; licenses?: ({ license: { id?: string; name?: string } } | { expression: string })[]; properties?: { name: string; value: string }[] }[];
|
|
12
|
+
services?: { name: string; description?: string; endpoints?: string[]; properties?: { name: string; value: string }[] }[];
|
|
13
|
+
}
|
|
14
|
+
const ORIGIN: Record<string, string> = { framework: 'Framework', module: 'Taco module', dependency: 'Dependency', external: 'External tool' };
|
|
15
|
+
const originOf = (c: NonNullable<Bom['components']>[number]) => ORIGIN[c.properties?.find((p) => p.name === 'taco:origin')?.value ?? ''] ?? 'Dependency';
|
|
16
|
+
const licenseOf = (c: NonNullable<Bom['components']>[number]) => (c.licenses ?? []).map((l) => ('expression' in l ? l.expression : l.license.id ?? l.license.name ?? '')).filter(Boolean).join(', ') || 'unknown';
|
|
17
|
+
|
|
18
|
+
/** Settings → Release Notes → SBOM: the external dependencies the build shipped, as a table, with the CycloneDX JSON to download. */
|
|
19
|
+
function SbomTab() {
|
|
20
|
+
const { registry } = useShell();
|
|
21
|
+
const [bom, setBom] = useState<Bom | null>(null);
|
|
22
|
+
const [error, setError] = useState<string | null>(null);
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
let stop = false;
|
|
25
|
+
fetch('sbom.json').then((r) => (r.ok ? r.json() : Promise.reject(new Error(`sbom.json is missing from this build (${r.status}). Build with taco-cli deploy.`)))).then((b) => { if (!stop) setBom(b); }).catch((e: Error) => { if (!stop) setError(e.message); });
|
|
26
|
+
return () => { stop = true; };
|
|
27
|
+
}, []);
|
|
28
|
+
if (error) return <div className="card"><p className="muted">{error}</p></div>;
|
|
29
|
+
if (!bom) return <p className="muted">Loading…</p>;
|
|
30
|
+
const components = bom.components ?? [], services = bom.services ?? [];
|
|
31
|
+
const counts = (o: string) => components.filter((c) => originOf(c) === o).length;
|
|
32
|
+
return (
|
|
33
|
+
<div data-testid="sbom">
|
|
34
|
+
<p className="muted">
|
|
35
|
+
Everything that ships inside {registry.app.displayName} v{registry.app.version}: {components.length} component(s) ({counts('Dependency')} external dependencies, {counts('External tool')} external tools, {counts('Framework')} framework, {counts('Taco module')} Taco modules)
|
|
36
|
+
and {services.length} external service(s). Generated by the build{bom.metadata?.timestamp ? ` on ${new Date(bom.metadata.timestamp).toLocaleString()}` : ''}.
|
|
37
|
+
</p>
|
|
38
|
+
<p><a className="button-link" href="sbom.json" download={`${registry.app.name}-${registry.app.version}.cdx.json`} data-sbom-download><i className="fa-solid fa-download" /> Download SBOM (CycloneDX {bom.specVersion ?? '1.5'} JSON)</a></p>
|
|
39
|
+
<div className="table-wrap">
|
|
40
|
+
<table className="sbom-table">
|
|
41
|
+
<thead><tr><th>Component</th><th>Version</th><th>Origin</th><th>License</th><th>Package URL</th></tr></thead>
|
|
42
|
+
<tbody>
|
|
43
|
+
{components.map((c) => (
|
|
44
|
+
<tr key={`${c.name}@${c.version}`} data-component={c.name}>
|
|
45
|
+
<td><strong>{c.name}</strong></td><td>{c.version}</td><td>{originOf(c)}</td><td>{licenseOf(c)}</td><td><code className="small">{c.purl}</code></td>
|
|
46
|
+
</tr>
|
|
47
|
+
))}
|
|
48
|
+
</tbody>
|
|
49
|
+
</table>
|
|
50
|
+
</div>
|
|
51
|
+
{services.length > 0 && (
|
|
52
|
+
<>
|
|
53
|
+
<h2>External services</h2>
|
|
54
|
+
<div className="table-wrap">
|
|
55
|
+
<table className="sbom-table">
|
|
56
|
+
<thead><tr><th>Service</th><th>Endpoints</th><th>Provided by</th></tr></thead>
|
|
57
|
+
<tbody>
|
|
58
|
+
{services.map((s) => (
|
|
59
|
+
<tr key={s.name} data-service={s.name}><td><strong>{s.name}</strong></td><td>{(s.endpoints ?? []).join(', ')}</td><td>{s.properties?.find((p) => p.name === 'taco:module')?.value}</td></tr>
|
|
60
|
+
))}
|
|
61
|
+
</tbody>
|
|
62
|
+
</table>
|
|
63
|
+
</div>
|
|
64
|
+
</>
|
|
65
|
+
)}
|
|
66
|
+
</div>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Settings → Release Notes: the app's `self/docs/release-notes.md`, newest first (tab "Release Notes"), and the SBOM of what the build shipped (tab "SBOM").
|
|
72
|
+
* Written by hand for now (`taco-cli deploy --release` adds the heading); the shape `## vX.Y.Z — date` + `- change ([#12](…))` is what a generator can fill later.
|
|
73
|
+
*/
|
|
74
|
+
export function ReleaseNotesPage({ tab = 'notes' }: { tab?: string }) {
|
|
75
|
+
const { registry } = useShell();
|
|
76
|
+
const contributed = useContributedTabs('release-notes');
|
|
77
|
+
const extra = contributed.find((t) => tabKey(t) === tab);
|
|
78
|
+
const strip = <TabStrip page="release-notes" core={[{ id: 'notes', label: 'Release Notes', href: href.settings('release-notes') }, { id: 'sbom', label: 'SBOM', href: href.settings('release-notes', 'sbom') }]} contributed={contributed} active={extra ? tabKey(extra) : tab === 'sbom' ? 'sbom' : 'notes'} />;
|
|
79
|
+
if (extra) return <>{strip}<ContributedTab tab={extra} /></>;
|
|
80
|
+
return (
|
|
81
|
+
<>
|
|
82
|
+
{strip}
|
|
83
|
+
<div className="page">
|
|
84
|
+
<h1>Release Notes</h1>
|
|
85
|
+
{tab === 'sbom' ? <SbomTab /> : (
|
|
86
|
+
<>
|
|
87
|
+
<p className="muted">What changed in each version of {registry.app.displayName}, newest first. You are on <strong>v{registry.app.version}</strong>.</p>
|
|
88
|
+
{registry.releaseNotesText?.trim()
|
|
89
|
+
? <div className="card release-notes"><Markdown text={registry.releaseNotesText} /></div>
|
|
90
|
+
: <div className="card"><p className="muted">No release notes yet. Write them in <code>self/docs/release-notes.md</code>.</p></div>}
|
|
91
|
+
</>
|
|
92
|
+
)}
|
|
93
|
+
</div>
|
|
94
|
+
</>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { useMemo, useState } from 'react';
|
|
2
|
+
import { cronNext, parseCron } from '../../core/cron.ts';
|
|
3
|
+
import { DAYS, HOUR_STEPS, MINUTE_STEPS, MODES, describeCron, fromForm, toForm, type Form, type Mode } from '../../core/cronfriendly.ts';
|
|
4
|
+
|
|
5
|
+
const fmt = (t: number) => new Date(t).toLocaleString(undefined, { weekday: 'short', day: 'numeric', month: 'short', hour: 'numeric', minute: '2-digit' });
|
|
6
|
+
|
|
7
|
+
/** Plain-English schedule form (How often · time · days). What is saved is the crontab, shown read-only under the form; "Custom" lets an expert type one. */
|
|
8
|
+
export function ScheduleEditor({ title, description, current, defaultCron, onSave, onClose }: { title: string; description?: string; current: string | null; defaultCron?: string | null; onSave: (cron: string | null) => Promise<void>; onClose: () => void }) {
|
|
9
|
+
const [s, setS] = useState<Form>(() => toForm(current));
|
|
10
|
+
const [saving, setSaving] = useState(false);
|
|
11
|
+
const set = (patch: Partial<Form>) => setS((x) => ({ ...x, ...patch }));
|
|
12
|
+
const expr = fromForm(s);
|
|
13
|
+
const problem = useMemo(() => {
|
|
14
|
+
if (s.mode === 'weekly' && !s.days.length) return 'Pick at least one day.';
|
|
15
|
+
if (s.mode === 'custom') { if (!expr) return 'Type a crontab (5 fields).'; try { parseCron(expr); } catch (e) { return (e as Error).message; } }
|
|
16
|
+
return null;
|
|
17
|
+
}, [s, expr]);
|
|
18
|
+
const runs = useMemo(() => {
|
|
19
|
+
const out: number[] = [];
|
|
20
|
+
if (expr && !problem) for (let t = Date.now(), i = 0; i < 3; i++) { const n = cronNext(expr, t); if (n == null) break; out.push(n); t = n; }
|
|
21
|
+
return out;
|
|
22
|
+
}, [expr, problem]);
|
|
23
|
+
const save = async () => { setSaving(true); try { await onSave(expr); onClose(); } finally { setSaving(false); } };
|
|
24
|
+
const steps = s.mode === 'minutes' ? MINUTE_STEPS : HOUR_STEPS;
|
|
25
|
+
const unit = (n: number) => (s.mode === 'minutes' ? (n === 1 ? 'minute' : `${n} minutes`) : n === 1 ? 'hour' : `${n} hours`);
|
|
26
|
+
return (
|
|
27
|
+
<div className="backdrop" onMouseDown={(e) => e.target === e.currentTarget && onClose()}>
|
|
28
|
+
<div className="modal schedule">
|
|
29
|
+
<button className="close" onClick={onClose} aria-label="Close">×</button>
|
|
30
|
+
<h2>Schedule — {title}</h2>
|
|
31
|
+
{description && <p className="muted small">{description}</p>}
|
|
32
|
+
<div className="form-row"><label>Refresh</label>
|
|
33
|
+
<select aria-label="How often" value={s.mode} onChange={(e) => { const mode = e.target.value as Mode; set(mode === 'custom' ? { mode, cron: fromForm({ ...s, mode: 'daily' }) ?? s.cron } : { mode }); }}>
|
|
34
|
+
{MODES.map(([v, l]) => <option key={v} value={v}>{l}</option>)}
|
|
35
|
+
</select></div>
|
|
36
|
+
{(s.mode === 'minutes' || s.mode === 'hours') && <div className="form-row"><label>Every</label>
|
|
37
|
+
<select value={s.every} onChange={(e) => set({ every: Number(e.target.value) })}>{steps.map((n) => <option key={n} value={n}>{unit(n)}</option>)}</select></div>}
|
|
38
|
+
{s.mode === 'hours' && <div className="form-row"><label>At</label>
|
|
39
|
+
<select value={s.minute} onChange={(e) => set({ minute: Number(e.target.value) })}>{[...new Set([0, 5, 10, 15, 20, 30, 45, s.minute])].sort((a, b) => a - b).map((n) => <option key={n} value={n}>:{String(n).padStart(2, '0')} past the hour</option>)}</select></div>}
|
|
40
|
+
{['daily', 'weekdays', 'weekly', 'monthly'].includes(s.mode) && <div className="form-row"><label>At</label><input type="time" value={s.time} onChange={(e) => set({ time: e.target.value || '02:00' })} /></div>}
|
|
41
|
+
{s.mode === 'weekly' && <div className="form-row"><label>On</label><div className="days">{DAYS.map((d, i) => (
|
|
42
|
+
<label key={d} className="inline"><input type="checkbox" checked={s.days.includes(i)} onChange={(e) => set({ days: DAYS.map((_, k) => k).filter((k) => (k === i ? e.target.checked : s.days.includes(k))) })} /> {d}</label>))}</div></div>}
|
|
43
|
+
{s.mode === 'monthly' && <div className="form-row"><label>Day of the month</label><input type="number" min={1} max={28} value={s.day} style={{ width: 80 }} onChange={(e) => set({ day: Number(e.target.value) || 1 })} /> <span className="muted small">(1–28)</span></div>}
|
|
44
|
+
{s.mode === 'custom' && <div className="form-row"><label>Crontab</label><input value={s.cron} placeholder="*/30 * * * *" spellCheck={false} style={{ fontFamily: 'var(--taco-font-mono)' }} onChange={(e) => set({ cron: e.target.value })} /></div>}
|
|
45
|
+
<p><strong>{problem ? `⚠ ${problem}` : describeCron(expr)}</strong></p>
|
|
46
|
+
<p className="muted small">{runs.length ? `Next runs: ${runs.map(fmt).join(' · ')}` : s.mode === 'manual' ? 'No schedule: refresh it yourself whenever you need to.' : ''}</p>
|
|
47
|
+
<p className="muted small mono">Saved as crontab: {expr || '(none: manual)'}</p>
|
|
48
|
+
<p className="muted small">Runs only while this app is open and the vault is unlocked; a run missed while locked starts as soon as you unlock. Times are local.</p>
|
|
49
|
+
<div className="actions">
|
|
50
|
+
{defaultCron !== undefined && <button onClick={() => setS(toForm(defaultCron))} title="Go back to the schedule the developer shipped">Use the default</button>}
|
|
51
|
+
<button onClick={onClose}>Cancel</button>
|
|
52
|
+
<button className="primary" disabled={!!problem || saving} onClick={() => void save()}>Save schedule</button>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
</div>
|
|
56
|
+
);
|
|
57
|
+
}
|