qf-jonathan opened a new pull request, #37488:
URL: https://github.com/apache/superset/pull/37488

   ### SUMMARY
   Implements undo/redo functionality for the Explore view, allowing users to 
undo and redo chart configuration changes with keyboard shortcuts and UI 
buttons.
   
   **Key Changes:**
   - **New undoable reducer**: Wrapped the explore reducer with `redux-undo` to 
track chart configuration changes
   - **Smart undo/redo actions**: Automatically detects whether changes are 
visual-only (renderTrigger: true) or data changes, and handles chart updates 
accordingly:
     - Visual changes (colors, labels, etc.) → Auto-trigger re-render on 
undo/redo
     - Data changes (metrics, filters, etc.) → Show chart as "stale" after 
undo/redo, requiring user to click "Update Chart"
   - **UI components**: Added undo/redo buttons to ExploreChartHeader with 
keyboard shortcuts (Ctrl+Z/Cmd+Z for undo, Ctrl+Y/Cmd+Y for redo)
   - **Type safety**: Updated TypeScript types to reflect the new redux-undo 
state structure (past/present/future)
   - **Selector updates**: Updated all selectors throughout the explore 
codebase to access `state.explore.present` instead of `state.explore`
   
   **Files Created:**
   - `superset-frontend/src/explore/reducers/undoableExploreReducer.js`
   
   **Files Modified:**
   - `superset-frontend/src/explore/actions/exploreActions.ts` - Added 
undo/redo action creators
   - `superset-frontend/src/views/store.ts` - Use undoable reducer
   - `superset-frontend/src/explore/components/ExploreChartHeader/index.jsx` - 
Added undo/redo UI
   - `superset-frontend/src/explore/types.ts` - Updated type definitions
   - Multiple selector files to use `.present` accessor
   
   **Design Decisions:**
   - Followed the same pattern as dashboard's undoable layout reducer for 
consistency
   - Implemented workaround for redux-undo filter bug by filtering at reducer 
level
   - Limited undo history to 50 actions (same as dashboard)
   - Only tracks user-initiated configuration changes, not API calls or side 
effects
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   **Before:** No undo/redo functionality in Explore view
   
   **After:** 
   - Undo/Redo buttons appear in the chart header next to the Save button
   - Buttons are disabled when no history is available
   - Keyboard shortcuts work (Ctrl+Z/Cmd+Z for undo, Ctrl+Y/Cmd+Y for redo)
   
   ### TESTING INSTRUCTIONS
   1. **Test visual-only changes (should update instantly on undo/redo):**
      - Open any chart in Explore view
      - Change a visual property (e.g., color scheme, chart title, label 
formatting)
      - Click Undo button or press Ctrl+Z → Chart should revert instantly
      - Click Redo button or press Ctrl+Y → Change should reapply instantly
   
   2. **Test data changes (should require "Update Chart" click):**
      - Change a data property (e.g., add/remove metric, change filter)
      - Click "Update Chart" to see new data
      - Click Undo button → Chart should show "stale" indicator
      - Click "Update Chart" → Should see reverted data
      - Click Redo button → Chart should show "stale" indicator again
   
   3. **Test keyboard shortcuts:**
      - Verify Ctrl+Z (Cmd+Z on Mac) triggers undo
      - Verify Ctrl+Y (Cmd+Y on Mac) triggers redo
   
   4. **Test button states:**
      - Verify Undo button is disabled when there's no undo history
      - Verify Redo button is disabled when there's no redo history
      - Make several changes and verify you can undo/redo through the history
   
   5. **Test mixed changes:**
      - Make a sequence of both visual and data changes
      - Verify undo/redo works correctly for each type
   
   ### ADDITIONAL INFORMATION
   - [x] Changes UI
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Includes DB Migration
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to