Skip to content

[codex] Add SPA system settings management#25

Merged
jruszo merged 4 commits intomasterfrom
feature/spa-system-settings
Apr 10, 2026
Merged

[codex] Add SPA system settings management#25
jruszo merged 4 commits intomasterfrom
feature/spa-system-settings

Conversation

@jruszo
Copy link
Copy Markdown
Owner

@jruszo jruszo commented Apr 10, 2026

What changed

This PR adds a new staff/admin-only SPA system settings surface for Datamingle.

It includes:

  • a new /settings/system SPA page with grouped runtime settings sections
  • staff/admin-only API endpoints for loading, updating, and testing system settings
  • sidebar and router updates so staff/superusers can access the page directly
  • Playwright e2e coverage for route protection and a save/reload/settings-test flow

Why it changed

The legacy bootstrap frontend already had a system settings surface, but the SPA did not. This fills that gap so staff/admins can manage Datamingle runtime settings without dropping back to the old UI.

User and developer impact

  • Staff and superusers can manage Datamingle system settings from the SPA.
  • Non-staff users cannot access the route or navigation entry.
  • The backend exposes typed, allowlisted settings APIs instead of relying on the legacy replace-all config update path.
  • The new e2e coverage guards against regressions in permissions and settings persistence.

Root cause

The missing SPA equivalent of the old system settings page left runtime configuration management outside the main app flow. During e2e validation, Playwright also exposed a load-state race where initial settings fetches could overwrite typed values before save. This PR fixes that by keeping controls disabled while the page is loading or saving.

Validation

  • black --check .
  • npm run lint
  • npm run build
  • docker exec datamingle-app python manage.py test sql_api.tests.TestSystemSettings common.tests.CheckTest
  • E2E_START_FRONTEND=1 npm run e2e:test -- tests/e2e/system-settings.spec.ts

Summary by CodeRabbit

  • New Features
    • Added a System Settings management interface accessible to staff and superusers, enabling configuration of system parameters including notification phases, auto-review behavior, storage backends, and communication settings.
    • Introduced connection testing capabilities for system components (Go Inception, email, storage).
    • Settings changes are validated and persisted across sessions.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 10, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

The PR introduces a comprehensive System Settings feature enabling staff/superusers to manage runtime configuration through both backend API endpoints and a frontend UI. Changes include validation refactoring in the check module, new DRF API endpoints with serializers and permission checks, a data-driven frontend schema, a new Settings System view component, E2E tests, and updates to navigation and routing logic.

Changes

Cohort / File(s) Summary
Backend validation refactoring
common/check.py
Extracted validation logic from request handlers into pure functions (validate_go_inception_payload, validate_email_payload, validate_file_storage_payload) that return dicts; added _parse_bool helper for boolean payload interpretation; updated view functions to wrap validation results in HTTP responses.
Backend API endpoints
sql_api/api_settings.py, sql_api/urls.py
Added comprehensive system settings management with SYSTEM_SETTINGS_SCHEMA covering goInception/backup/storage/notification config; implemented load_system_settings/save_system_settings helpers with SysConfig persistence; added SystemSettingsView for GET/PUT operations and three test endpoint views (GoInceptionTestView, EmailTestView, StorageTestView); registered URL routes under v1/system-settings/.
Permission & access control
sql_api/permissions.py
Added IsStaffOrSuperuser permission class to restrict access to authenticated staff or superuser accounts.
Frontend API integration
frontend/src/lib/api.ts
Introduced types (SystemSettings, SystemSettingsValue, SystemSettingsOption, SystemSettingsPayload) and exported functions (fetchSystemSettings, updateSystemSettings) for authenticated GET/PUT; added three POST test helpers (testSystemSettingsGoInception, testSystemSettingsEmail, testSystemSettingsStorage).
Frontend schema & configuration
frontend/src/lib/system-settings.ts
Created data-driven settings schema with systemSettingsSections array defining section/field structure, input types, visibility conditions, and option sources; exported createInitialSystemSettings() to populate default values per field type (checkbox → false, multiselect → [], number → null, other → '').
Frontend UI components & routing
frontend/src/views/SettingsSystemView.vue, frontend/src/router/index.ts, frontend/src/App.vue
Added SettingsSystemView component with form rendering, state tracking, save/reload/test functionality, and unsaved-changes prompts; added /settings/system route with requiresStaffAdmin metadata and access guard; updated App.vue with canSeeRuntimeSettings computed property and Settings menu navigation logic.
Testing infrastructure
sql_api/tests.py, frontend/tests/e2e/system-settings.spec.ts, frontend/tests/e2e/support/workflow-helpers.ts, frontend/playwright.config.ts
Added backend test suite (TestSystemSettings) covering GET/PUT/test endpoints with auth and fixture setup; added E2E suite blocking non-staff users and allowing demo\_admin to save/reload/test settings; updated DemoUser type to include demo_admin; configured Playwright baseURL from env var and screenshot capture for all runs.

Sequence Diagram

sequenceDiagram
    actor User as Staff/Admin User
    participant Client as Frontend (Vue)
    participant API as Django REST API
    participant DB as Database (SysConfig)
    participant Validators as Validation Module

    User->>Client: Navigate to /settings/system
    Client->>API: GET /v1/system-settings/
    API->>DB: load_system_settings()
    DB-->>API: SysConfig values
    API->>API: build_system_settings_options()
    API-->>Client: SystemSettingsPayload (settings + options)
    Client->>Client: Render form with schema-driven fields
    
    User->>Client: Edit field values
    Client->>Client: Update reactive settings state
    
    User->>Client: Click "Save Settings"
    Client->>API: PUT /v1/system-settings/ {settings}
    API->>API: SystemSettingsSerializer.validate()
    API->>DB: save_system_settings(validated)
    DB-->>API: SysConfig updated
    API-->>Client: 200 OK (updated payload)
    Client->>Client: Show "Settings saved" feedback

    User->>Client: Click "Test Storage Connection"
    Client->>API: POST /v1/system-settings/tests/storage/ {payload}
    API->>Validators: validate_file_storage_payload(payload)
    Validators-->>API: dict with validation result
    API-->>Client: 200 OK {detail: "test succeeded"}
    Client->>Client: Show test result feedback
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Poem

🐰 Hops through settings, ears held high,
System configs now can fly!
Schema-driven, clean, and bright,
Staff admins get their settings right!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding a SPA system settings management feature. It directly reflects the primary purpose of the PR without being vague or misleading.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/spa-system-settings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Comment thread common/check.py
# Log detailed error information
logging.error("Storage connectivity test failed")
# logging.error(f"Storage connectivity test failed: {message}")
logging.debug("Storage connectivity test error: %s", message)
Comment thread sql_api/api_settings.py
result = validate_go_inception_payload(serializer.validated_data)
if result["status"] != 0:
return Response(
{"errors": result["msg"]}, status=status.HTTP_400_BAD_REQUEST
Comment thread sql_api/api_settings.py
)
if result["status"] != 0:
return Response(
{"errors": result["msg"]}, status=status.HTTP_400_BAD_REQUEST
Comment thread sql_api/api_settings.py Dismissed
@jruszo jruszo marked this pull request as ready for review April 10, 2026 11:38
@jruszo jruszo merged commit 81524c7 into master Apr 10, 2026
5 of 7 checks passed
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.

2 participants