diff --git a/.changeset/giant-eagles-talk.md b/.changeset/giant-eagles-talk.md deleted file mode 100644 index 759719c2d9..0000000000 --- a/.changeset/giant-eagles-talk.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -'@backstage/plugin-catalog': minor -'@backstage/plugin-catalog-react': minor ---- - -Added `createMetadataTitleColumn` to allow table column for `metadata.title` entity field diff --git a/plugins/catalog-react/src/components/EntityRefLink/EntityRefLink.tsx b/plugins/catalog-react/src/components/EntityRefLink/EntityRefLink.tsx index e220acc543..123c768e36 100644 --- a/plugins/catalog-react/src/components/EntityRefLink/EntityRefLink.tsx +++ b/plugins/catalog-react/src/components/EntityRefLink/EntityRefLink.tsx @@ -19,20 +19,23 @@ import { ENTITY_DEFAULT_NAMESPACE, } from '@backstage/catalog-model'; import React, { forwardRef } from 'react'; -import { generatePath } from 'react-router'; -import { entityRoute } from '../../routes'; +import { entityRouteRef } from '../../routes'; import { formatEntityRefTitle } from './format'; import { Link, LinkProps } from '@backstage/core-components'; +import { useRouteRef } from '@backstage/core-plugin-api'; +import { Tooltip } from '@material-ui/core'; export type EntityRefLinkProps = { entityRef: Entity | EntityName; defaultKind?: string; + title?: string; children?: React.ReactNode; } & Omit; export const EntityRefLink = forwardRef( (props, ref) => { - const { entityRef, defaultKind, children, ...linkProps } = props; + const { entityRef, defaultKind, title, children, ...linkProps } = props; + const entityRoute = useRouteRef(entityRouteRef); let kind; let namespace; @@ -57,16 +60,20 @@ export const EntityRefLink = forwardRef( name, }; - // TODO: Use useRouteRef here to generate the path - return ( - + const link = ( + {children} - {!children && formatEntityRefTitle(entityRef, { defaultKind })} + {!children && + (title ?? formatEntityRefTitle(entityRef, { defaultKind }))} ); + + return title ? ( + + {link} + + ) : ( + link + ); }, ); diff --git a/plugins/catalog-react/src/components/EntityTable/columns.tsx b/plugins/catalog-react/src/components/EntityTable/columns.tsx index 57aaa156e8..9a48b2d554 100644 --- a/plugins/catalog-react/src/components/EntityTable/columns.tsx +++ b/plugins/catalog-react/src/components/EntityTable/columns.tsx @@ -58,7 +58,11 @@ export function createEntityRefColumn({ return formatContent(entity1).localeCompare(formatContent(entity2)); }, render: entity => ( - + ), }; } @@ -150,21 +154,6 @@ export function createMetadataDescriptionColumn< }; } -export function createMetadataTitleColumn(): TableColumn { - return { - title: 'Title', - field: 'metadata.title', - render: entity => ( - - ), - width: 'auto', - }; -} - export function createSpecLifecycleColumn(): TableColumn { return { title: 'Lifecycle', diff --git a/plugins/catalog/src/components/CatalogTable/columns.tsx b/plugins/catalog/src/components/CatalogTable/columns.tsx index 1ed0e1f72b..89c1a23966 100644 --- a/plugins/catalog/src/components/CatalogTable/columns.tsx +++ b/plugins/catalog/src/components/CatalogTable/columns.tsx @@ -34,6 +34,7 @@ export function createNameColumn( ), }; @@ -94,17 +95,6 @@ export function createMetadataDescriptionColumn(): TableColumn { }; } -export function createMetadataTitleColumn(): TableColumn { - return { - title: 'Title', - field: 'entity.metadata.title', - render: ({ entity }) => ( - - ), - width: 'auto', - }; -} - export function createTagsColumn(): TableColumn { return { title: 'Tags',