From 8adb0759ea2a5a975fac2fa22b6ddfc59a00e68d Mon Sep 17 00:00:00 2001 From: Camila Belo Date: Mon, 5 Feb 2024 16:35:52 +0100 Subject: [PATCH] feat(api-docs): migrate explorer page to new system Signed-off-by: Camila Belo --- plugins/api-docs/src/alpha.tsx | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/plugins/api-docs/src/alpha.tsx b/plugins/api-docs/src/alpha.tsx index 6449af0460..d8cc0265eb 100644 --- a/plugins/api-docs/src/alpha.tsx +++ b/plugins/api-docs/src/alpha.tsx @@ -14,10 +14,14 @@ * limitations under the License. */ +import React from 'react'; + import { createApiExtension, createApiFactory, + createPageExtension, createPlugin, + createSchemaFromZod, } from '@backstage/frontend-plugin-api'; import { convertLegacyRouteRef } from '@backstage/core-compat-api'; import { ApiEntity } from '@backstage/catalog-model'; @@ -41,6 +45,23 @@ const ApiDocsConfigApi = createApiExtension({ }), }); +const ApiDocsExplorerPage = createPageExtension({ + defaultPath: '/api-docs', + routeRef: convertLegacyRouteRef(rootRoute), + // Mapping DefaultApiExplorerPageProps to config + configSchema: createSchemaFromZod(z => + z.object({ + path: z.string().default('/api-docs'), + initiallySelectedFilter: z.enum(['owned', 'starred', 'all']).optional(), + // Ommiting columns and actions for now as their types are too complex to map to zod + }), + ), + loader: () => + import('./components/ApiExplorerPage').then(m => ( + + )), +}); + export default createPlugin({ id: 'api-docs', routes: { @@ -49,5 +70,5 @@ export default createPlugin({ externalRoutes: { registerApi: convertLegacyRouteRef(registerComponentRouteRef), }, - extensions: [ApiDocsConfigApi], + extensions: [ApiDocsConfigApi, ApiDocsExplorerPage], });