Skip to content

Settings and user preferences of an application #3443

Todo

Description

@rubenvdlinde

Is your feature request related to a problem? Please describe.

  • An application often needs a few values of its own, such as a default view or a contact address, and users want to keep their own choices, such as a collapsed menu.
Why this is needed
  • The managers of an application need a few values of its own, such as a default view or a contact address, and its users want their own choices kept, such as a collapsed menu. Today Tables has its own settings and a config per table and view (api/2/config), but an application has none.
  • buildiq parity: adminSettings, settings pages and personalisation in the manifest, backed by OpenRegister's /api/settings and /api/preferences/{key} (sections 1 and 7 of the feature comparison).
  • The settings page type (Settings page type of an application #3449) builds its form from this schema, and the manifest export (Export an application as a manifest on api/2 #3450) carries the settings. The plan puts "settings and permission fields (sprint 4) before the designer editors (sprint 5)".

Describe the solution you'd like

  • api/2 endpoints for settings of an application, set by its managers, and preferences per user per application.
Diagram
sequenceDiagram
    actor M as Manager
    actor U as Member
    participant API as New application settings API
    participant S as New settings service
    participant DB as Database
    M->>API: PUT settings of the application
    API->>S: is the user a manager of the application?
    S->>S: validate against the declared schema
    S->>DB: store per application
    U->>API: GET settings
    API->>S: is the user a member?
    S-->>U: values, read only
    U->>API: PUT own preference
    API->>S: can the user open the application?
    S->>DB: store per user per application
Loading
Acceptance Criteria
  • Settings: read by every member, written by managers only.
  • Preferences: read and written by the user only, for applications they can open.
  • Values are validated against a schema declared per application.
  • Export and import carry the settings, not the preferences.
  • Unit tests for the permissions.
  • Writing settings: the route declares its permission with #[RequirePermission] (manage on the application) using a fixed node type (context), and the service checks the same right before it writes (as agreed on UUIDs for rows #3093 and in the review of feat(contexts): give applications a menu with its own API #3135). A test runs every write as a reader and expects 403, or 404 where the reader may not know the object exists. Writing a preference needs read on the application, checked the same way.
  • Values are stored as JSON in a text column, one record per application, never in the database JSON column type (as agreed on Grid pages in applications (frontend) #3099). The declared schema is stored the same way.
  • Migration: a new table with a unique index on the application id; no empty-string defaults, since Oracle stores '' as NULL (as raised on Technical name for tables and applications, CRUD routes by application and table #3094); the version in appinfo/info.xml is bumped with the migration (as raised on feat(rows): add persistent UUIDv7 identifiers to rows #3229).
  • Deleting an application deletes its settings and its users' preferences in the same transaction. Deleting a user removes their preferences.
Out of scope
  • The settings page: Settings page type of an application #3449.
  • Tables' own settings and the existing config per table and view (api/2/config).
  • Proposed slicing, one PR each in landing order: settings with their schema, then preferences.

Describe alternatives you've considered

Questions for maintainers

  1. Where the schema of an application's settings lives: a JSON Schema stored with the application and edited in the designer, or a fixed list of setting kinds? We would go with a JSON Schema, because the manifest export carries it and the settings page builds its form from it.
  2. Preferences: the server's user preferences (app tables, one key per application), or a table of our own? We would go with the server's user preferences, because user deletion and the user migrator already handle them, so only settings need a new table.

Additional context

Linking to other objects
Relevant files:
Related issues

Drafted with AI assistance from the project plan; @rjzondervan reviews it. Part of #3419.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions