Skip to content

Commit

Permalink
fix(native-filters): Fix "undefined" error after editing a filter (ap…
Browse files Browse the repository at this point in the history
…ache#14984)

* fix(native-filters): Fix "undefined" error after editing a filter

* Remove console log
  • Loading branch information
kgabryje authored and cccs-RyanS committed Dec 17, 2021
1 parent d4883cd commit 42fdea8
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions superset-frontend/src/dashboard/actions/nativeFilters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,19 @@ export const setFilterConfiguration = (
endpoint: `/api/v1/dashboard/${id}`,
});

const mergedFilterConfig = filterConfig.map(filter => {
const oldFilter = oldFilters[filter.id];
if (!oldFilter) {
return filter;
}
return { ...oldFilter, ...filter };
});

try {
const response = await updateDashboard({
json_metadata: JSON.stringify({
...metadata,
native_filter_configuration: filterConfig,
native_filter_configuration: mergedFilterConfig,
}),
});
dispatch(
Expand All @@ -99,12 +107,20 @@ export const setFilterConfiguration = (
);
dispatch({
type: SET_FILTER_CONFIG_COMPLETE,
filterConfig,
filterConfig: mergedFilterConfig,
});
dispatch(setDataMaskForFilterConfigComplete(filterConfig, oldFilters));
dispatch(
setDataMaskForFilterConfigComplete(mergedFilterConfig, oldFilters),
);
} catch (err) {
dispatch({ type: SET_FILTER_CONFIG_FAIL, filterConfig });
dispatch({ type: SET_DATA_MASK_FOR_FILTER_CONFIG_FAIL, filterConfig });
dispatch({
type: SET_FILTER_CONFIG_FAIL,
filterConfig: mergedFilterConfig,
});
dispatch({
type: SET_DATA_MASK_FOR_FILTER_CONFIG_FAIL,
filterConfig: mergedFilterConfig,
});
}
};

Expand Down

0 comments on commit 42fdea8

Please sign in to comment.