From 98d3f2fa31680b782caddc7d328e71e178ccddab Mon Sep 17 00:00:00 2001 From: Scott Guymer Date: Mon, 24 Jul 2023 11:56:37 +0200 Subject: [PATCH 1/3] Add email to index for user entity Signed-off-by: Scott Guymer --- .../defaultCatalogCollatorEntityTransformer.test.ts | 3 ++- .../collators/defaultCatalogCollatorEntityTransformer.ts | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/plugins/search-backend-module-catalog/src/collators/defaultCatalogCollatorEntityTransformer.test.ts b/plugins/search-backend-module-catalog/src/collators/defaultCatalogCollatorEntityTransformer.test.ts index 8206a58599..4ae6c88c06 100644 --- a/plugins/search-backend-module-catalog/src/collators/defaultCatalogCollatorEntityTransformer.test.ts +++ b/plugins/search-backend-module-catalog/src/collators/defaultCatalogCollatorEntityTransformer.test.ts @@ -42,6 +42,7 @@ const userEntity = { spec: { profile: { displayName: 'User 1', + email: 'test@test.com', }, }, }; @@ -94,7 +95,7 @@ describe('DefaultCatalogCollatorEntityTransformer', () => { expect(document).toMatchObject({ title: userEntity.metadata.name, - text: `${userEntity.metadata.description} : ${userEntity.spec.profile.displayName}`, + text: `${userEntity.metadata.description} : ${userEntity.spec.profile.displayName} : ${userEntity.spec.profile.email}}`, namespace: 'default', componentType: 'other', lifecycle: '', diff --git a/plugins/search-backend-module-catalog/src/collators/defaultCatalogCollatorEntityTransformer.ts b/plugins/search-backend-module-catalog/src/collators/defaultCatalogCollatorEntityTransformer.ts index 2fc0c5d50d..db239b8669 100644 --- a/plugins/search-backend-module-catalog/src/collators/defaultCatalogCollatorEntityTransformer.ts +++ b/plugins/search-backend-module-catalog/src/collators/defaultCatalogCollatorEntityTransformer.ts @@ -27,6 +27,12 @@ const getDocumentText = (entity: Entity): string => { } } + if (isUserEntity(entity)) { + if (entity.spec?.profile?.email) { + documentTexts.push(entity.spec.profile.email); + } + } + return documentTexts.join(' : '); }; From d4f19a16bd52861c835dbc28cd32bfdb8e34b415 Mon Sep 17 00:00:00 2001 From: Scott Guymer Date: Mon, 24 Jul 2023 12:02:36 +0200 Subject: [PATCH 2/3] added changeset Signed-off-by: Scott Guymer --- .changeset/twelve-pigs-cough.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/twelve-pigs-cough.md diff --git a/.changeset/twelve-pigs-cough.md b/.changeset/twelve-pigs-cough.md new file mode 100644 index 0000000000..e2eef61915 --- /dev/null +++ b/.changeset/twelve-pigs-cough.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-search-backend-module-catalog': patch +--- + +Add User Entity email to the search index so that users can be found by their email. From e5f5054bb03ea869cfd2107377cb3624ed3cec75 Mon Sep 17 00:00:00 2001 From: Scott Guymer Date: Fri, 28 Jul 2023 09:43:52 +0200 Subject: [PATCH 3/3] Remove extra brace Signed-off-by: Scott Guymer --- .../collators/defaultCatalogCollatorEntityTransformer.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/search-backend-module-catalog/src/collators/defaultCatalogCollatorEntityTransformer.test.ts b/plugins/search-backend-module-catalog/src/collators/defaultCatalogCollatorEntityTransformer.test.ts index 4ae6c88c06..3fe6a9c3e5 100644 --- a/plugins/search-backend-module-catalog/src/collators/defaultCatalogCollatorEntityTransformer.test.ts +++ b/plugins/search-backend-module-catalog/src/collators/defaultCatalogCollatorEntityTransformer.test.ts @@ -95,7 +95,7 @@ describe('DefaultCatalogCollatorEntityTransformer', () => { expect(document).toMatchObject({ title: userEntity.metadata.name, - text: `${userEntity.metadata.description} : ${userEntity.spec.profile.displayName} : ${userEntity.spec.profile.email}}`, + text: `${userEntity.metadata.description} : ${userEntity.spec.profile.displayName} : ${userEntity.spec.profile.email}`, namespace: 'default', componentType: 'other', lifecycle: '',