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): max call size stack error #24304

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 @@ -18,7 +18,8 @@
*/
import { Behavior, FeatureFlag } from '@superset-ui/core';
import * as featureFlags from 'src/featureFlags';
import { nativeFilterGate } from './utils';
import { DashboardLayout } from 'src/dashboard/types';
import { nativeFilterGate, findTabsWithChartsInScope } from './utils';

let isFeatureEnabledMock: jest.MockInstance<boolean, [feature: FeatureFlag]>;

Expand Down Expand Up @@ -124,3 +125,40 @@ describe('nativeFilterGate', () => {
});
});
});

test('findTabsWithChartsInScope should handle a recursive layout structure', () => {
const dashboardLayout = {
DASHBOARD_VERSION_KEY: 'v2',
ROOT_ID: {
children: ['GRID_ID'],
id: 'ROOT_ID',
type: 'ROOT',
},
GRID_ID: {
children: ['TAB-LrujeuD5Qn', 'TABS-kN7tw6vFif'],
id: 'GRID_ID',
parents: ['ROOT_ID'],
type: 'GRID',
},
'TAB-LrujeuD5Qn': {
children: ['TABS-kN7tw6vFif'],
id: 'TAB-LrujeuD5Qn',
meta: {
text: 'View by Totals',
},
parents: ['ROOT_ID'],
type: 'TAB',
},
'TABS-kN7tw6vFif': {
children: ['TAB-LrujeuD5Qn', 'TAB--7BUkKkNl'],
id: 'TABS-kN7tw6vFif',
meta: {},
parents: ['ROOT_ID'],
type: 'TABS',
},
} as any as DashboardLayout;

expect(Array.from(findTabsWithChartsInScope(dashboardLayout, []))).toEqual(
[],
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,12 @@ const findTabsWithChartsInScopeHelper = (
componentId: string,
tabIds: string[],
tabsToHighlight: Set<string>,
visited: Set<string>,
) => {
if (visited.has(componentId)) {
return;
}
visited.add(componentId);
if (
dashboardLayout?.[componentId]?.type === CHART_TYPE &&
chartsInScope.includes(dashboardLayout[componentId]?.meta?.chartId)
Expand All @@ -175,6 +180,7 @@ const findTabsWithChartsInScopeHelper = (
childId,
isComponentATab(dashboardLayout, childId) ? [...tabIds, childId] : tabIds,
tabsToHighlight,
visited,
),
);
};
Expand All @@ -187,6 +193,7 @@ export const findTabsWithChartsInScope = (
const rootChildId = dashboardRoot.children[0];
const hasTopLevelTabs = rootChildId !== DASHBOARD_GRID_ID;
const tabsInScope = new Set<string>();
const visited = new Set<string>();
if (hasTopLevelTabs) {
dashboardLayout[rootChildId]?.children?.forEach(tabId =>
findTabsWithChartsInScopeHelper(
Expand All @@ -195,6 +202,7 @@ export const findTabsWithChartsInScope = (
tabId,
[tabId],
tabsInScope,
visited,
),
);
} else {
Expand All @@ -207,6 +215,7 @@ export const findTabsWithChartsInScope = (
element.id,
[element.id],
tabsInScope,
visited,
),
);
}
Expand Down