Skip to content

Commit 99dffe6

Browse files
authored
Merge pull request #4255 from kahirokunn/deduplicate-cr
frontend: Deduplicate CRDs in sidebar items
2 parents 36937ef + d7473b9 commit 99dffe6

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

frontend/src/components/Sidebar/useSidebarItems.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,18 @@ export const useSidebarItems = (sidebarName: string = DefaultSidebars.IN_CLUSTER
9090
],
9191
});
9292
} else {
93-
const entryGroup = entriesGroup.get(group)!;
94-
entryGroup.subList?.push({
95-
name: item.jsonData.metadata.name,
96-
label: item.jsonData.spec.names.kind,
97-
isCR: true,
98-
});
99-
//entryGroup.subList =
93+
const entryGroup = entriesGroup.get(group);
94+
if (entryGroup?.subList) {
95+
const crdName = item.jsonData.metadata.name;
96+
97+
if (!entryGroup.subList.some(subItem => subItem.name === crdName)) {
98+
entryGroup.subList.push({
99+
name: crdName,
100+
label: item.jsonData.spec.names.kind,
101+
isCR: true,
102+
});
103+
}
104+
}
100105
}
101106
});
102107
entriesGroup.forEach(item => {

0 commit comments

Comments
 (0)