fix(fe/src/dashboard): optional chaining for possibly nullable parent attribute in LayoutItem type (#30442)
Signed-off-by: hainenber <dotronghai96@gmail.com>
This commit is contained in:
parent
989744aba2
commit
2a458a4802
|
|
@ -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
|
// We start assuming that all charts are in scope for all tabs in the root path
|
||||||
const topLevelTabsInFullScope = [...filter.scope.rootPath];
|
const topLevelTabsInFullScope = [...filter.scope.rootPath];
|
||||||
const layoutChartElementsInTabsInScope = layoutCharts.filter(element =>
|
const layoutChartElementsInTabsInScope = layoutCharts.filter(element =>
|
||||||
element.parents.some(parent =>
|
element.parents?.some(parent =>
|
||||||
topLevelTabsInFullScope.includes(parent),
|
topLevelTabsInFullScope.includes(parent),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
@ -105,7 +105,7 @@ export const useFilterScope = (filter: Filter) => {
|
||||||
const excludedIndex = topLevelTabsInFullScope.findIndex(tabId =>
|
const excludedIndex = topLevelTabsInFullScope.findIndex(tabId =>
|
||||||
layoutChartElementsInTabsInScope
|
layoutChartElementsInTabsInScope
|
||||||
.find(chart => chart.meta.chartId === chartId)
|
.find(chart => chart.meta.chartId === chartId)
|
||||||
?.parents.includes(tabId),
|
?.parents?.includes(tabId),
|
||||||
);
|
);
|
||||||
if (excludedIndex > -1) {
|
if (excludedIndex > -1) {
|
||||||
topLevelTabsInFullScope.splice(excludedIndex, 1);
|
topLevelTabsInFullScope.splice(excludedIndex, 1);
|
||||||
|
|
@ -119,7 +119,7 @@ export const useFilterScope = (filter: Filter) => {
|
||||||
layoutChartElementsInTabsInScope.find(
|
layoutChartElementsInTabsInScope.find(
|
||||||
element =>
|
element =>
|
||||||
element.meta.chartId === chartId &&
|
element.meta.chartId === chartId &&
|
||||||
element.parents.every(
|
element.parents?.every(
|
||||||
parent => !topLevelTabsInFullScope.includes(parent),
|
parent => !topLevelTabsInFullScope.includes(parent),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ function useSelectChartTabParents() {
|
||||||
const chartLayoutItem = Object.values(dashboardLayout).find(
|
const chartLayoutItem = Object.values(dashboardLayout).find(
|
||||||
layoutItem => layoutItem.meta?.chartId === chartId,
|
layoutItem => layoutItem.meta?.chartId === chartId,
|
||||||
);
|
);
|
||||||
return chartLayoutItem?.parents.filter(
|
return chartLayoutItem?.parents?.filter(
|
||||||
(parent: string) => dashboardLayout[parent]?.type === TAB_TYPE,
|
(parent: string) => dashboardLayout[parent]?.type === TAB_TYPE,
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -177,7 +177,7 @@ export type ComponentType = (typeof componentTypes)[ComponentTypesKeys];
|
||||||
/** State of dashboardLayout item in redux */
|
/** State of dashboardLayout item in redux */
|
||||||
export type LayoutItem = {
|
export type LayoutItem = {
|
||||||
children: string[];
|
children: string[];
|
||||||
parents: string[];
|
parents?: string[];
|
||||||
type: ComponentType;
|
type: ComponentType;
|
||||||
id: string;
|
id: string;
|
||||||
meta: {
|
meta: {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue