diff --git a/.changeset/rude-geckos-lead.md b/.changeset/rude-geckos-lead.md new file mode 100644 index 0000000000..3699b5686c --- /dev/null +++ b/.changeset/rude-geckos-lead.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-api-docs': patch +--- + +Add `tableOptions` and `title` to Components cards of APIs diff --git a/plugins/api-docs/report.api.md b/plugins/api-docs/report.api.md index 5c84544319..693502fad9 100644 --- a/plugins/api-docs/report.api.md +++ b/plugins/api-docs/report.api.md @@ -104,7 +104,9 @@ export const ConsumedApisCard: (props: { // @public (undocumented) export const ConsumingComponentsCard: (props: { variant?: InfoCardVariants; + title?: string; columns?: TableColumn[]; + tableOptions?: TableOptions; }) => JSX_2.Element; // @public @@ -138,7 +140,9 @@ export const EntityConsumedApisCard: (props: { // @public (undocumented) export const EntityConsumingComponentsCard: (props: { variant?: InfoCardVariants; + title?: string; columns?: TableColumn[]; + tableOptions?: TableOptions; }) => JSX_2.Element; // @public (undocumented) @@ -160,7 +164,9 @@ export const EntityProvidedApisCard: (props: { // @public (undocumented) export const EntityProvidingComponentsCard: (props: { variant?: InfoCardVariants; + title?: string; columns?: TableColumn[]; + tableOptions?: TableOptions; }) => JSX_2.Element; // @public (undocumented) @@ -215,7 +221,9 @@ export const ProvidedApisCard: (props: { // @public (undocumented) export const ProvidingComponentsCard: (props: { variant?: InfoCardVariants; + title?: string; columns?: TableColumn[]; + tableOptions?: TableOptions; }) => JSX_2.Element; // @public (undocumented) diff --git a/plugins/api-docs/src/components/ComponentsCards/ConsumingComponentsCard.tsx b/plugins/api-docs/src/components/ComponentsCards/ConsumingComponentsCard.tsx index 12bc930c37..1fda0d7e05 100644 --- a/plugins/api-docs/src/components/ComponentsCards/ConsumingComponentsCard.tsx +++ b/plugins/api-docs/src/components/ComponentsCards/ConsumingComponentsCard.tsx @@ -31,6 +31,7 @@ import { Link, Progress, TableColumn, + TableOptions, WarningPanel, } from '@backstage/core-components'; import { useTranslationRef } from '@backstage/frontend-plugin-api'; @@ -41,19 +42,25 @@ import { apiDocsTranslationRef } from '../../translation'; */ export const ConsumingComponentsCard = (props: { variant?: InfoCardVariants; + title?: string; columns?: TableColumn[]; + tableOptions?: TableOptions; }) => { - const { variant = 'gridItem', columns = EntityTable.componentEntityColumns } = - props; + const { t } = useTranslationRef(apiDocsTranslationRef); + const { + variant = 'gridItem', + title = t('consumingComponentsCard.title'), + columns = EntityTable.componentEntityColumns, + tableOptions = {}, + } = props; const { entity } = useEntity(); const { entities, loading, error } = useRelatedEntities(entity, { type: RELATION_API_CONSUMED_BY, }); - const { t } = useTranslationRef(apiDocsTranslationRef); if (loading) { return ( - + ); @@ -61,7 +68,7 @@ export const ConsumingComponentsCard = (props: { if (error || !entities) { return ( - + @@ -88,6 +95,7 @@ export const ConsumingComponentsCard = (props: { } columns={columns} + tableOptions={tableOptions} entities={entities as ComponentEntity[]} /> ); diff --git a/plugins/api-docs/src/components/ComponentsCards/ProvidingComponentsCard.tsx b/plugins/api-docs/src/components/ComponentsCards/ProvidingComponentsCard.tsx index c271c33380..efdcd83247 100644 --- a/plugins/api-docs/src/components/ComponentsCards/ProvidingComponentsCard.tsx +++ b/plugins/api-docs/src/components/ComponentsCards/ProvidingComponentsCard.tsx @@ -31,6 +31,7 @@ import { Link, Progress, TableColumn, + TableOptions, WarningPanel, } from '@backstage/core-components'; import { useTranslationRef } from '@backstage/frontend-plugin-api'; @@ -39,19 +40,25 @@ import { apiDocsTranslationRef } from '../../translation'; /** @public */ export const ProvidingComponentsCard = (props: { variant?: InfoCardVariants; + title?: string; columns?: TableColumn[]; + tableOptions?: TableOptions; }) => { - const { variant = 'gridItem', columns = EntityTable.componentEntityColumns } = - props; + const { t } = useTranslationRef(apiDocsTranslationRef); + const { + variant = 'gridItem', + title = t('providingComponentsCard.title'), + columns = EntityTable.componentEntityColumns, + tableOptions = {}, + } = props; const { entity } = useEntity(); const { entities, loading, error } = useRelatedEntities(entity, { type: RELATION_API_PROVIDED_BY, }); - const { t } = useTranslationRef(apiDocsTranslationRef); if (loading) { return ( - + ); @@ -59,7 +66,7 @@ export const ProvidingComponentsCard = (props: { if (error || !entities) { return ( - + @@ -86,6 +93,7 @@ export const ProvidingComponentsCard = (props: { } columns={columns} + tableOptions={tableOptions} entities={entities as ComponentEntity[]} /> );