From 67276652e6404809c995e3e6c410b69c08d68080 Mon Sep 17 00:00:00 2001 From: Boris Bera Date: Sun, 25 Feb 2024 11:18:11 -0500 Subject: [PATCH] Make `spec.target` searchable in catalog table for location Signed-off-by: Boris Bera --- .changeset/wet-sheep-reply.md | 5 +++++ .../catalog/src/components/CatalogTable/columns.tsx | 12 ++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 .changeset/wet-sheep-reply.md diff --git a/.changeset/wet-sheep-reply.md b/.changeset/wet-sheep-reply.md new file mode 100644 index 0000000000..27635b133e --- /dev/null +++ b/.changeset/wet-sheep-reply.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog': patch +--- + +Allow the `spec.target` field to be searchable in the catalog table for locations. Previously, only the `spec.targets` field was be searchable. This makes locations generated by providers such as the `GithubEntityProvider` searchable in the catalog table. [#23098](https://github.com/backstage/backstage/issues/23098) diff --git a/plugins/catalog/src/components/CatalogTable/columns.tsx b/plugins/catalog/src/components/CatalogTable/columns.tsx index 4260a0c26b..a191befe59 100644 --- a/plugins/catalog/src/components/CatalogTable/columns.tsx +++ b/plugins/catalog/src/components/CatalogTable/columns.tsx @@ -86,6 +86,18 @@ export const columnFactories = Object.freeze({ return { title: 'Targets', field: 'entity.spec.targets', + customFilterAndSearch: (query, row) => { + const targets = []; + if (Array.isArray(row.entity?.spec?.targets)) { + targets.push(...row.entity?.spec?.targets); + } else if (row.entity?.spec?.target) { + targets.push(row.entity?.spec?.target); + } + return targets + .join(', ') + .toLocaleUpperCase('en-US') + .includes(query.toLocaleUpperCase('en-US')); + }, render: ({ entity }) => ( <> {(entity?.spec?.targets || entity?.spec?.target) && (