Skip to content

Commit 2845b2f

Browse files
committed
frontend: Deduplicate namespaces from multi-cluster lists in autocomplete
Signed-off-by: kahirokunn <okinakahiro@gmail.com>
1 parent 0cfeae0 commit 2845b2f

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

frontend/src/components/Sidebar/useSidebarItems.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,16 @@ export const useSidebarItems = (sidebarName: string = DefaultSidebars.IN_CLUSTER
9191
});
9292
} else {
9393
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 =
94+
const subList = entryGroup.subList ?? (entryGroup.subList = []);
95+
const crdName = item.jsonData.metadata.name;
96+
97+
if (!subList.some(subItem => subItem.name === crdName)) {
98+
subList.push({
99+
name: crdName,
100+
label: item.jsonData.spec.names.kind,
101+
isCR: true,
102+
});
103+
}
100104
}
101105
});
102106
entriesGroup.forEach(item => {

0 commit comments

Comments
 (0)