diff --git a/plugins/catalog/src/alpha.tsx b/plugins/catalog/src/alpha.tsx index 5e78a52f9b..e34830f21d 100644 --- a/plugins/catalog/src/alpha.tsx +++ b/plugins/catalog/src/alpha.tsx @@ -14,6 +14,8 @@ * limitations under the License. */ +import React from 'react'; +import HomeIcon from '@material-ui/icons/Home'; import { createApiFactory, discoveryApiRef, @@ -22,8 +24,11 @@ import { } from '@backstage/core-plugin-api'; import { CatalogClient } from '@backstage/catalog-client'; import { + createSchemaFromZod, createApiExtension, + createPageExtension, createPlugin, + createNavItemExtension, } from '@backstage/frontend-plugin-api'; import { catalogApiRef, @@ -31,6 +36,7 @@ import { } from '@backstage/plugin-catalog-react'; import { createSearchResultListItemExtension } from '@backstage/plugin-search-react/alpha'; import { DefaultStarredEntitiesApi } from './apis'; +import { rootRouteRef } from './routes'; /** @alpha */ export const CatalogApi = createApiExtension({ @@ -65,6 +71,41 @@ export const CatalogSearchResultListItemExtension = ), }); +/** @alpha */ +export const CatalogIndexPage = createPageExtension({ + id: 'catalog', + routeRef: rootRouteRef, + configSchema: createSchemaFromZod(z => + z.object({ + path: z.string().default('/catalog'), + initialKind: z.string().default('component'), + initiallySelectedFilter: z + .enum(['owned', 'starred', 'all']) + .default('owned'), + ownerPickerMode: z.enum(['owners-only', 'all']).optional(), + }), + ), + loader: async ({ config }) => { + const { CatalogPage } = await import('./components/CatalogPage'); + const { ownerPickerMode, initialKind, initiallySelectedFilter } = config; + + return ( + + ); + }, +}); + +const CatalogNavItem = createNavItemExtension({ + id: 'catalog.nav.index', + routeRef: rootRouteRef, + title: 'Catalog', + icon: HomeIcon, +}); + /** @alpha */ export default createPlugin({ id: 'catalog', @@ -72,5 +113,7 @@ export default createPlugin({ CatalogApi, StarredEntitiesApi, CatalogSearchResultListItemExtension, + CatalogNavItem, + CatalogIndexPage, ], });