korbit-ai[bot] commented on code in PR #31809:
URL: https://github.com/apache/superset/pull/31809#discussion_r1912499477
##########
superset-frontend/src/dashboard/actions/dashboardLayout.js:
##########
@@ -267,6 +267,13 @@ export function handleComponentDrop(dropResult) {
};
}
+export function resetDashboardPast() {
+ return (dispatch, getState) => {
+ const { dashboardLayout } = getState();
+ dashboardLayout.past = []; // Set `past` as an empty array
+ };
+}
Review Comment:
### Improper Redux State Mutation <sub></sub>
<details>
<summary>Tell me more</summary>
###### What is the issue?
Direct mutation of the Redux state by directly assigning to
dashboardLayout.past instead of dispatching an action.
###### Why this matters
This will break Redux's state management principles and the undo/redo
functionality won't work correctly because Redux isn't aware of the state
change.
###### Suggested change ∙ *Feature Preview*
Create and dispatch a proper Redux action to reset the past state using
redux-undo's ActionCreators:
```javascript
export function resetDashboardPast() {
return dispatch => {
dispatch(UndoActionCreators.clearHistory());
};
}
```
</details>
###### Chat with Korbit by mentioning @korbit-ai, and give a 👍 or 👎 to help
Korbit improve your reviews.
<!--- korbi internal id:378d28c2-3839-415f-b372-8b694bb9ed55 -->
--
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]