diff --git a/packages/dev-utils/src/devApp/render.tsx b/packages/dev-utils/src/devApp/render.tsx
index 86a8b2f7cb..b14fbbf776 100644
--- a/packages/dev-utils/src/devApp/render.tsx
+++ b/packages/dev-utils/src/devApp/render.tsx
@@ -29,9 +29,25 @@ import {
AlertDisplay,
OAuthRequestDialog,
AnyApiFactory,
+ IconComponent,
+ BackstageRoutes,
+ attachComponentData,
} from '@backstage/core';
import SentimentDissatisfiedIcon from '@material-ui/icons/SentimentDissatisfied';
-import { Routes } from 'react-router';
+import { Outlet } from 'react-router';
+
+const GatheringRoute: (props: {
+ path: string;
+ children: JSX.Element;
+}) => JSX.Element = () => ;
+
+attachComponentData(GatheringRoute, 'core.gatherMountPoints', true);
+
+type RegisterPageOptions = {
+ element: JSX.Element;
+ title?: string;
+ icon?: IconComponent;
+};
// TODO(rugvip): export proper plugin type from core that isn't the plugin class
type BackstagePlugin = ReturnType;
@@ -44,6 +60,8 @@ class DevAppBuilder {
private readonly plugins = new Array();
private readonly apis = new Array();
private readonly rootChildren = new Array();
+ private readonly routes = new Array();
+ private readonly sidebarItems = new Array();
/**
* Register one or more plugins to render in the dev app
@@ -75,6 +93,21 @@ class DevAppBuilder {
return this;
}
+ addPage({ element, title, icon }: RegisterPageOptions): DevAppBuilder {
+ const path = `/page-${this.routes.length + 1}`;
+ this.sidebarItems.push(
+ ,
+ );
+ this.routes.push(
+ ,
+ );
+ return this;
+ }
/**
* Build a DevApp component using the resources registered so far
*/
@@ -100,7 +133,10 @@ class DevAppBuilder {
{sidebar}
- {deprecatedAppRoutes}
+
+ {this.routes}
+ {deprecatedAppRoutes}
+
@@ -166,6 +202,7 @@ class DevAppBuilder {
return (
+ {this.sidebarItems}
{sidebarItems}
);
@@ -199,7 +236,7 @@ class DevAppBuilder {
// this to provide their own plugin dev wrappers.
/**
- * Creates a dev app for rendering one or more plugins and exposing the touchpoints of the plugin.
+ * Creates a dev app for rendering one or more plugins and exposing the touch points of the plugin.
*/
export function createDevApp() {
return new DevAppBuilder();