Skip to content

feat(admin): add settings editor tab to admin dashboard#706

Open
Ferryx349 wants to merge 9 commits into
cameri:mainfrom
Ferryx349:settings-UI
Open

feat(admin): add settings editor tab to admin dashboard#706
Ferryx349 wants to merge 9 commits into
cameri:mainfrom
Ferryx349:settings-UI

Conversation

@Ferryx349

Copy link
Copy Markdown
Collaborator

Description

This PR adds a Settings tab to the admin dashboard so relay operators can review and edit configuration from the browser instead of only via CLI.

  • Category-based guided editor driven by the settings schema
  • Stage edits locally, preview a diff before saving, then apply or discard
  • Validate all settings before apply
  • Restore from backup and reload current config
  • Sensitive values are redacted in API responses and diff preview

Test plan

  • Log into the admin dashboard and open the Settings tab
  • Edit a setting in a category and confirm the diff preview updates
  • Run Validate all on valid and invalid values
  • Apply staged changes and confirm settings.yaml updates
  • Discard changes and confirm staged edits are cleared
  • Restore backup from a previous save
  • Confirm secrets are not shown in the UI diff preview

Related Issue

Fixes- #665

Screenshots (if appropriate):

Settings-ui.mov

This is how final UI looks.

IMAGE 2026-07-22 12:01:03

Types of changes

  • Non-functional change (docs, style, minor refactor)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my code changes.
  • I added a changeset, or this is docs-only and I added an empty changeset.
  • All new and existing tests passed.

Ferryx349 added 8 commits July 8, 2026 11:57
Signed-off-by: ABHAY PANDEY <pandeyabhay967@gmail.com>
Signed-off-by: ABHAY PANDEY <pandeyabhay967@gmail.com>
Signed-off-by: ABHAY PANDEY <pandeyabhay967@gmail.com>
… backups

Signed-off-by: ABHAY PANDEY <pandeyabhay967@gmail.com>
Reconcile merged UI-DASH and Settings PRs with the settings editor branch:
keep settings editor/backup APIs, adopt upstream Grafana port 7777, fail-closed
rate limiting, admin-health warnings, and Settings review refactors.
@changeset-bot

changeset-bot Bot commented Jul 22, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 6c94844

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
nostream Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Comment thread src/routes/admin/index.ts
adminRateLimitMiddleware,
adminAuthMiddleware,
withAdminController(createGetAdminSettingsSchemaController),
)
Comment thread src/routes/admin/index.ts
// codeql[js/missing-rate-limiting] - adminRateLimitMiddleware applies Redis-backed admin rate limits
router.post(
'/settings/validate',
adminRateLimitMiddleware,
Comment thread src/routes/admin/index.ts
adminRateLimitMiddleware,
adminAuthMiddleware,
json(),
withAdminController(createPostAdminSettingsRestoreController),
Comment thread src/routes/admin/index.ts Outdated
@Ferryx349

Copy link
Copy Markdown
Collaborator Author

This PR is on the top of #690

@coveralls

coveralls commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Coverage Status

coverage: 69.694% (+1.0%) from 68.718% — Ferryx349:settings-UI into cameri:main

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a browser-based settings editor to the admin dashboard, backed by new authenticated admin settings endpoints. This extends the existing admin console beyond metrics/health by enabling operators to view merged config, stage edits, validate, apply updates atomically with backups, and restore prior versions.

Changes:

  • Added admin settings API endpoints (get settings, schema, validate, patch/apply changes, list backups, restore) with audit logging and atomic writes + backups.
  • Introduced settings redaction utilities and expanded the guided settings schema/categories exposed to the dashboard UI.
  • Added the Settings tab UI (HTML/CSS/JS) with category-driven editor, staged diff preview, validation, apply/discard, reload, and restore flows, plus new unit tests.

Reviewed changes

Copilot reviewed 27 out of 27 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/unit/utils/settings-redaction.spec.ts Unit tests for secret/path redaction utilities.
test/unit/utils/settings-config.spec.ts Aligns imports for settings-config test coverage.
test/unit/routes/admin-settings.spec.ts End-to-end unit tests for the new admin settings API routes (auth, patch, validate, backups/restore).
test/unit/app/maintenance-worker.spec.ts Updates maintenance worker tests to stub new telemetry shutdown behavior.
src/utils/settings.ts Adjusts settings file watching to watch the config directory for settings changes.
src/utils/settings-redaction.ts Adds utilities to redact sensitive settings values and paths.
src/utils/settings-guided-schema.ts Expands/adjusts guided schema categories and exposed editable settings.
src/utils/settings-config.ts Adds backups + audit log support, atomic save, backup restore/listing, and schema validation tweaks.
src/schemas/admin-settings-schema.ts Adds zod schemas for admin settings patch/restore request bodies.
src/routes/admin/index.ts Registers new authenticated admin settings routes in the admin router.
src/factories/controllers/post-admin-settings-validate-controller-factory.ts Factory wiring for validate controller.
src/factories/controllers/post-admin-settings-restore-controller-factory.ts Factory wiring for restore controller.
src/factories/controllers/patch-admin-settings-controller-factory.ts Factory wiring for patch controller.
src/factories/controllers/get-admin-settings-schema-controller-factory.ts Factory wiring for schema controller.
src/factories/controllers/get-admin-settings-controller-factory.ts Factory wiring for settings controller.
src/factories/controllers/get-admin-settings-backups-controller-factory.ts Factory wiring for backups controller.
src/controllers/admin/post-settings-validate-controller.ts Implements “validate merged settings” endpoint.
src/controllers/admin/post-settings-restore-controller.ts Implements restore-from-backup endpoint + audit entry.
src/controllers/admin/patch-settings-controller.ts Implements validated patch/apply flow + audit logging + redacted responses.
src/controllers/admin/get-settings-schema-controller.ts Serves guided schema for UI editor.
src/controllers/admin/get-settings-controller.ts Serves merged settings with secret redaction.
src/controllers/admin/get-settings-backups-controller.ts Serves settings backup listing for restore UI.
resources/admin/dashboard.html Adds Settings tab markup and UI layout containers.
resources/admin/assets/dashboard.js Implements settings editor UX: load schema/settings, stage changes, diff preview, apply/discard/restore/reload, and validate-all.
resources/admin/assets/dashboard.css Styles settings editor layout, diff preview, and toolbar controls.
.changeset/admin-settings-ui.md Changeset for UI feature release notes.
.changeset/admin-settings-api.md Changeset for API feature release notes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +7 to +9
public async handleRequest(_request: Request, response: Response): Promise<void> {
response.status(200).setHeader('content-type', 'application/json').send({ categories: guidedSettingCategories })
}
Comment on lines +651 to +670
const validateFieldInput = (field, rawValue) => {
if (field.type === 'number') {
const trimmed = String(rawValue).trim()
if (!trimmed) {
return 'Value is required'
}

if (!/^-?\d+(\.\d+)?$/.test(trimmed)) {
return 'Enter a valid number'
}
}

if (field.type === 'string' || field.type === 'select') {
if (!String(rawValue).trim()) {
return 'Value is required'
}
}

return undefined
}
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.

5 participants