Make spec.target searchable in catalog table for location

Signed-off-by: Boris Bera <beraboris@gmail.com>
This commit is contained in:
Boris Bera
2024-02-25 11:18:11 -05:00
parent 59dcc0f2c5
commit 67276652e6
2 changed files with 17 additions and 0 deletions
+5
View File
@@ -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)
@@ -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) && (