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/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 };