Skip to content

Comments

feat(dashboard): add version history with one-click restore#37697

Draft
JCelento wants to merge 29 commits intoapache:masterfrom
JCelento:feature/dashboard-version-history
Draft

feat(dashboard): add version history with one-click restore#37697
JCelento wants to merge 29 commits intoapache:masterfrom
JCelento:feature/dashboard-version-history

Conversation

@JCelento
Copy link
Contributor

@JCelento JCelento commented Feb 5, 2026

SUMMARY

Adds dashboard version history: a snapshot is created on each save, and users can list versions and restore any one with a single click. Restore updates layout and metadata, syncs chart–dashboard links, and removes orphaned chart components; the UI refreshes without a full page reload.

Backend: New dashboard_versions table and DashboardVersion model; DashboardVersionDAO (create, list, retention); snapshot-after-save in UpdateDashboardCommand; RestoreDashboardVersionCommand; API endpoints GET .../versions, PUT .../versions/<id> (description), POST .../restore/<version_id>.

Frontend: History button in dashboard Header (edit mode); HistoryModal to list versions (number, comment, author, date) and restore with confirmation; optional version description editing; restore triggers re-hydration via dashboardRestoreKey (no full reload). Includes a fix for the hydration effect dependency array so it does not re-run in a loop when dashboard/charts refs change.

Design and scope are documented in 0001-dashboard-version-history.md.

DEMO VIDEO OF THE FEATURE

dashboard versioning demo

TESTING INSTRUCTIONS

  1. Open a dashboard in edit mode and save at least once.
  2. Click the History button in the header and confirm the version list appears (version number, comment if set, author, date).
  3. Restore an older version: click Restore, confirm; the dashboard should update to that version without a full page reload.
  4. Optionally, on save, add a version description in the modal and confirm; verify that it was persisted.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • 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

@github-actions github-actions bot added risk:db-migration PRs that require a DB migration api Related to the REST API doc Namespace | Anything related to documentation and removed doc Namespace | Anything related to documentation labels Feb 5, 2026
@netlify
Copy link

netlify bot commented Feb 5, 2026

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit d0926bd
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6984cd8f1c09cb0008817aa3
😎 Deploy Preview https://deploy-preview-37697--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented Feb 5, 2026

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 9c6c5bf
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6984cefb6d4278000824084a
😎 Deploy Preview https://deploy-preview-37697--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented Feb 5, 2026

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 05d4aca
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/698ce3dd0b5fca0008935c6c
😎 Deploy Preview https://deploy-preview-37697--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov
Copy link

codecov bot commented Feb 5, 2026

Codecov Report

❌ Patch coverage is 82.25256% with 52 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.58%. Comparing base (69c679b) to head (f7faeac).
⚠️ Report is 17 commits behind head on master.

Files with missing lines Patch % Lines
superset/migrations/shared/security_converge.py 8.10% 34 Missing ⚠️
superset/dashboards/api.py 81.08% 13 Missing and 1 partial ⚠️
superset/commands/dashboard/restore_version.py 97.70% 0 Missing and 2 partials ⚠️
superset/commands/dashboard/update.py 86.66% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master   #37697       +/-   ##
===========================================
+ Coverage        0   66.58%   +66.58%     
===========================================
  Files           0      671      +671     
  Lines           0    51556    +51556     
  Branches        0     5808     +5808     
===========================================
+ Hits            0    34328    +34328     
- Misses          0    15840    +15840     
- Partials        0     1388     +1388     
Flag Coverage Δ
hive 41.48% <37.54%> (?)
mysql 64.69% <81.91%> (?)
postgres 64.77% <81.91%> (?)
presto 41.50% <37.54%> (?)
python 66.55% <82.25%> (?)
sqlite 64.36% <81.91%> (?)
unit 100.00% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions github-actions bot added the doc Namespace | Anything related to documentation label Feb 5, 2026
- Snapshot dashboard position_json and json_metadata on each manual save
- Add dashboard_versions model, migration, and DashboardVersionDAO
- Add GET /api/v1/dashboard/<id>/versions and POST .../restore/<version_id>
- Add History button and HistoryModal in dashboard editor (version list, one-click restore)
- Retain last 20 versions per dashboard; RestoreDashboardVersionCommand with ownership check
- Handle restore errors in HistoryModal (toast string, throw Error not Response)
- Add integration tests for version restore with chart add/remove
… handling

- Restore: avoid ORM/raw conflict on dashboard_slices; expire slices after sync.
- Model: cascade delete-orphan on Dashboard.versions (fix NOT NULL on delete).
- API: generic "Restore failed" + server log; add versioning integration tests.
- Add @transaction to update_version API; remove manual commit
- Fix unit tests: use test_request_context for g.user, valid layout for snapshot test
- Snapshot on manual save, list versions, restore with confirm
- Optional version description in Save modal; read-only in History modal
- History button in view mode for consistency after restore
- Card layout, theme tokens, and tooltip for Dashboard history
- Add DashboardRestoreContext and refreshKey to refetch dashboard/charts
  after restore; re-hydrate in DashboardPage
- HistoryModal: only reload when onRestore is not provided
- HistoryModal: abort-safe fetch, getErrorMessage helper, aria-expanded
- Header: useModalState for modals, pass onRestore from context
- Add HistoryModal unit tests, Header History test, restore integration test
- Keep service-worker.js hand-maintained; add .gitignore note
- Use single migration for dashboard_versions.description (drop rename step)
- Make DASHBOARD_VERSION_RETENTION configurable via config (default 20)
- Add limit to get_versions_for_dashboard (default = retention) in API/DAO
- Add unique constraint (dashboard_id, version_number); handle IntegrityError on snapshot
- Map get_versions/update_version/restore_version in MODEL_API_RW_METHOD_PERMISSION_MAP
- Restore endpoint returns version_number_restored and chart_ids; document @with_dashboard choice
- Migration 2026_02_06: create can_get_versions, can_restore_version,
  can_update_version for Dashboard; grant to roles with can_read/can_write
- security_converge: add grant_pvms_to_roles_that_have (additive grant)
  and revoke_pvms (revoke and delete PVMs) for use in migrations
…t tests

- Move dashboard version unit test from commands/ to dashboards/test_dashboard_version.py
- Add DashboardVersionDAO unit tests in dao_tests.py (session fixture, same pattern as chart customizations)
- DB-dependent coverage remains in integration test_dashboard_version_commands.py
…tests

Use @pytest.mark.usefixtures(admin_has_dashboard_version_permissions)
instead of fixture parameters so tests work with unittest-style TestCase
and match the pattern used by other fixtures in dashboards api_tests.
@JCelento JCelento force-pushed the feature/dashboard-version-history branch from 9a8e016 to 0d69da3 Compare February 11, 2026 15:24
@github-actions github-actions bot removed the doc Namespace | Anything related to documentation label Feb 11, 2026
@Vitor-Avila
Copy link
Contributor

this is awesome!!! 😍

@LuisSanchez
Copy link
Contributor

Excellent work 👏

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 review:draft risk:db-migration PRs that require a DB migration size/XXL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants