mirror of https://github.com/apache/superset.git
[fix] dashboard filter scope bug (#9550)
This commit is contained in:
parent
074e3653e2
commit
4a55e1ea3a
|
@ -212,5 +212,19 @@ describe('getFilterScopeFromNodesTree', () => {
|
||||||
immune: [],
|
immune: [],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('mixed row level tab and chart scope', () => {
|
||||||
|
const checkedChartIds = [103, 105, 102];
|
||||||
|
expect(
|
||||||
|
getFilterScopeFromNodesTree({
|
||||||
|
filterKey: '107_region',
|
||||||
|
nodes,
|
||||||
|
checkedChartIds,
|
||||||
|
}),
|
||||||
|
).toEqual({
|
||||||
|
scope: ['TAB-E4mJaZ-uQM', 'TAB-rLYu-Cryu'],
|
||||||
|
immune: [101],
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -26,14 +26,16 @@ function getTabChildrenScope({
|
||||||
tabScopes,
|
tabScopes,
|
||||||
parentNodeValue,
|
parentNodeValue,
|
||||||
forceAggregate = false,
|
forceAggregate = false,
|
||||||
|
hasChartSibilings = false,
|
||||||
}) {
|
}) {
|
||||||
// if all sub-tabs are in scope, or forceAggregate = true
|
// if all sub-tabs are in scope, or forceAggregate = true
|
||||||
// aggregate scope to parentNodeValue
|
// aggregate scope to parentNodeValue
|
||||||
if (
|
if (
|
||||||
forceAggregate ||
|
forceAggregate ||
|
||||||
Object.entries(tabScopes).every(
|
(!hasChartSibilings &&
|
||||||
([key, { scope }]) => scope && scope.length && key === scope[0],
|
Object.entries(tabScopes).every(
|
||||||
)
|
([key, { scope }]) => scope && scope.length && key === scope[0],
|
||||||
|
))
|
||||||
) {
|
) {
|
||||||
return {
|
return {
|
||||||
scope: [parentNodeValue],
|
scope: [parentNodeValue],
|
||||||
|
@ -98,7 +100,11 @@ function traverse({ currentNode = {}, filterId, checkedChartIds = [] }) {
|
||||||
|
|
||||||
// has tab children but only some sub-tab in scope
|
// has tab children but only some sub-tab in scope
|
||||||
if (tabChildren.length) {
|
if (tabChildren.length) {
|
||||||
return getTabChildrenScope({ tabScopes, parentNodeValue: currentValue });
|
return getTabChildrenScope({
|
||||||
|
tabScopes,
|
||||||
|
parentNodeValue: currentValue,
|
||||||
|
hasChartSibilings: !isEmpty(chartChildren),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// no tab children and no chart children in scope
|
// no tab children and no chart children in scope
|
||||||
|
|
Loading…
Reference in New Issue