diff --git a/.changeset/five-baboons-explain.md b/.changeset/five-baboons-explain.md new file mode 100644 index 0000000000..b30c1a6237 --- /dev/null +++ b/.changeset/five-baboons-explain.md @@ -0,0 +1,5 @@ +--- +'@backstage/dev-utils': minor +--- + +Removed support for deprecated registered plugin routes. All routes now need to be added using `addPage` instead. diff --git a/packages/dev-utils/src/devApp/render.tsx b/packages/dev-utils/src/devApp/render.tsx index 06975df20f..271c8d70cf 100644 --- a/packages/dev-utils/src/devApp/render.tsx +++ b/packages/dev-utils/src/devApp/render.tsx @@ -39,7 +39,6 @@ import { } from '@backstage/integration-react'; import { Box } from '@material-ui/core'; import BookmarkIcon from '@material-ui/icons/Bookmark'; -import SentimentDissatisfiedIcon from '@material-ui/icons/SentimentDissatisfied'; import React, { ComponentType, ReactNode } from 'react'; import ReactDOM from 'react-dom'; import { hot } from 'react-hot-loader'; @@ -75,6 +74,8 @@ class DevAppBuilder { private readonly routes = new Array(); private readonly sidebarItems = new Array(); + private defaultPage?: string; + /** * Register one or more plugins to render in the dev app */ @@ -113,6 +114,11 @@ class DevAppBuilder { */ addPage(opts: RegisterPageOptions): DevAppBuilder { const path = opts.path ?? `/page-${this.routes.length + 1}`; + + if (!this.defaultPage || path === '/') { + this.defaultPage = path; + } + if (opts.title) { this.sidebarItems.push( { return ( @@ -181,10 +184,12 @@ class DevAppBuilder { {this.rootChildren} - {sidebar} + + + {this.sidebarItems} + {this.routes} - {deprecatedAppRoutes} } /> @@ -207,84 +212,12 @@ class DevAppBuilder { const DevApp = hot(hotModule)(this.build()); - const paths = this.findPluginPaths(this.plugins); - - if (window.location.pathname === '/') { - if (!paths.includes('/') && paths.length > 0) { - window.location.pathname = paths[0]; - } + if (window.location.pathname === '/' && this.defaultPage) { + window.location.pathname = this.defaultPage; } ReactDOM.render(, document.getElementById('root')); } - - // Create a sidebar that exposes the touchpoints of a plugin - private setupSidebar(plugins: BackstagePlugin[]): JSX.Element { - const sidebarItems = new Array(); - for (const plugin of plugins) { - for (const output of plugin.output()) { - switch (output.type) { - case 'legacy-route': { - const { path } = output; - sidebarItems.push( - , - ); - break; - } - case 'route': { - const { target } = output; - sidebarItems.push( - , - ); - break; - } - default: - break; - } - } - } - - return ( - - - {this.sidebarItems} - {sidebarItems} - - ); - } - - private findPluginPaths(plugins: BackstagePlugin[]) { - const paths = new Array(); - - for (const plugin of plugins) { - for (const output of plugin.output()) { - switch (output.type) { - case 'legacy-route': { - paths.push(output.path); - break; - } - case 'route': { - paths.push(output.target.path); - break; - } - default: - break; - } - } - } - - return paths; - } } // TODO(rugvip): Figure out patterns for how to allow in-house apps to build upon