core-api: export SubRouteRef and make them assignable to plugin.routes
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/core-api': patch
|
||||
---
|
||||
|
||||
Export `SubRouteRef` type, and allow `SubRouteRef`s to be assigned to `plugin.routes`.
|
||||
@@ -98,6 +98,12 @@ describe('Integration Test', () => {
|
||||
|
||||
const plugin1 = createPlugin({
|
||||
id: 'blob',
|
||||
// Both absolute and sub route refs should be assignable to the plugin routes
|
||||
routes: {
|
||||
ref1: plugin1RouteRef,
|
||||
ref2: plugin2RouteRef,
|
||||
ref3: subRouteRef1,
|
||||
},
|
||||
externalRoutes: {
|
||||
extRouteRef1,
|
||||
extRouteRef2,
|
||||
|
||||
@@ -53,7 +53,7 @@ import {
|
||||
import { IconComponent, IconComponentMap, IconKey } from '../icons';
|
||||
import { BackstagePlugin } from '../plugin';
|
||||
import { AnyRoutes } from '../plugin/types';
|
||||
import { RouteRef, ExternalRouteRef } from '../routing';
|
||||
import { RouteRef, ExternalRouteRef, SubRouteRef } from '../routing';
|
||||
import {
|
||||
routeObjectCollector,
|
||||
routeParentCollector,
|
||||
@@ -75,10 +75,8 @@ import {
|
||||
SignInResult,
|
||||
} from './types';
|
||||
|
||||
export function generateBoundRoutes(
|
||||
bindRoutes: AppOptions['bindRoutes'],
|
||||
): Map<ExternalRouteRef, RouteRef> {
|
||||
const result = new Map<ExternalRouteRef, RouteRef>();
|
||||
export function generateBoundRoutes(bindRoutes: AppOptions['bindRoutes']) {
|
||||
const result = new Map<ExternalRouteRef, RouteRef | SubRouteRef>();
|
||||
|
||||
if (bindRoutes) {
|
||||
const bind: AppRouteBinder = (externalRoutes, targetRoutes: AnyRoutes) => {
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
import { ComponentType } from 'react';
|
||||
import { RouteRef, ExternalRouteRef } from '../routing';
|
||||
import { RouteRef, SubRouteRef, ExternalRouteRef } from '../routing';
|
||||
import { AnyApiFactory } from '../apis/system';
|
||||
|
||||
export type RouteOptions = {
|
||||
@@ -70,7 +70,7 @@ export type Extension<T> = {
|
||||
expose(plugin: BackstagePlugin<any, any>): T;
|
||||
};
|
||||
|
||||
export type AnyRoutes = { [name: string]: RouteRef<any> };
|
||||
export type AnyRoutes = { [name: string]: RouteRef | SubRouteRef };
|
||||
|
||||
export type AnyExternalRoutes = { [name: string]: ExternalRouteRef };
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
export type {
|
||||
RouteRef,
|
||||
SubRouteRef,
|
||||
AbsoluteRouteRef,
|
||||
ConcreteRoute,
|
||||
MutableRouteRef,
|
||||
|
||||
Reference in New Issue
Block a user