Repository navigation
Description
Part of #1151.
Scope
An operator changes settings and restarts the daemon from the Settings page's Daemon card, on a worker or a gateway: Edit in a dialog, Use default, a confirm before a change that can cut the console off, and Restart daemon while a saved change waits.
If this goes wrong, an operator saves a lock-out key with no warning, sees a secret, or saves a value that undoes another change.
Technical spec
Commit 096519b.
Rows
- Behaviours: B15, B16, B17, B18, B19
- Interfaces: I20, I21, I22, I24
- Existing code: X25, X26, X27, X28, X29, X30, X31, X32
Facts
none
Modules touched
Searches: /v1/config, configSections, setCommand, ItemAction, ConfirmHost, EnrolHost, useActions, TIMES, staleKeys, settings in ui and e2e/console; Copy in the console docs.
ui/src/model/settings-rows.ts(new),ui/src/model/config-view.ts,ui/src/model/actions.ts,ui/src/model/stale-keys.ts.ui/src/state/settings.ts,ui/src/state/actions.ts,ui/src/state/queries.ts,ui/src/state/services.tsx,ui/src/data/api.ts.ui/src/ds/setting-dialog.tsx,ui/src/ds/setting-dialog.css(new),ui/src/ds/index.ts,ui/src/app/setting-host.tsx(new),ui/src/app/app.tsx.ui/src/screens/settings/index.tsx,ui/src/screens/settings/settings.css,ui/src/test/fixtures.ts,ui/src/test/console.tsx,e2e/console/stubs.ts,e2e/console/fixtures.ts,e2e/console/render-fixtures.ts.docs/internal/DESIGN.md,website/src/content/docs/docs/reference/console.mdx.
flowchart LR
SC["screens/settings *"] --> ST["state/settings *"]
ST --> M["model/settings-rows *"]
SC --> DS["ds/setting-dialog *"]
ST --> A["state/actions *"]
A --> MA["model/actions *"]
A --> API["data/api *"]
Rules in play
- ADR 0099 §7: edits in the Daemon card, the confirm, Restart daemon, no Edit on program and fleet keys.
- ADR 0037 §3: saving and restarting are entries of
ui/src/model/actions.ts, run by the one runner. - ADR 0044: the page reads
['settings']only while shown;config.changedmarks it. ui/AGENTS.mdlayers: a screen draws a view model; the contract is imported for types only.docs/internal/DESIGN.md: inputs, dialog, table; its Settings section changes in this PR.- Documentation rule 9: the console page.
Retired words
read-only, of the Daemon card: it edits settings; only the program keys and a worker's fleet keys have no Edit.
Tests
Seam: the whole app through ui/src/test/console.tsx (model: ui/src/screens/settings/settings.dom.test.tsx), the model (model: ui/src/model/actions.test.ts) and the event map (model: ui/src/model/stale-keys.test.ts).
- B15: An operator opens Settings and sees the Daemon card's rows grouped by section: a value with its default; a pending row adds
Saved: <value>; Set and Not set; Live, On restart, Restart pending; a program key with Copy and no Edit; a worker'sgateway.url,gateway.token,gateway.headersandgateway.localLeaseswith no Edit, andgateway.labelwith it; a removed key with no default (Saved: Not set); a pending secret with noSaved:line;fileProblemabove the rows with no Restart daemon; 403 and 404 as today; a gateway's rows - B16: An operator edits a row in a dialog and saves it: boolean, number, string, enum, json; a pending row opens with its saved value; a number or json that does not parse is refused in the dialog and nothing is sent; Use default on an
inFilerow sendsnull, and is absent on another; a refusal shows the daemon's message and the dialog keeps the typed value; a lost connection showsThe daemon did not answer.; a secret's field starts empty and an empty one cannot be saved; Cancel sends nothing; after a 200 the dialog closes and the answer's rows are shown; a failed save's Retry toast sends nothing while a setting dialog is open, as for Enrol (decided in delivery, pending the maintainer) - B17: A lock-out key asks first and then the page says what the restart does:
http.port;http.host;http.enabledfalse;http.enabledtrue (no confirm);http.proxyAuth; Use default onhttp.host,http.port,http.proxyAuth(the same confirm) and onhttp.enabled(a confirm only when its default is false); Keep sends nothing and keeps the dialog; the line above the rows while anhttp.*row is pending: an address, or HTTP off - B18: An operator restarts the daemon from Settings: Restart daemon only with a pending row; confirm, one
POST /v1/restart, the success toast; Keep sends nothing; a 503 shows the daemon's message; after the reconnect the rows are read again - B19:
config.changedmarks the settings read stale:config.changedmarks['settings'];lease.granteddoes not
Done when
rg '/v1/config' ui/srcprints nothing.- The console's screenshots are written again and the Settings picture shows the card.
- The website's console page describes editing, the confirms and Restart daemon, and its Settings section no longer says read-only.
pnpm test:console --project=chromium e2e/console/browser-checks.spec.tspasses.
Out of scope
- A worker's settings through its gateway's console, and joining a fleet from the console.
- Undo of a save.
Depends on
- Settings: read every setting through GET /v1/settings #1153 because: the rows it draws
- Settings: change settings through the daemon with PATCH /v1/settings, live where it can #1154 because:
PATCH /v1/settingsandconfig.changed - Settings: restart the daemon with POST /v1/restart and simlock daemon restart #1155 because:
POST /v1/restart
Written by an agent.
Activity
[-]Console: a Settings page that edits settings and restarts the daemon[/-][+]Console: edit settings and restart the daemon from the Settings page[/+]test: a boolean, string, enum and json row is edited and saved as its…
feat(console): the setting dialog has a field for each kind of setting (
test: a number or json that does not parse is refused in the dialog a…
feat(console): the dialog says why a typed value cannot be saved (#1156)
test: a refusal shows the daemon's message, a lost connection says it…
test: Use default on an inFile row sends null and is absent on another (
feat(console): Use default sends null for a row the file holds (#1156)
test: a secret's field starts empty and an empty one cannot be saved (#…
feat(console): an empty secret cannot be saved (#1156)
6 remaining items
feat(console): the page says where the console will be while an http.…
test: Restart daemon asks first, restarts the daemon once, shows a re…
feat(console): Restart daemon restarts the daemon while a saved chang…
test: config.changed marks the settings read stale (#1156)
feat(console): config.changed marks the settings read stale, and the …
test: the setting dialog and the confirm over it pass the browser che…
docs(console): the Settings page's Daemon card edits and restarts, in…
refactor(console): the settings rows and the stale keys are built in …
docs(console): the console manual keeps to its size (#1156)
test(console): the rows test covers a pending and a not-set secret, a…
test(console): a Retry left from a refused setting save sends nothing…
fix(console): a removed saved setting opens an empty field, and a wri…
test(console): a config.changed after a setting save shows the daemon…
docs(adr): 0099 to Accepted (#1156)