Skip to content

Add the FOG 1.6 FOG Configuration settings page - #204

Merged
mastacontrola merged 2 commits into
masterfrom
factory/issue-199
Nov 17, 2026
Merged

mastacontrola merged 2 commits into
masterfrom
factory/issue-199

Conversation

@mastacontrola

Copy link
Copy Markdown
Member

I built the FOG Settings page at /about/settings, with its save route and its tests, and committed it on factory/issue-199 as 4c2aa90. npm test, npm run test:ui and npm run test:ui:prod all pass on the final code. Both reviewers (opus) are clean after two rounds.

What changed

  • The page. GET /about/settings (api/controllers/pages/settings.js, views/pages/settings.ejs) shows the settings catalog (config/fog-settings.js) in the 1.6 layout:
    • one "FOG Settings" card, with #settings-search and #settings-search-clear in its header;
    • a nav-pills category list with count badges, sorted naturally without case;
    • one panel per category.
    • Each value comes from sails.helpers.settings.get. A Setting record that is not a catalog key, such as schema, never shows.
    • The page answers 403 without setting.read. Without setting.update, every control is disabled.
    • A valid stored value that is not one of the options (FOG_VIEW_DEFAULT_SCREEN = 30) shows as one more option, selected.
    • A catalog type the page cannot render answers 500. The log line names the key and the type.
    • The section header is "FOG Configuration", as in 1.6.
  • The client script (views/pages/partials/settings.js, inlined through partialname):
    • The search filters live, and ?search= pre-fills it. A category click clears the search. Below 768px, a panel title toggles its panel.
    • A change saves on its own through $.ajax. A good save shows the success toast, plus a "Reload required" toast for a reload row. A failed save puts the select back to its stored value and shows an error toast.
  • The save route. POST /api/v1/setting/save (api/controllers/setting/save.js) has the policies isLoggedIn, isAuthenticated and apiCsrfGuard, and checks setting.update itself.
    • A key that is not in the catalog answers 400 Unknown setting: <key>. The check uses own keys only, so constructor and schema are refused too.
    • A value that normalize() rejects answers 400 <key> value is not valid.
    • Otherwise it updates or creates the record with the normalized value and answers 202 with the 1.6 body. req.audit names the setting.
  • The menu. A "FOG Configuration" leaf (fas fa-wrench, order 150) now sits after iPXE Menu. Both pinned menu lists have the new entry. menu.test.js also checks that the leaf is active on /about/settings.
  • The tests. test/integration/settings-page.test.js is new and covers 16 cases. tools/smoke/checks/fog-settings.js is new. /about/settings is now in PAGES.

Why, and where it differs from 1.6

The issue asks for a validated settings page. Until now the only way to change a setting was a raw POST /api/v1/setting, which checks nothing. These choices differ from the 1.6 markup or from the spec's file list:

  • Search fields. Each row carries data-key and data-description instead of 1.6's single data-search string. The script matches each field on its own, as the spec words it, and reads the value from the live control. So a saved value matches without a page reload; 1.6 reloads the page body after each save. One difference: a term that spans two fields (for example "mode this") matched in 1.6 and does not match here.
  • Active highlight. The nav <a> also gets the Bootstrap 5 nav-link active classes, so the active category shows as a pill. The 1.6 li.active stays, so the existing CSS still applies.
  • Value types. Only a string or a number reaches normalize(). A crafted body such as {"value":{"toString":1}} used to answer 500. It now answers 400. An array or a boolean value is now refused too.
  • Category click. A click now also clears the hidden state that a search left on the panels. In 1.6, a click after a search with no match showed an empty page.
  • Extra test file. tools/smoke/checks/ui16-03-shell.js gained a header row. That check fails on any PAGES entry that has no row.
  • Reload toast text. The toast uses the spec's text. It leaves out 1.6's extra sentence about a hard refresh.

Tests

$ npm test
Your .js files look good.
  508 passing (38s)          # base commit: 492
