From 14e135c0f10e30f7abec2b83dfe48728aad034c6 Mon Sep 17 00:00:00 2001 From: Camila Belo Date: Sun, 15 Oct 2023 10:06:27 +0200 Subject: [PATCH] feat(catalog): provide external routes Signed-off-by: Camila Belo --- packages/app-next/app-config.yaml | 2 ++ plugins/catalog/src/alpha.tsx | 23 +++++++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/packages/app-next/app-config.yaml b/packages/app-next/app-config.yaml index eaaa2b0560..6f6081fece 100644 --- a/packages/app-next/app-config.yaml +++ b/packages/app-next/app-config.yaml @@ -4,6 +4,8 @@ app: routes: bindings: plugin.pages.externalRoutes.pageX: plugin.pages.routes.pageX + # waiting for https://github.com/backstage/backstage/pull/20605 + # catalog.externalRoutes.viewTechDoc: techdocs.routes.docRoot extensions: - apis.plugin.graphiql.browse.gitlab: true diff --git a/plugins/catalog/src/alpha.tsx b/plugins/catalog/src/alpha.tsx index 0a6a093b7a..bc568cafd2 100644 --- a/plugins/catalog/src/alpha.tsx +++ b/plugins/catalog/src/alpha.tsx @@ -22,6 +22,7 @@ import { fetchApiRef, storageApiRef, } from '@backstage/core-plugin-api'; +import { convertLegacyRouteRef } from '@backstage/core-plugin-api/alpha'; import { CatalogClient } from '@backstage/catalog-client'; import { createSchemaFromZod, @@ -44,7 +45,12 @@ import { } from '@backstage/plugin-catalog-react'; import { createSearchResultListItemExtension } from '@backstage/plugin-search-react/alpha'; import { DefaultStarredEntitiesApi } from './apis'; -import { rootRouteRef } from './routes'; +import { + createComponentRouteRef, + createFromTemplateRouteRef, + rootRouteRef, + viewTechDocRouteRef, +} from './routes'; import { Progress } from '@backstage/core-components'; import { useEntityFromUrl } from './components/CatalogEntityPage/useEntityFromUrl'; @@ -213,7 +219,7 @@ const CatalogUserListFilter = createCatalogFilterExtension({ const CatalogIndexPage = createPageExtension({ id: 'catalog', defaultPath: '/catalog', - routeRef: rootRouteRef, + routeRef: convertLegacyRouteRef(rootRouteRef), inputs: { filters: createExtensionInput({ element: coreExtensionData.reactElement, @@ -229,7 +235,7 @@ const CatalogIndexPage = createPageExtension({ const CatalogEntityPage = createPageExtension({ id: 'catalog:entity', defaultPath: '/catalog/:namespace/:kind/:name', - routeRef: entityRouteRef, + routeRef: convertLegacyRouteRef(entityRouteRef), loader: async () => { const Component = () => { return ( @@ -244,7 +250,7 @@ const CatalogEntityPage = createPageExtension({ const CatalogNavItem = createNavItemExtension({ id: 'catalog.nav.index', - routeRef: rootRouteRef, + routeRef: convertLegacyRouteRef(rootRouteRef), title: 'Catalog', icon: HomeIcon, }); @@ -252,6 +258,15 @@ const CatalogNavItem = createNavItemExtension({ /** @alpha */ export default createPlugin({ id: 'catalog', + routes: { + catalogIndex: convertLegacyRouteRef(rootRouteRef), + catalogEntity: convertLegacyRouteRef(entityRouteRef), + }, + externalRoutes: { + viewTechDoc: convertLegacyRouteRef(viewTechDocRouteRef), + createComponent: convertLegacyRouteRef(createComponentRouteRef), + createFromTemplate: convertLegacyRouteRef(createFromTemplateRouteRef), + }, extensions: [ CatalogApi, StarredEntitiesApi,