Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] dashboard filter scope bug #9550

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -212,5 +212,19 @@ describe('getFilterScopeFromNodesTree', () => {
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],
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@ function getTabChildrenScope({
tabScopes,
parentNodeValue,
forceAggregate = false,
hasChartSibilings = false,
}) {
// if all sub-tabs are in scope, or forceAggregate = true
// aggregate scope to parentNodeValue
if (
forceAggregate ||
Object.entries(tabScopes).every(
([key, { scope }]) => scope && scope.length && key === scope[0],
)
(!hasChartSibilings &&
Object.entries(tabScopes).every(
([key, { scope }]) => scope && scope.length && key === scope[0],
))
) {
return {
scope: [parentNodeValue],
Expand Down Expand Up @@ -98,7 +100,11 @@ function traverse({ currentNode = {}, filterId, checkedChartIds = [] }) {

// has tab children but only some sub-tab in scope
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
Expand Down