feat: allow custom title for DomainCard
Signed-off-by: Chris Langhout <clanghout@bol.com>
This commit is contained in:
@@ -51,4 +51,31 @@ describe('<DomainCard />', () => {
|
||||
'/catalog/default/domain/artists',
|
||||
);
|
||||
});
|
||||
|
||||
it('renders a domain card with custom title', async () => {
|
||||
const entity: DomainEntity = {
|
||||
apiVersion: 'backstage.io/v1alpha1',
|
||||
kind: 'Domain',
|
||||
metadata: {
|
||||
name: 'artists',
|
||||
},
|
||||
spec: {
|
||||
owner: 'guest',
|
||||
},
|
||||
};
|
||||
const { getByText } = await renderInTestApp(
|
||||
<DomainCard entity={entity} title="my Custom Title" />,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(getByText('Explore').parentElement).toHaveAttribute(
|
||||
'href',
|
||||
'/catalog/default/domain/artists',
|
||||
);
|
||||
expect(getByText('my Custom Title')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -35,7 +35,7 @@ import { LinkButton, ItemCardHeader } from '@backstage/core-components';
|
||||
import { useRouteRef } from '@backstage/core-plugin-api';
|
||||
|
||||
/** @public */
|
||||
export const DomainCard = (props: { entity: DomainEntity }) => {
|
||||
export const DomainCard = (props: { entity: DomainEntity; title?: string }) => {
|
||||
const { entity } = props;
|
||||
|
||||
const catalogEntityRoute = useRouteRef(entityRouteRef);
|
||||
@@ -53,7 +53,10 @@ export const DomainCard = (props: { entity: DomainEntity }) => {
|
||||
return (
|
||||
<Card>
|
||||
<CardMedia>
|
||||
<ItemCardHeader title={entity.metadata.name} subtitle={owner} />
|
||||
<ItemCardHeader
|
||||
title={props.title ?? entity.metadata.name}
|
||||
subtitle={owner}
|
||||
/>
|
||||
</CardMedia>
|
||||
<CardContent>
|
||||
{entity.metadata.tags?.length ? (
|
||||
|
||||
Reference in New Issue
Block a user