diff --git a/.changeset/five-gorillas-marry.md b/.changeset/five-gorillas-marry.md new file mode 100644 index 0000000000..c3ba150429 --- /dev/null +++ b/.changeset/five-gorillas-marry.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog': minor +--- + +Add `spec.targets` (or `spec.target`) for Location entities at the `CatalogTable`. diff --git a/plugins/catalog/api-report.md b/plugins/catalog/api-report.md index bfdf62bdb0..29920d3532 100644 --- a/plugins/catalog/api-report.md +++ b/plugins/catalog/api-report.md @@ -132,6 +132,7 @@ export const CatalogTable: { ): TableColumn; createSystemColumn(): TableColumn; createOwnerColumn(): TableColumn; + createSpecTargetsColumn(): TableColumn; createSpecTypeColumn(): TableColumn; createSpecLifecycleColumn(): TableColumn; createMetadataDescriptionColumn(): TableColumn; diff --git a/plugins/catalog/src/components/CatalogTable/CatalogTable.test.tsx b/plugins/catalog/src/components/CatalogTable/CatalogTable.test.tsx index 0d2b80e3c1..c59b10281c 100644 --- a/plugins/catalog/src/components/CatalogTable/CatalogTable.test.tsx +++ b/plugins/catalog/src/components/CatalogTable/CatalogTable.test.tsx @@ -215,7 +215,14 @@ describe('CatalogTable component', () => { }, { kind: 'location', - expectedColumns: ['Name', 'Type', 'Description', 'Tags', 'Actions'], + expectedColumns: [ + 'Name', + 'Type', + 'Targets', + 'Description', + 'Tags', + 'Actions', + ], }, { kind: 'resource', diff --git a/plugins/catalog/src/components/CatalogTable/CatalogTable.tsx b/plugins/catalog/src/components/CatalogTable/CatalogTable.tsx index 96937c52c2..005a00c48e 100644 --- a/plugins/catalog/src/components/CatalogTable/CatalogTable.tsx +++ b/plugins/catalog/src/components/CatalogTable/CatalogTable.tsx @@ -83,9 +83,13 @@ export const CatalogTable = (props: CatalogTableProps) => { case 'system': return [columnFactories.createOwnerColumn()]; case 'group': - case 'location': case 'template': return [columnFactories.createSpecTypeColumn()]; + case 'location': + return [ + columnFactories.createSpecTypeColumn(), + columnFactories.createSpecTargetsColumn(), + ]; default: return [ columnFactories.createSystemColumn(), diff --git a/plugins/catalog/src/components/CatalogTable/columns.tsx b/plugins/catalog/src/components/CatalogTable/columns.tsx index d8b52e276e..19d160c0e2 100644 --- a/plugins/catalog/src/components/CatalogTable/columns.tsx +++ b/plugins/catalog/src/components/CatalogTable/columns.tsx @@ -23,6 +23,7 @@ import { Chip } from '@material-ui/core'; import { CatalogTableRow } from './types'; import { OverflowTooltip, TableColumn } from '@backstage/core-components'; import { Entity } from '@backstage/catalog-model'; +import { JsonArray } from '@backstage/types'; // The columnFactories symbol is not directly exported, but through the // CatalogTable.columns field. @@ -82,11 +83,30 @@ export const columnFactories = Object.freeze({ ), }; }, + createSpecTargetsColumn(): TableColumn { + return { + title: 'Targets', + field: 'entity.spec.targets', + render: ({ entity }) => ( + <> + {(entity?.spec?.targets || entity?.spec?.target) && ( + + )} + + ), + }; + }, createSpecTypeColumn(): TableColumn { return { title: 'Type', field: 'entity.spec.type', hidden: true, + width: 'auto', }; }, createSpecLifecycleColumn(): TableColumn { @@ -129,6 +149,7 @@ export const columnFactories = Object.freeze({ ))} ), + width: 'auto', }; }, createTitleColumn(options?: {