Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Prevent undo functionality from referencing incorrect dashboard edits #31809

Merged
merged 9 commits into from
Jan 21, 2025
Prev Previous commit
Next Next commit
clearing history of package redux-undo
fardin-developer committed Jan 13, 2025
commit ff02430d9dfb7382ecce21f23fc2a6d77029ac45
7 changes: 1 addition & 6 deletions superset-frontend/src/dashboard/actions/dashboardLayout.js
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clearing history from redux undo

Original file line number Diff line number Diff line change
@@ -267,12 +267,7 @@ export function handleComponentDrop(dropResult) {
};
}

export function resetDashboardPast() {
return (dispatch, getState) => {
const { dashboardLayout } = getState();
dashboardLayout.past = []; // Set `past` as an empty array
};
}
export const clearDashboardHistory = () => UndoActionCreators.clearHistory();

// Undo redo ------------------------------------------------------------------
export function undoLayoutAction() {
Original file line number Diff line number Diff line change
@@ -55,7 +55,7 @@ import {
import {
deleteTopLevelTabs,
handleComponentDrop,
resetDashboardPast,
clearDashboardHistory,
} from 'src/dashboard/actions/dashboardLayout';
import {
DASHBOARD_GRID_ID,
@@ -678,7 +678,7 @@ const DashboardBuilder = () => {
buttonText={canEdit && t('Edit the dashboard')}
buttonAction={() => {
dispatch(setEditMode(true));
dispatch(resetDashboardPast());
dispatch(clearDashboardHistory());
}}
image="dashboard.svg"
/>
5 changes: 3 additions & 2 deletions superset-frontend/src/dashboard/components/Header/index.jsx
Original file line number Diff line number Diff line change
@@ -66,7 +66,7 @@ import {
redoLayoutAction,
undoLayoutAction,
updateDashboardTitle,
resetDashboardPast,
clearDashboardHistory,
} from '../../actions/dashboardLayout';
import {
fetchCharts,
@@ -222,7 +222,7 @@ const Header = () => {
addWarningToast,
onUndo: undoLayoutAction,
onRedo: redoLayoutAction,
clearDashboardHistory: resetDashboardPast,
clearDashboardHistory,
setEditMode,
setUnsavedChanges,
fetchFaveStar,
@@ -673,6 +673,7 @@ const Header = () => {
NavExtension,
boundActionCreators.onRedo,
boundActionCreators.onUndo,
boundActionCreators.clearDashboardHistory(),
editMode,
emphasizeRedo,
emphasizeUndo,