diff --git a/.changeset/seven-tips-begin.md b/.changeset/seven-tips-begin.md index b9ebc4f159..5609315144 100644 --- a/.changeset/seven-tips-begin.md +++ b/.changeset/seven-tips-begin.md @@ -1,6 +1,13 @@ --- -'@backstage/create-app': patch -'@backstage/plugin-api-docs': patch +'@backstage/plugin-api-docs': minor --- -Add tables with consumes and provides relationships to the API and component entity pages. +Stop exposing a custom router from the `api-docs` plugin. Instead, use the +widgets exported by the plugin to compose your custom entity pages. + +Instead of displaying the API definitions directly in the API tab of the +component, it now contains tables linking to the API entities. This also adds +new widgets to display relationships (bot provides & consumes relationships) +between components and APIs. + +See the changelog of `create-app` for a migration guide. diff --git a/.changeset/seven-tips-more.md b/.changeset/seven-tips-more.md index fcb51e30aa..9a6c4855c3 100644 --- a/.changeset/seven-tips-more.md +++ b/.changeset/seven-tips-more.md @@ -6,10 +6,13 @@ Adjust template to the latest changes in the `api-docs` plugin. ## Template Changes -While updating to the latest `api-docs` plugin, the following changes are necessary for the `create-app` template in your `app/src/components/catalog/EntityPage.tsx`. This adds: +While updating to the latest `api-docs` plugin, the following changes are +necessary for the `create-app` template in your +`app/src/components/catalog/EntityPage.tsx`. This adds: - A custom entity page for API entities -- Changes the API tab to include the new `ConsumedApisCard` and `ProvidedApisCard` that link to the API entity. +- Changes the API tab to include the new `ConsumedApisCard` and + `ProvidedApisCard` that link to the API entity. ```diff import { diff --git a/packages/create-app/templates/default-app/packages/app/src/components/catalog/EntityPage.tsx b/packages/create-app/templates/default-app/packages/app/src/components/catalog/EntityPage.tsx index 608a4f5f76..b5e384f7a9 100644 --- a/packages/create-app/templates/default-app/packages/app/src/components/catalog/EntityPage.tsx +++ b/packages/create-app/templates/default-app/packages/app/src/components/catalog/EntityPage.tsx @@ -13,9 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { Entity } from '@backstage/catalog-model'; +import { ApiEntity, Entity } from '@backstage/catalog-model'; import { WarningPanel } from '@backstage/core'; -import { ConsumedApisCard, ProvidedApisCard } from '@backstage/plugin-api-docs'; +import { + ApiDefinitionCard, + ConsumedApisCard, + ConsumingComponentsCard, + ProvidedApisCard, + ProvidingComponentsCard +} from '@backstage/plugin-api-docs'; import { AboutCard, EntityPageLayout, useEntity @@ -128,8 +134,7 @@ const DefaultEntityPage = ({ entity }: { entity: Entity }) => ( ); -export const EntityPage = () => { - const { entity } = useEntity(); +export const ComponentEntityPage = ({ entity }: { entity: Entity }) => { switch (entity?.spec?.type) { case 'service': return ; @@ -139,3 +144,55 @@ export const EntityPage = () => { return ; } }; + +const ApiOverviewContent = ({ entity }: { entity: Entity }) => ( + + + + + + + + + + + + + +); + +const ApiDefinitionContent = ({ entity }: { entity: ApiEntity }) => ( + + + + + +); + +const ApiEntityPage = ({ entity }: { entity: Entity }) => ( + + } + /> + } + /> + +); + +export const EntityPage = () => { + const { entity } = useEntity(); + + switch (entity?.kind?.toLowerCase()) { + case 'component': + return ; + case 'api': + return ; + default: + return ; + } +};