fix catalog search by display name
Signed-off-by: Stephen Glass <stephen@stephen.glass>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-catalog-react': patch
|
||||
---
|
||||
|
||||
Fix catalog filtering to allow searching entities by display name
|
||||
@@ -72,6 +72,33 @@ const templates: TemplateEntityV1beta3[] = [
|
||||
},
|
||||
];
|
||||
|
||||
const users: Entity[] = [
|
||||
{
|
||||
apiVersion: '1',
|
||||
kind: 'User',
|
||||
metadata: {
|
||||
name: 'jd1234',
|
||||
},
|
||||
spec: {
|
||||
profile: {
|
||||
displayName: 'DOE, JOHN',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
apiVersion: '1',
|
||||
kind: 'User',
|
||||
metadata: {
|
||||
name: 'fb3456',
|
||||
},
|
||||
spec: {
|
||||
profile: {
|
||||
displayName: 'BAR, FOO',
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
describe('EntityTextFilter', () => {
|
||||
it('should search name', () => {
|
||||
const filter = new EntityTextFilter('app');
|
||||
@@ -96,6 +123,12 @@ describe('EntityTextFilter', () => {
|
||||
expect(filter.filterEntity(entities[0])).toBeFalsy();
|
||||
expect(filter.filterEntity(entities[1])).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should search display name', () => {
|
||||
const filter = new EntityTextFilter('doe');
|
||||
expect(filter.filterEntity(users[0])).toBeTruthy();
|
||||
expect(filter.filterEntity(users[1])).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('EntityOrphanFilter', () => {
|
||||
|
||||
@@ -94,6 +94,13 @@ export class EntityTextFilter implements EntityFilter {
|
||||
const partialMatch = this.toUpperArray([
|
||||
entity.metadata.name,
|
||||
entity.metadata.title,
|
||||
...(typeof entity.spec?.profile === 'object' &&
|
||||
entity.spec?.profile !== null &&
|
||||
!Array.isArray(entity.spec.profile) &&
|
||||
'displayName' in entity.spec.profile &&
|
||||
typeof entity.spec.profile.displayName === 'string'
|
||||
? [entity.spec.profile.displayName]
|
||||
: []),
|
||||
]);
|
||||
|
||||
for (const word of words) {
|
||||
|
||||
Reference in New Issue
Block a user