fix(useEntityTypeFilter): fetch unique set of types ignoring case sensitivity

Signed-off-by: Phil Kuang <pkuang@factset.com>
This commit is contained in:
Phil Kuang
2021-07-09 13:00:01 -04:00
parent 2c3f301f82
commit e13f0fb9de
2 changed files with 9 additions and 3 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-catalog-react': patch
---
Fix `EntityTypeFilter` so it produces unique case-insensitive set of available types
@@ -86,10 +86,11 @@ export function useEntityTypeFilter(): EntityTypeReturn {
const countByType = entities.reduce((acc, entity) => {
if (typeof entity.spec?.type !== 'string') return acc;
if (!acc[entity.spec.type]) {
acc[entity.spec.type] = 0;
const entityType = entity.spec.type.toLocaleLowerCase('en-US');
if (!acc[entityType]) {
acc[entityType] = 0;
}
acc[entity.spec.type] += 1;
acc[entityType] += 1;
return acc;
}, {} as Record<string, number>);