Skip to content

Settings form engine in Storybook (1 of 2 for #147) - #165

Merged
sgomez merged 1 commit into
frontend-rebuildfrom
agent/frontend/147
Nov 25, 2026
Merged

sgomez merged 1 commit into
frontend-rebuildfrom
agent/frontend/147

Conversation

@sgomez

@sgomez sgomez commented Nov 25, 2026

Copy link
Copy Markdown
Owner

Part of #147 (1 of 2: the form engine and its stories; the Settings/PHP switch on the edit page follows). Part of #135.

Summary

The schema-driven Settings form of SPEC 10.10, generic over every schema in docs/spec/schemas, in a new forms slice. It reads the schemas through what npm run generate writes; the browser compiles nothing.

frontend/
├── build/generate.mjs          + generated/forms.ts: each document schema with $ref resolved and only what the
│                                 form reads (title, description, default, examples, enum, x-widget, x-when,
│                                 x-sensitive, x-literal, x-authsource-reference, required, if/then/else and
│                                 dependentRequired as `rules`, x-groups). An unknown x-widget fails the build.
├── lint/layers.js              + forms: ['documents']
└── src/
    ├── domain/documents/       form.ts (FormNode, FormSchema); index exports `forms`
    ├── domain/forms/           new slice
    │   ├── engine/             pure logic, unit-tested
    │   │   ├── presence.ts     isSet = key exists; applies (x-when); requiredIn (required + rules);
    │   │   │                   groupsOf → per group: rendered, addable, "N of M set"
    │   │   ├── values.ts       initial values (boolean opposite its default, default never written),
    │   │   │                   add/unset, list rows (add/remove/move/set), map rows (rename in place)
    │   │   ├── controls.ts     SPEC 10.10 control table, x-widget allowlist
    │   │   ├── finder.ts       every root option but `extra`; one that does not apply is disabled with why
    │   │   └── issues.ts       issues per pointer and group, Secret references, hint (default, else example)
    │   ├── SettingsForm.tsx    finder, groups, "On this page" index; schema errors at once (compiled
    │   │                       validators) merged with the server's issues (validate route, rejected save)
    │   └── controls/           text, suggest, textarea, select/radio, switch, number, secret, authsource
    │                           select, nested fields, rows, language map rows, JSON text, certificate card
    ├── design-system/          + AddButton, Collapsible, PageIndex, SearchPick (React Aria ComboBox, "/" focuses it);
    │                           Input number/suggestions, Select empty choice, Radios hidden label, MenuButton icon
    └── app/adapters/memory/forms.ts   board fixtures and capabilities

Capability-gated (only what the port offers shows): Reveal of a sensitive literal, the authsource select (x-authsource-reference), secrets_dir completion, and the certificate facts card (subject, expiry, Replace). Without them: a password field, a text field, no completion, the PEM field.

Not routed: nothing in app or pages uses the slice yet, so production is unchanged. The edit page gets the switch in the second PR.

Stories (no screenshots: domain components):

  • Domain/Forms/Settings form: Service provider (FormServiceProvider), Authsource saml:SP after a rejected save (Form), Authsource multiauth:MultiAuth (FormMultiAuth)
  • Domain/Forms/Settings form, drafts: Draft: New service provider, Draft: Finding an option, Draft: Conditional options, Draft: Sensitive value, Draft: Without the server's lists, Draft: Uncataloged options
  • Design system/Collapsible, Design system/Search pick, and new variants of Input, Select, Radios, Menu

Evidence

  • Engine unit tests (jsdom), 64 in domain/forms: presence by key, required by root list, by if branch and by dependentRequired, x-when hiding a set option and dropping it from the count, booleans opposite their default, no default written, nested empty optional field absent, rows add/remove/move, map rename, finder with disabled reason and without extra, control table, Secret references, issues per group and in the index, focus moved to an added option, "and N more".
  • npm test: 704 passed, lines 98.99 %. Lint, type check, composer size, composer static, composer test (607) are clean. composer build is committed. No PHP changed; no page screenshot changed.

Board differences

  • No page around the form yet. The boards show the form in the edit screen with the PHP aside; that arrives with the switch (second PR). The form takes an aside slot for it.
  • Groups and options follow the schemas. The boards' group names and options (Basics, certData, acs.Bindings…) predate the schemas; the form renders the schema's x-groups and options.
  • List rows of objects render all their fields (SPEC 10.10). FormMultiAuth shows each source as one field; here each row has Authsource, Button text, Help text, CSS class and Authentication context classes. Rows whose fields are all single-line sit on one line with placeholders (endpoints: Binding, Location, Index, Default).
  • Grip on single rows. The board shows the move handle on every row; here it shows only when there is more than one row, and opens a menu (Move up / Move down) so that it works with the keyboard.
  • preselect of MultiAuth is a text field, not the board's select: SPEC 10.10 makes a value taken from the same document a plain text field.
  • "Found on this node" beside a private key file is not shown: the node check of SPEC 7.5 comes from the validate route as a warning.
  • The board's PHP aside has syntax colours; not built here.

Merge Danger

Door: two-way

Blast Radius: none in production; Storybook and the generated forms.ts only.

@sgomez
sgomez merged commit 423859a into frontend-rebuild Nov 25, 2026
16 checks passed
@sgomez
sgomez deleted the agent/frontend/147 branch November 25, 2026 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant