diff --git a/.changeset/large-pens-cough.md b/.changeset/large-pens-cough.md new file mode 100644 index 0000000000..631a20aee2 --- /dev/null +++ b/.changeset/large-pens-cough.md @@ -0,0 +1,6 @@ +--- +'@backstage/frontend-plugin-api': patch +'@backstage/frontend-app-api': patch +--- + +Accepts sub route refs on the new `createPlugin` routes map. diff --git a/packages/frontend-app-api/src/routing/collectRouteIds.ts b/packages/frontend-app-api/src/routing/collectRouteIds.ts index 1d6aa14e5d..2fbb8b6791 100644 --- a/packages/frontend-app-api/src/routing/collectRouteIds.ts +++ b/packages/frontend-app-api/src/routing/collectRouteIds.ts @@ -21,9 +21,14 @@ import { FrontendFeature, } from '@backstage/frontend-plugin-api'; // eslint-disable-next-line @backstage/no-relative-monorepo-imports -import { toInternalRouteRef } from '../../../frontend-plugin-api/src/routing/RouteRef'; +import { + isRouteRef, + toInternalRouteRef, +} from '../../../frontend-plugin-api/src/routing/RouteRef'; // eslint-disable-next-line @backstage/no-relative-monorepo-imports import { toInternalExternalRouteRef } from '../../../frontend-plugin-api/src/routing/ExternalRouteRef'; +// eslint-disable-next-line @backstage/no-relative-monorepo-imports +import { toInternalSubRouteRef } from '../../../frontend-plugin-api/src/routing/SubRouteRef'; /** @internal */ export interface RouteRefsById { @@ -47,9 +52,14 @@ export function collectRouteIds(features: FrontendFeature[]): RouteRefsById { throw new Error(`Unexpected duplicate route '${refId}'`); } - const internalRef = toInternalRouteRef(ref); - internalRef.setId(refId); - routesById.set(refId, ref); + if (isRouteRef(ref)) { + const internalRef = toInternalRouteRef(ref); + internalRef.setId(refId); + routesById.set(refId, ref); + } else { + const internalRef = toInternalSubRouteRef(ref); + routesById.set(refId, internalRef); + } } for (const [name, ref] of Object.entries(feature.externalRoutes)) { const refId = `plugin.${feature.id}.externalRoutes.${name}`; diff --git a/packages/frontend-plugin-api/api-report.md b/packages/frontend-plugin-api/api-report.md index a292634d9a..2260db334f 100644 --- a/packages/frontend-plugin-api/api-report.md +++ b/packages/frontend-plugin-api/api-report.md @@ -180,7 +180,7 @@ export type AnyRouteRefParams = // @public (undocumented) export type AnyRoutes = { - [name in string]: RouteRef; + [name in string]: RouteRef | SubRouteRef; }; export { ApiFactory }; diff --git a/packages/frontend-plugin-api/src/wiring/types.ts b/packages/frontend-plugin-api/src/wiring/types.ts index c2a6b09ba7..7e0650e06c 100644 --- a/packages/frontend-plugin-api/src/wiring/types.ts +++ b/packages/frontend-plugin-api/src/wiring/types.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { ExternalRouteRef, RouteRef } from '../routing'; +import { ExternalRouteRef, RouteRef, SubRouteRef } from '../routing'; /** * Feature flag configuration. @@ -27,7 +27,7 @@ export type FeatureFlagConfig = { }; /** @public */ -export type AnyRoutes = { [name in string]: RouteRef }; +export type AnyRoutes = { [name in string]: RouteRef | SubRouteRef }; /** @public */ export type AnyExternalRoutes = { [name in string]: ExternalRouteRef };