Done.

$ npm run test:ui
ok    /about/settings
ok    fog-settings: FOG 1.6 FOG Settings page
All UI checks passed.

$ npm run test:ui:prod
ok    /about/settings
ok    fog-settings: FOG 1.6 FOG Settings page
All UI checks passed.

The new mocha file fails on the base commit: 14 of its first 14 cases answer 404.

Each gate also failed its test when I put its defect back in a scratch copy:

Defect put back Test that went red
No apiCsrfGuard on the save route No X-Requested-With → 403
No setting.update check Reader user → 403
in instead of Object.hasOwn Unknown key (constructor) → 400
No setting.read gate No-permission user → 403
canUpdate always true Every control disabled for a reader
No normalize check sideways → 400
No value type guard Crafted body → 400, not 500

The UI runs leave no tracked file changed.

The sandbox cannot reach GitHub, and one dependency (sails-mongo) comes from GitHub, so npm ci failed here. I used a copy of the local node_modules instead. Five packages in it were older than the lockfile, so I replaced them with the exact lockfile versions from npm and checked each against the lockfile's integrity hash. CI runs npm ci as usual.

Reviews

The models: Opus 5.5 planned and implemented the change. spec-reviewer and standards-reviewer both ran on opus, because the tier is critical.

  • Standards, round 1: FINDINGS 3. All fixed.
    • (hard) A crafted body made the save answer 500. I added the type guard and a regression test.
    • (judgment) canUpdate now uses audit.can.
    • (judgment) The reload flag is now a data-reload attribute, not a test for the icon class.
  • Standards, round 2: FINDINGS 1. Fixed. The fixes were verified with nothing new. The one finding was a routes comment that said the save route "must precede" the :model routes. No :model route can match it, so I corrected the comment.
  • Spec: FINDINGS 1, no code change needed. Every Behavior bullet and every server-side criterion is met. The one open item was the six browser criteria, which only the UI runs can show. Both UI runs pass on the final code.

Holdout scenarios: none for this repo.
Tier: critical (opus, effort xhigh).

Closes #199

🤖 Generated with Claude Code

mastacontrola and others added 2 commits November 17, 2026 06:58
GET /about/settings renders the settings catalog (config/fog-settings.js)
as the 1.6 FOG Settings page: one card, a live search box, a category
nav and one panel per category, with each row's value from
sails.helpers.settings.get. A Setting record that is not a catalog key,
such as schema, never shows. The page answers 403 without setting.read
and disables every control without setting.update. A stored value that
is not an option (FOG_VIEW_DEFAULT_SCREEN = 30) shows as one more,
selected option. A catalog type the page cannot render answers 500 and
logs the key and the type.

Each control saves on change through POST /api/v1/setting/save
(setting.update, apiCsrfGuard). A key not in the catalog, or a value
that normalize() rejects, answers 400 with the 1.6 body and stores
nothing. Only a string or a number reaches normalize(), so a crafted
JSON body gets a 400, not a 500. A good save stores the normalized value
and answers 202 with the 1.6 body. req.audit names the setting.

The sidebar gets the 1.6 "FOG Configuration" leaf (order 150, after
iPXE Menu). The two pinned menu lists and the ui16-03 header table
gain the new entry.

Tests: test/integration/settings-page.test.js (fails on the base: the
route did not exist) and the UI check tools/smoke/checks/fog-settings.js.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#203 (the Audit Log page) added the Logging group at the same menu and
smoke-table positions as this branch's FOG Configuration entry. Keep both,
FOG Configuration (150) before Logging (170).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mastacontrola
mastacontrola added this pull request to the merge queue Nov 17, 2026
Merged via the queue into master with commit 7eab7e7 Nov 17, 2026
5 checks passed
@mastacontrola
mastacontrola deleted the factory/issue-199 branch November 17, 2026 14:01
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.

Add the FOG 1.6 FOG Configuration settings page

1 participant