Merge pull request #22200 from backstage/camilal/fix-new-plugin-subroute-type
[Frontend System] Fix plugin subroute creation
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
---
|
||||
'@backstage/frontend-plugin-api': patch
|
||||
'@backstage/frontend-app-api': patch
|
||||
---
|
||||
|
||||
Accepts sub route refs on the new `createPlugin` routes map.
|
||||
@@ -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}`;
|
||||
|
||||
@@ -180,7 +180,7 @@ export type AnyRouteRefParams =
|
||||
|
||||
// @public (undocumented)
|
||||
export type AnyRoutes = {
|
||||
[name in string]: RouteRef;
|
||||
[name in string]: RouteRef | SubRouteRef;
|
||||
};
|
||||
|
||||
export { ApiFactory };
|
||||
|
||||
@@ -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 };
|
||||
|
||||
Reference in New Issue
Block a user