Repository navigation
Add the FOG settings catalog and a settings read helper - #202
Merged
Merged
Conversation
config/fog-settings.js (sails.config.fogSettings) is the one code-side list of the runtime settings: category, description, type, options, default, normalize and reload per key. The database holds only the values an admin changed; fog-node seeds no rows (migrate: 'safe'). sails.helpers.settings.get(key) reads the key's Setting record and returns normalize(value), or the default for a missing record or a bad value. It never creates a record. An unknown key throws "Unknown setting: <key>". The catalog starts with the two table settings, FOG_TABLE_SCROLL_MODE and FOG_VIEW_DEFAULT_SCREEN, with their 1.6 descriptions as plain text and their current reader rules. api/helpers/table-settings.js now reads both through the helper; its output shape is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I added a settings catalog in code and a read helper,
sails.helpers.settings.get(key). The two list-table settings now read through the helper.npm testandnpm run test:uiboth pass. Both reviewers signed off on the final commit.What changed
config/fog-settings.js(new) exportssails.config.fogSettings. Each entry hascategory,description,type,options,default,normalizeandreload.config/local.js. Secrets never go in.schemais never a key.FOG_TABLE_SCROLL_MODEandFOG_VIEW_DEFAULT_SCREEN. Both are in categoryFOG View Settings, withreload: true.normalizekeeps the old reader rule exactly: the same trim, lowercase and/^(-1|[1-9][0-9]*)$/. No stored value changes meaning.schema.phpat98ac5bb732eb, as plain text with the HTML tags removed. Scroll mode uses step 296. Page length uses the repaired text from step 397.api/helpers/settings/get.js(new) readsSetting.findOne({name: key})and returnsnormalize(row.value). A missing record or a bad value gives the default. It never creates a record.Unknown setting: <key>.Object.hasOwn. Without it, a name likeconstructorwould read an inherited property as a setting.api/helpers/table-settings.jscallssails.helpers.settings.getfor both keys. It no longer callssails.models.setting.findOneitself. The output{scrollMode, pageLength}does not change.test/helpers/settings-catalog.test.js(new) checks the following. The test creates and removes its ownSettingrecord.schemais absent.getcases from the spec: no record, a good record, a bad record and an unknown key.constructoris rejected as unknown.These stay unchanged, as the spec requires:
FOG_HOST_IDENTIFY_SMBIOS,FOG_AGENT_ENROLL_DEPLOY_WINDOW,FOG_CLIENT_CHECKIN_TIMEandFOG_ENABLE_SHOW_PASSWORDS.FOG_AGENT_ROOT_FINGERPRINT.Why
Issue #198 asks for one code-side list of the runtime settings. The FOG Configuration page in the next brief renders from this list.
migrate: 'safe'forbids seeding rows, so the database holds only the values an admin changed.Tests
npm test: passed. Lint is clean ("Your .js files look good."). 492 tests pass and none fail. All 8 newSettings catalog::tests pass. The existingtable-settings::tests intest/integration/list-pages.test.jsstill pass.npm run test:ui: passed: "All UI checks passed." That includesok ui16-06: FOG 1.6 list tables, which covers paged mode. The run changed no tracked file.ae0b618. All 8 tests failed, becausesails.config.fogSettingsandsails.helpers.settingsdo not exist there.The sandbox blocks GitHub, so the test setup needed three workarounds:
npm cicould not fetchsails-mongo, which installs from GitHub. I copiednode_modulesfrom a local clone with the same lockfile. Then I replaced the 5 packages that did not match the lockfile versions with tarballs from the npm registry.~/.cache/ms-playwright.Reviewer verdicts
test:uiresult was still missing; that run now passes. It noted that the spec does not ask for theObject.hasOwnguard; I kept the guard as a correctness fix.e32b762: clean. Every acceptance criterion is met, with no regression.|| {}fallback that hid a missing catalog.constructortest now matches the fullUnknown setting: constructormessage.schematest. Theschematest now reads through the localcatalog()helper.e32b762: clean.Holdout scenarios: none for this repo.
Tier: normal (opus, effort high).
Closes #198
🤖 Generated with Claude Code