Merge pull request #27775 from stephenglass/fix-catalog-search-displayname
fix(catalog): fix catalog search by display name
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,7 @@ export class EntityTextFilter implements EntityFilter {
|
||||
const partialMatch = this.toUpperArray([
|
||||
entity.metadata.name,
|
||||
entity.metadata.title,
|
||||
(entity.spec?.profile as { displayName?: string })?.displayName,
|
||||
]);
|
||||
|
||||
for (const word of words) {
|
||||
|
||||
Reference in New Issue
Block a user