feat(dashboard): add version history with one-click restore#37697
Draft
JCelento wants to merge 29 commits intoapache:masterfrom
Draft
feat(dashboard): add version history with one-click restore#37697JCelento wants to merge 29 commits intoapache:masterfrom
JCelento wants to merge 29 commits intoapache:masterfrom
Conversation
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report❌ Patch coverage is 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- 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
…r from repository
- 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.
9a8e016 to
0d69da3
Compare
… overwrite save payload
Contributor
|
this is awesome!!! 😍 |
Contributor
|
Excellent work 👏 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_versionstable andDashboardVersionmodel;DashboardVersionDAO(create, list, retention); snapshot-after-save inUpdateDashboardCommand;RestoreDashboardVersionCommand; API endpointsGET .../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
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION