You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by vi...@apache.org on 2021/04/12 07:55:32 UTC

[superset] branch master updated: fix: fix bug when remove chart not removing it's related cross filter data (#14081)

This is an automated email from the ASF dual-hosted git repository.

villebro pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/master by this push:
     new d6bd160  fix: fix bug when remove chart not  removing it's related cross filter data (#14081)
d6bd160 is described below

commit d6bd1602507b05000c7112f241ded3bd9aea9244
Author: simcha90 <56...@users.noreply.github.com>
AuthorDate: Mon Apr 12 10:54:31 2021 +0300

    fix: fix bug when remove chart not  removing it's related cross filter data (#14081)
---
 .../src/dashboard/actions/dashboardState.js        | 24 ++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/superset-frontend/src/dashboard/actions/dashboardState.js b/superset-frontend/src/dashboard/actions/dashboardState.js
index 5bfc1dc..ac2ead0 100644
--- a/superset-frontend/src/dashboard/actions/dashboardState.js
+++ b/superset-frontend/src/dashboard/actions/dashboardState.js
@@ -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) {
@@ -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;