fix(useEntityTypeFilter): fetch unique set of types ignoring case sensitivity
Signed-off-by: Phil Kuang <pkuang@factset.com>
This commit is contained in:
@@ -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>);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user