core-api: export SubRouteRef and make them assignable to plugin.routes

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2021-03-16 17:49:39 +01:00
parent ad19c23be6
commit a51dc0006e
5 changed files with 17 additions and 7 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/core-api': patch
---
Export `SubRouteRef` type, and allow `SubRouteRef`s to be assigned to `plugin.routes`.
+6
View File
@@ -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,
+3 -5
View File
@@ -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) => {
+2 -2
View File
@@ -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 };
+1
View File
@@ -16,6 +16,7 @@
export type {
RouteRef,
SubRouteRef,
AbsoluteRouteRef,
ConcreteRoute,
MutableRouteRef,