Skip to content

feat(themes): add per-theme editors (Subject model)#42404

Draft
yousoph wants to merge 2 commits into
apache:masterfrom
preset-io:theme-editors-subject-model
Draft

feat(themes): add per-theme editors (Subject model)#42404
yousoph wants to merge 2 commits into
apache:masterfrom
preset-io:theme-editors-subject-model

Conversation

@yousoph

@yousoph yousoph commented Jul 24, 2026

Copy link
Copy Markdown
Member

SUMMARY

Extends the Subject model / entity editors introduced in #38831 to Themes. Themes previously had no ownership concept and were editable only by admins. This PR adds a per-theme editors list (Subjects) so edit access can be scoped per theme instead of all-or-nothing, following the same editors-only pattern already used by alerts/reports (no viewers for themes).

Key behaviors:

  • A new theme_editors junction table and a Theme.editors relationship (mirrors report_schedule_editors).
  • Theme creation is routed through a new CreateThemeCommand; the creating user is automatically added as an editor.
  • PUT/DELETE/bulk-delete now enforce raise_for_editorship on the theme (admins always pass). System themes and the system default/dark themes keep their existing admin-only protections.
  • Editorship is checked on import overwrite.
  • REST API exposes editors (create/update schemas + list/show columns) and a /api/v1/theme/related/editors endpoint, with a new optional SUBJECTS_RELATED_TYPES_THEMES config to control which subject types appear in the picker (falls back to the global default).
  • Frontend: themes list shows an editors pile and swaps its row action to a read-only view for non-editors; the theme modal gains an editors picker and is read-only for non-editors/system themes.

Backwards compatibility: no feature flag and no data backfill — existing themes have no editors, which means only admins can edit them (unchanged behavior). Theme visibility is deliberately unchanged: the list endpoint has no new access filter, so every user who can read themes today still can, and themes applied to a dashboard continue to render for anyone who can view that dashboard.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Themes list gains an "Editors" column; the theme modal gains an "Editors" picker. UI screenshots to follow.

TESTING INSTRUCTIONS

  • superset db upgrade creates the theme_editors table (migration f7e8d9c0b1a2).
  • As a non-admin user with can_write on Theme: create a theme → you are automatically its editor and can edit it; you cannot edit a theme you are not an editor of (403); you cannot add yourself as editor via PUT to gain access.
  • As an admin: full CRUD on any theme; system/default themes remain protected.
  • New tests: tests/integration_tests/themes/test_theme_editors.py, tests/unit_tests/migrations/test_add_theme_editors.py, plus ThemeList/ThemeModal jest tests.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags: none
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

Documents the behavior change in UPDATING.md. Builds on #38831.

🤖 Generated with Claude Code

Introduce per-theme editors so any principal with Theme write can create
themes and only a theme's editors (or an admin) can edit or delete it,
mirroring the ReportSchedule editors-only pattern.

- Add a theme_editors junction table and Theme.editors relationship, with
  a migration that creates the table (no backfill; themes had no owners).
- Route theme creation through a new CreateThemeCommand that auto-adds the
  creator as an editor and prevents self-lockout.
- Gate UpdateThemeCommand/DeleteThemeCommand on editorship (editorship
  checked before applying the editors payload); keep system-theme
  protections.
- Expose editors on the Theme API (schemas, list/show columns, and the
  related/editors picker endpoint) and guard theme import overwrites on
  editorship.
- Add SUBJECTS_RELATED_TYPES_THEMES config for the editor picker.
- Frontend: add an Editors column and editor field to the theme list and
  modal, with a read-only view for non-editors.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@dosubot dosubot Bot added api Related to the REST API authentication:access-control Rlated to access control change:backend Requires changing the backend change:frontend Requires changing the frontend global:theming Related to theming Superset labels Jul 24, 2026
@github-actions github-actions Bot added risk:db-migration PRs that require a DB migration and removed change:backend Requires changing the backend change:frontend Requires changing the frontend authentication:access-control Rlated to access control global:theming Related to theming Superset labels Jul 24, 2026
@bito-code-review

bito-code-review Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Bito Review Skipped - Source Branch Not Found

Bito didn’t review this change because the pull request is no longer valid. It may have been merged, or the source/target branch may no longer exist.

@yousoph
yousoph marked this pull request as draft July 24, 2026 23:36
The Editors field in the theme modal no longer blocks Save and no longer
shows a required asterisk. An empty editors list is valid and simply means
admin-only, matching how charts and dashboards treat their owners/editors.
The backend still auto-adds the creator on an empty list and prevents a
non-admin from removing themselves as the last editor, so no extra
front-end guard is needed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Related to the REST API risk:db-migration PRs that require a DB migration size/XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant