Skip to content

Commit

Permalink
fix(cross-filters): only apply filters if ff is set (#13704)
Browse files Browse the repository at this point in the history
* fix(cross-filters): only apply filters if ff is set

* fix missing parent
  • Loading branch information
villebro authored Mar 20, 2021
1 parent 95a017a commit 1a67f15
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ export function useFilterScopeTree(
const validNodes = useMemo(
() =>
Object.values(layout).reduce<string[]>((acc, cur) => {
if (cur?.type === CHART_TYPE && currentChartId !== cur?.meta?.chartId) {
return [...new Set([...acc, ...cur?.parents, cur.id])];
const { id, parents = [], type, meta } = cur;
if (type === CHART_TYPE && currentChartId !== meta?.chartId) {
return [...new Set([...acc, ...parents, id])];
}
return acc;
}, []),
Expand Down
15 changes: 14 additions & 1 deletion superset-frontend/src/dataMask/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
import { DataMaskType, MaskWithId } from './types';
import { FilterConfiguration } from '../dashboard/components/nativeFilters/types';
import { FeatureFlag, isFeatureEnabled } from '../featureFlags';

export const UPDATE_DATA_MASK = 'UPDATE_DATA_MASK';
export interface UpdateDataMask {
Expand Down Expand Up @@ -50,10 +51,22 @@ export function updateDataMask(
ownFilters?: Omit<MaskWithId, 'id'>;
},
): UpdateDataMask {
const { nativeFilters, crossFilters, ownFilters } = dataMask;
const filteredDataMask: {
nativeFilters?: Omit<MaskWithId, 'id'>;
crossFilters?: Omit<MaskWithId, 'id'>;
ownFilters?: Omit<MaskWithId, 'id'>;
} = { ownFilters };
if (isFeatureEnabled(FeatureFlag.DASHBOARD_NATIVE_FILTERS) && nativeFilters) {
filteredDataMask.nativeFilters = nativeFilters;
}
if (isFeatureEnabled(FeatureFlag.DASHBOARD_CROSS_FILTERS) && crossFilters) {
filteredDataMask.crossFilters = crossFilters;
}
return {
type: UPDATE_DATA_MASK,
filterId,
...dataMask,
...filteredDataMask,
};
}

Expand Down

0 comments on commit 1a67f15

Please sign in to comment.