Merge pull request #29050 from backstage/blam/support-additional-types
Support additional `kind` prop to `Subcomponents` card
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-catalog': minor
|
||||
---
|
||||
|
||||
Allow providing `kind` parameters to replace the default `Component` kind for `SubComponents` card
|
||||
@@ -577,6 +577,8 @@ export interface HasSubcomponentsCardProps {
|
||||
// (undocumented)
|
||||
columns?: TableColumn<ComponentEntity>[];
|
||||
// (undocumented)
|
||||
kind?: string;
|
||||
// (undocumented)
|
||||
tableOptions?: TableOptions;
|
||||
// (undocumented)
|
||||
title?: string;
|
||||
|
||||
@@ -117,4 +117,53 @@ describe('<HasSubcomponentsCard />', () => {
|
||||
expect(screen.getByText(/target-name/i)).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it('allows overriding the entity kind', async () => {
|
||||
const entity: Entity = {
|
||||
apiVersion: 'v1',
|
||||
kind: 'Component',
|
||||
metadata: {
|
||||
name: 'my-component',
|
||||
namespace: 'my-namespace',
|
||||
},
|
||||
relations: [
|
||||
{
|
||||
targetRef: 'custom:my-namespace/target-name',
|
||||
type: RELATION_HAS_PART,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
catalogApi.getEntitiesByRefs.mockResolvedValue({
|
||||
items: [
|
||||
{
|
||||
apiVersion: 'v1',
|
||||
kind: 'Custom',
|
||||
metadata: {
|
||||
name: 'target-name',
|
||||
namespace: 'my-namespace',
|
||||
},
|
||||
spec: {},
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
await renderInTestApp(
|
||||
<Wrapper>
|
||||
<EntityProvider entity={entity}>
|
||||
<HasSubcomponentsCard kind="Custom" />
|
||||
</EntityProvider>
|
||||
</Wrapper>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText('Has subcomponents')).toBeInTheDocument();
|
||||
expect(screen.getByText(/target-name/i)).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -35,6 +35,7 @@ export interface HasSubcomponentsCardProps {
|
||||
title?: string;
|
||||
columns?: TableColumn<ComponentEntity>[];
|
||||
tableOptions?: TableOptions;
|
||||
kind?: string;
|
||||
}
|
||||
|
||||
export function HasSubcomponentsCard(props: HasSubcomponentsCardProps) {
|
||||
@@ -44,12 +45,13 @@ export function HasSubcomponentsCard(props: HasSubcomponentsCardProps) {
|
||||
title = t('hasSubcomponentsCard.title'),
|
||||
columns = componentEntityColumns,
|
||||
tableOptions = {},
|
||||
kind = 'Component',
|
||||
} = props;
|
||||
return (
|
||||
<RelatedEntitiesCard
|
||||
variant={variant}
|
||||
title={title}
|
||||
entityKind="Component"
|
||||
entityKind={kind}
|
||||
relationType={RELATION_HAS_PART}
|
||||
columns={columns}
|
||||
asRenderableEntities={asComponentEntities}
|
||||
|
||||
Reference in New Issue
Block a user