Skip to content

Commit

Permalink
fix(fe/src/dashboard): optional chaining for possibly nullable parent…
Browse files Browse the repository at this point in the history
… attribute in LayoutItem type (#30442)

Signed-off-by: hainenber <dotronghai96@gmail.com>
  • Loading branch information
hainenber authored Oct 3, 2024
1 parent 989744a commit 2a458a4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export const useFilterScope = (filter: Filter) => {
// We start assuming that all charts are in scope for all tabs in the root path
const topLevelTabsInFullScope = [...filter.scope.rootPath];
const layoutChartElementsInTabsInScope = layoutCharts.filter(element =>
element.parents.some(parent =>
element.parents?.some(parent =>
topLevelTabsInFullScope.includes(parent),
),
);
Expand All @@ -105,7 +105,7 @@ export const useFilterScope = (filter: Filter) => {
const excludedIndex = topLevelTabsInFullScope.findIndex(tabId =>
layoutChartElementsInTabsInScope
.find(chart => chart.meta.chartId === chartId)
?.parents.includes(tabId),
?.parents?.includes(tabId),
);
if (excludedIndex > -1) {
topLevelTabsInFullScope.splice(excludedIndex, 1);
Expand All @@ -119,7 +119,7 @@ export const useFilterScope = (filter: Filter) => {
layoutChartElementsInTabsInScope.find(
element =>
element.meta.chartId === chartId &&
element.parents.every(
element.parents?.every(
parent => !topLevelTabsInFullScope.includes(parent),
),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function useSelectChartTabParents() {
const chartLayoutItem = Object.values(dashboardLayout).find(
layoutItem => layoutItem.meta?.chartId === chartId,
);
return chartLayoutItem?.parents.filter(
return chartLayoutItem?.parents?.filter(
(parent: string) => dashboardLayout[parent]?.type === TAB_TYPE,
);
};
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/dashboard/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export type ComponentType = (typeof componentTypes)[ComponentTypesKeys];
/** State of dashboardLayout item in redux */
export type LayoutItem = {
children: string[];
parents: string[];
parents?: string[];
type: ComponentType;
id: string;
meta: {
Expand Down

0 comments on commit 2a458a4

Please sign in to comment.