Index name + title for entity in default catalog collator

It's confusing to no longer be able to search for an entity based on
name when the entity has a title specified. This changes the behavior so
that it's searchable on both.

Signed-off-by: Brian Phillips <28457+brianphillips@users.noreply.github.com>
This commit is contained in:
Brian Phillips
2024-06-12 22:56:55 -05:00
parent b016505d4a
commit 0f55f5ca8e
3 changed files with 9 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-catalog-backend': patch
---
Ensure name and title are both indexed by the DefaultCatalogCollator
@@ -117,7 +117,7 @@ describe('DefaultCatalogCollator', () => {
},
});
expect(documents[1]).toMatchObject({
title: expectedEntities[1].metadata.title,
title: `${expectedEntities[1].metadata.title} (${expectedEntities[1].metadata.name})`,
location: '/catalog/default/component/test-entity-2',
text: expectedEntities[1].metadata.description,
namespace: 'default',
@@ -115,7 +115,9 @@ export class DefaultCatalogCollator {
);
return response.items.map((entity: Entity): CatalogEntityDocument => {
return {
title: entity.metadata.title ?? entity.metadata.name,
title: entity.metadata.title
? `${entity.metadata.title} (${entity.metadata.name})`
: entity.metadata.name,
location: this.applyArgsToFormat(this.locationTemplate, {
namespace: entity.metadata.namespace || 'default',
kind: entity.kind,