From a9f1c704dc9061319edf2387b33daf029b86ceb9 Mon Sep 17 00:00:00 2001 From: Kamil Zainal Date: Thu, 6 Jan 2022 12:41:41 +0000 Subject: [PATCH 1/9] Route 'Register Existing API' on API page to /catalog-import The 'Register Existing API' button on /api-docs was routing to /create but APIs can't be created. Changing to route to /catalog-import where an API can be registered instead. Signed-off-by: Kamil Zainal --- packages/app/src/App.tsx | 2 +- .../components/ApiExplorerPage/DefaultApiExplorerPage.tsx | 6 +++--- plugins/api-docs/src/plugin.ts | 4 ++-- plugins/api-docs/src/routes.ts | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/app/src/App.tsx b/packages/app/src/App.tsx index 59f107c70d..360eca6152 100644 --- a/packages/app/src/App.tsx +++ b/packages/app/src/App.tsx @@ -117,7 +117,7 @@ const app = createApp({ catalogEntity: catalogPlugin.routes.catalogEntity, }); bind(apiDocsPlugin.externalRoutes, { - createComponent: scaffolderPlugin.routes.root, + registerComponent: catalogImportPlugin.routes.importPage, }); bind(explorePlugin.externalRoutes, { catalogEntity: catalogPlugin.routes.catalogEntity, diff --git a/plugins/api-docs/src/components/ApiExplorerPage/DefaultApiExplorerPage.tsx b/plugins/api-docs/src/components/ApiExplorerPage/DefaultApiExplorerPage.tsx index 5ddda96daa..d38383f004 100644 --- a/plugins/api-docs/src/components/ApiExplorerPage/DefaultApiExplorerPage.tsx +++ b/plugins/api-docs/src/components/ApiExplorerPage/DefaultApiExplorerPage.tsx @@ -42,7 +42,7 @@ import { UserListPicker, } from '@backstage/plugin-catalog-react'; import React from 'react'; -import { createComponentRouteRef } from '../../routes'; +import { registerComponentRouteRef } from '../../routes'; const defaultColumns: TableColumn[] = [ CatalogTable.columns.createNameColumn({ defaultKind: 'API' }), @@ -77,7 +77,7 @@ export const DefaultApiExplorerPage = ({ const generatedSubtitle = `${ configApi.getOptionalString('organization.name') ?? 'Backstage' } API Explorer`; - const createComponentLink = useRouteRef(createComponentRouteRef); + const registerComponentLink = useRouteRef(registerComponentRouteRef); return ( All your APIs diff --git a/plugins/api-docs/src/plugin.ts b/plugins/api-docs/src/plugin.ts index 61695b4a7a..4b69cc85ff 100644 --- a/plugins/api-docs/src/plugin.ts +++ b/plugins/api-docs/src/plugin.ts @@ -17,7 +17,7 @@ import { ApiEntity } from '@backstage/catalog-model'; import { defaultDefinitionWidgets } from './components/ApiDefinitionCard'; import { apiDocsConfigRef } from './config'; -import { createComponentRouteRef, rootRoute } from './routes'; +import { registerComponentRouteRef, rootRoute } from './routes'; import { createApiFactory, createComponentExtension, @@ -45,7 +45,7 @@ export const apiDocsPlugin = createPlugin({ }), ], externalRoutes: { - createComponent: createComponentRouteRef, + registerComponent: registerComponentRouteRef, }, }); diff --git a/plugins/api-docs/src/routes.ts b/plugins/api-docs/src/routes.ts index b7c152889e..2103672eb0 100644 --- a/plugins/api-docs/src/routes.ts +++ b/plugins/api-docs/src/routes.ts @@ -23,7 +23,7 @@ export const rootRoute = createRouteRef({ id: 'api-docs', }); -export const createComponentRouteRef = createExternalRouteRef({ - id: 'create-component', +export const registerComponentRouteRef = createExternalRouteRef({ + id: 'register-component', optional: true, }); From b3831be2feb8e02ddd48dfb8fddb1ac55a6e1e0a Mon Sep 17 00:00:00 2001 From: Kamil Zainal Date: Thu, 6 Jan 2022 15:37:41 +0000 Subject: [PATCH 2/9] Add changeset Signed-off-by: Kamil Zainal --- .changeset/serious-roses-stare.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/serious-roses-stare.md diff --git a/.changeset/serious-roses-stare.md b/.changeset/serious-roses-stare.md new file mode 100644 index 0000000000..9f3b6b9746 --- /dev/null +++ b/.changeset/serious-roses-stare.md @@ -0,0 +1,6 @@ +--- +'example-app': patch +'@backstage/plugin-api-docs': patch +--- + +Link 'Register Existing API' button on API page to /catalog-import instead of /create From 859891b7de1cc8914cee94a23fefb44d1fce00b0 Mon Sep 17 00:00:00 2001 From: Kamil Zainal Date: Thu, 6 Jan 2022 16:36:22 +0000 Subject: [PATCH 3/9] Changes from yarn build:api-reports Signed-off-by: Kamil Zainal --- plugins/api-docs/api-report.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/api-docs/api-report.md b/plugins/api-docs/api-report.md index f0e8c06aab..ccae9e7d47 100644 --- a/plugins/api-docs/api-report.md +++ b/plugins/api-docs/api-report.md @@ -47,7 +47,7 @@ const apiDocsPlugin: BackstagePlugin< root: RouteRef; }, { - createComponent: ExternalRouteRef; + registerComponent: ExternalRouteRef; } >; export { apiDocsPlugin }; From 2068135b9b463205bf1048632a72f6e7f7cd0aaf Mon Sep 17 00:00:00 2001 From: Kamil Zainal Date: Thu, 6 Jan 2022 16:41:58 +0000 Subject: [PATCH 4/9] Update create-app template Signed-off-by: Kamil Zainal --- .../create-app/templates/default-app/packages/app/src/App.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/create-app/templates/default-app/packages/app/src/App.tsx b/packages/create-app/templates/default-app/packages/app/src/App.tsx index 8a535835b4..b6aa88ff9e 100644 --- a/packages/create-app/templates/default-app/packages/app/src/App.tsx +++ b/packages/create-app/templates/default-app/packages/app/src/App.tsx @@ -37,7 +37,7 @@ const app = createApp({ viewTechDoc: techdocsPlugin.routes.docRoot, }); bind(apiDocsPlugin.externalRoutes, { - createComponent: scaffolderPlugin.routes.root, + registerComponent: catalogImportPlugin.routes.importPage, }); bind(scaffolderPlugin.externalRoutes, { registerComponent: catalogImportPlugin.routes.importPage, From 5a2204ef0a9b8309ad77f2b4ad9b5f6f584d5017 Mon Sep 17 00:00:00 2001 From: Kamil Zainal Date: Mon, 10 Jan 2022 15:51:52 +0000 Subject: [PATCH 5/9] Update existing changeset to reflect API change Signed-off-by: Kamil Zainal --- .changeset/serious-roses-stare.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.changeset/serious-roses-stare.md b/.changeset/serious-roses-stare.md index 9f3b6b9746..b30676a355 100644 --- a/.changeset/serious-roses-stare.md +++ b/.changeset/serious-roses-stare.md @@ -1,6 +1,6 @@ --- -'example-app': patch -'@backstage/plugin-api-docs': patch +'@backstage/plugin-api-docs': minor --- -Link 'Register Existing API' button on API page to /catalog-import instead of /create +Link 'Register Existing API' button on API page to /catalog-import instead of /create . +We now expect to `bind` the route for `apiDocsPlugin` to `registerComponent` instead of `createComponent`. From d4941024bce71887f1af802f5e64259f24a5bdc2 Mon Sep 17 00:00:00 2001 From: Kamil Zainal Date: Mon, 10 Jan 2022 16:09:14 +0000 Subject: [PATCH 6/9] Add changeset for create-app with instructions for upgrade Signed-off-by: Kamil Zainal --- .changeset/friendly-weeks-cry.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .changeset/friendly-weeks-cry.md diff --git a/.changeset/friendly-weeks-cry.md b/.changeset/friendly-weeks-cry.md new file mode 100644 index 0000000000..dfe5765d49 --- /dev/null +++ b/.changeset/friendly-weeks-cry.md @@ -0,0 +1,21 @@ +--- +'@backstage/create-app': patch +--- + +Rebind external route for catalog import plugin from `scaffolderPlugin.routes.root` to `catalogImportPlugin.routes.importPage`. + +To make this change to an existing app, make the following change to `packages/app/src/App.tsx` + +```diff +const App = createApp({ + ... + bindRoutes({ bind }) { + ... + bind(apiDocsPlugin.externalRoutes, { +- createComponent: scaffolderPlugin.routes.root, ++ registerComponent: catalogImportPlugin.routes.importPage, + }); + ... + }, +}); +``` From 027bc50cc569e93cc482567f05f49e4777ea19f3 Mon Sep 17 00:00:00 2001 From: Kamil Zainal Date: Tue, 18 Jan 2022 18:12:36 +0000 Subject: [PATCH 7/9] Rename registerComponent to registerApi to better communicate intent Signed-off-by: Kamil Zainal --- .changeset/friendly-weeks-cry.md | 2 +- .../create-app/templates/default-app/packages/app/src/App.tsx | 2 +- plugins/api-docs/api-report.md | 2 +- plugins/api-docs/src/plugin.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.changeset/friendly-weeks-cry.md b/.changeset/friendly-weeks-cry.md index dfe5765d49..e98be44f06 100644 --- a/.changeset/friendly-weeks-cry.md +++ b/.changeset/friendly-weeks-cry.md @@ -13,7 +13,7 @@ const App = createApp({ ... bind(apiDocsPlugin.externalRoutes, { - createComponent: scaffolderPlugin.routes.root, -+ registerComponent: catalogImportPlugin.routes.importPage, ++ registerApi: catalogImportPlugin.routes.importPage, }); ... }, diff --git a/packages/create-app/templates/default-app/packages/app/src/App.tsx b/packages/create-app/templates/default-app/packages/app/src/App.tsx index b6aa88ff9e..4c284e9c9a 100644 --- a/packages/create-app/templates/default-app/packages/app/src/App.tsx +++ b/packages/create-app/templates/default-app/packages/app/src/App.tsx @@ -37,7 +37,7 @@ const app = createApp({ viewTechDoc: techdocsPlugin.routes.docRoot, }); bind(apiDocsPlugin.externalRoutes, { - registerComponent: catalogImportPlugin.routes.importPage, + registerApi: catalogImportPlugin.routes.importPage, }); bind(scaffolderPlugin.externalRoutes, { registerComponent: catalogImportPlugin.routes.importPage, diff --git a/plugins/api-docs/api-report.md b/plugins/api-docs/api-report.md index ccae9e7d47..3bc6f4070a 100644 --- a/plugins/api-docs/api-report.md +++ b/plugins/api-docs/api-report.md @@ -47,7 +47,7 @@ const apiDocsPlugin: BackstagePlugin< root: RouteRef; }, { - registerComponent: ExternalRouteRef; + registerApi: ExternalRouteRef; } >; export { apiDocsPlugin }; diff --git a/plugins/api-docs/src/plugin.ts b/plugins/api-docs/src/plugin.ts index 4b69cc85ff..f1928f4443 100644 --- a/plugins/api-docs/src/plugin.ts +++ b/plugins/api-docs/src/plugin.ts @@ -45,7 +45,7 @@ export const apiDocsPlugin = createPlugin({ }), ], externalRoutes: { - registerComponent: registerComponentRouteRef, + registerApi: registerComponentRouteRef, }, }); From f8af53571deddc6c2a5c32c95161b3f2799f17b8 Mon Sep 17 00:00:00 2001 From: Kamil Zainal Date: Tue, 18 Jan 2022 18:22:03 +0000 Subject: [PATCH 8/9] Alter changeset to reflect changes local to the package Signed-off-by: Kamil Zainal --- .changeset/serious-roses-stare.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.changeset/serious-roses-stare.md b/.changeset/serious-roses-stare.md index b30676a355..ed6f20a6fa 100644 --- a/.changeset/serious-roses-stare.md +++ b/.changeset/serious-roses-stare.md @@ -2,5 +2,4 @@ '@backstage/plugin-api-docs': minor --- -Link 'Register Existing API' button on API page to /catalog-import instead of /create . -We now expect to `bind` the route for `apiDocsPlugin` to `registerComponent` instead of `createComponent`. +Renamed the `createComponent` external route to `registerApi` since it's now recommended to link to the entity registration page rather than the creation page. From 520332da2773e80986057bc81010424c637bd095 Mon Sep 17 00:00:00 2001 From: Kamil Zainal Date: Tue, 18 Jan 2022 18:24:44 +0000 Subject: [PATCH 9/9] Update to reflect rename Signed-off-by: Kamil Zainal --- packages/app/src/App.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/app/src/App.tsx b/packages/app/src/App.tsx index 360eca6152..21eb3aa38a 100644 --- a/packages/app/src/App.tsx +++ b/packages/app/src/App.tsx @@ -117,7 +117,7 @@ const app = createApp({ catalogEntity: catalogPlugin.routes.catalogEntity, }); bind(apiDocsPlugin.externalRoutes, { - registerComponent: catalogImportPlugin.routes.importPage, + registerApi: catalogImportPlugin.routes.importPage, }); bind(explorePlugin.externalRoutes, { catalogEntity: catalogPlugin.routes.catalogEntity,