Skip to content

Commit

Permalink
fix: fix bug when remove chart not removing it's related cross filter…
Browse files Browse the repository at this point in the history
… data (apache#14081)
  • Loading branch information
simcha90 authored Apr 12, 2021
1 parent 4eaca91 commit c8a2f51
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions superset-frontend/src/dashboard/actions/dashboardState.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ import serializeActiveFilterValues from '../util/serializeActiveFilterValues';
import serializeFilterScopes from '../util/serializeFilterScopes';
import { getActiveFilters } from '../util/activeDashboardFilters';
import { safeStringify } from '../../utils/safeStringify';
import { FeatureFlag, isFeatureEnabled } from '../../featureFlags';
import { setChartConfiguration } from './dashboardInfo';

export const SET_UNSAVED_CHANGES = 'SET_UNSAVED_CHANGES';
export function setUnsavedChanges(hasUnsavedChanges) {
Expand Down Expand Up @@ -199,6 +201,28 @@ export function saveDashboardRequest(data, id, saveType) {
},
})
.then(response => {
if (isFeatureEnabled(FeatureFlag.DASHBOARD_CROSS_FILTERS)) {
const {
dashboardInfo: {
metadata: { chart_configuration = {} },
},
} = getState();
const chartConfiguration = Object.values(chart_configuration).reduce(
(prev, next) => {
// If chart removed from dashboard - remove it from metadata
if (
Object.values(layout).find(
layoutItem => layoutItem?.meta?.chartId === next.id,
)
) {
return { ...prev, [next.id]: next };
}
return prev;
},
{},
);
dispatch(setChartConfiguration(chartConfiguration));
}
dispatch(saveDashboardRequestSuccess(response.json.last_modified_time));
dispatch(addSuccessToast(t('This dashboard was saved successfully.')));
return response;
Expand Down

0 comments on commit c8a2f51

Please sign in to comment.