Add support for Pages and Sidebar items in existing app
Co-authored-by: Fredrik Adelöw <freben@gmail.com> Co-authored-by: Patrik Oldsberg <poldsberg@gmail.com> Co-authored-by: Camila Belo <camilaibs@gmail.com> Co-authored-by: Philipp Hugenroth <philipph@spotify.com> Signed-off-by: Johan Haals <johan.haals@gmail.com>
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
"@backstage/core-app-api": "workspace:^",
|
||||
"@backstage/core-components": "workspace:^",
|
||||
"@backstage/core-plugin-api": "workspace:^",
|
||||
"@backstage/frontend-app-api": "workspace:^",
|
||||
"@backstage/integration-react": "workspace:^",
|
||||
"@backstage/plugin-adr": "workspace:^",
|
||||
"@backstage/plugin-airbrake": "workspace:^",
|
||||
|
||||
@@ -27,7 +27,13 @@ import {
|
||||
RELATION_PROVIDES_API,
|
||||
} from '@backstage/catalog-model';
|
||||
import { createApp } from '@backstage/app-defaults';
|
||||
import { AppRouter, FeatureFlagged, FlatRoutes } from '@backstage/core-app-api';
|
||||
import {
|
||||
AppRouter,
|
||||
ConfigReader,
|
||||
defaultConfigLoader,
|
||||
FeatureFlagged,
|
||||
FlatRoutes,
|
||||
} from '@backstage/core-app-api';
|
||||
import {
|
||||
AlertDisplay,
|
||||
OAuthRequestDialog,
|
||||
@@ -55,7 +61,6 @@ import {
|
||||
import { orgPlugin } from '@backstage/plugin-org';
|
||||
import { ExplorePage } from '@backstage/plugin-explore';
|
||||
import { GcpProjectsPage } from '@backstage/plugin-gcp-projects';
|
||||
import { GraphiQLPage } from '@backstage/plugin-graphiql';
|
||||
import { HomepageCompositionRoot } from '@backstage/plugin-home';
|
||||
import { LighthousePage } from '@backstage/plugin-lighthouse';
|
||||
import { NewRelicPage } from '@backstage/plugin-newrelic';
|
||||
@@ -112,6 +117,7 @@ import { PuppetDbPage } from '@backstage/plugin-puppetdb';
|
||||
import { DevToolsPage } from '@backstage/plugin-devtools';
|
||||
import { customDevToolsPage } from './components/devtools/CustomDevToolsPage';
|
||||
import { CatalogUnprocessedEntitiesPage } from '@backstage/plugin-catalog-unprocessed-entities';
|
||||
import { createExtensionTree } from '@backstage/frontend-app-api';
|
||||
|
||||
const app = createApp({
|
||||
apis,
|
||||
@@ -158,6 +164,11 @@ const app = createApp({
|
||||
},
|
||||
});
|
||||
|
||||
/* HIGHLY EXPERIMENTAL. DO NOT USE THIS IN YOUR APP */
|
||||
const extensionTree = createExtensionTree({
|
||||
config: ConfigReader.fromConfigs(await defaultConfigLoader()),
|
||||
});
|
||||
|
||||
const routes = (
|
||||
<FlatRoutes>
|
||||
<Route path="/" element={<Navigate to="catalog" />} />
|
||||
@@ -271,7 +282,9 @@ const routes = (
|
||||
path="/tech-radar"
|
||||
element={<TechRadarPage width={1500} height={800} />}
|
||||
/>
|
||||
<Route path="/graphiql" element={<GraphiQLPage />} />
|
||||
{
|
||||
/* HIGHLY EXPERIMENTAL. DO NOT USE THIS IN YOUR APP */ extensionTree.getRootRoutes()
|
||||
}
|
||||
<Route path="/lighthouse" element={<LighthousePage />} />
|
||||
<Route path="/api-docs" element={<ApiExplorerPage />} />
|
||||
<Route path="/gcp-projects" element={<GcpProjectsPage />} />
|
||||
@@ -310,7 +323,7 @@ export default app.createRoot(
|
||||
<AlertDisplay transientTimeoutMs={2500} />
|
||||
<OAuthRequestDialog />
|
||||
<AppRouter>
|
||||
<Root>{routes}</Root>
|
||||
<Root extensionTree={extensionTree}>{routes}</Root>
|
||||
</AppRouter>
|
||||
</>,
|
||||
);
|
||||
|
||||
@@ -27,7 +27,6 @@ import MenuIcon from '@material-ui/icons/Menu';
|
||||
import MoneyIcon from '@material-ui/icons/MonetizationOn';
|
||||
import LogoFull from './LogoFull';
|
||||
import LogoIcon from './LogoIcon';
|
||||
import { GraphiQLIcon } from '@backstage/plugin-graphiql';
|
||||
import {
|
||||
Settings as SidebarSettings,
|
||||
UserSettingsSignInAvatar,
|
||||
@@ -53,6 +52,7 @@ import { SearchModal } from '../search/SearchModal';
|
||||
import Score from '@material-ui/icons/Score';
|
||||
import { useApp } from '@backstage/core-plugin-api';
|
||||
import BuildIcon from '@material-ui/icons/Build';
|
||||
import { ExtensionTree } from '@backstage/frontend-app-api';
|
||||
|
||||
const useSidebarLogoStyles = makeStyles({
|
||||
root: {
|
||||
@@ -82,7 +82,10 @@ const SidebarLogo = () => {
|
||||
);
|
||||
};
|
||||
|
||||
export const Root = ({ children }: PropsWithChildren<{}>) => (
|
||||
export const Root = ({
|
||||
children,
|
||||
extensionTree,
|
||||
}: PropsWithChildren<{ extensionTree: ExtensionTree }>) => (
|
||||
<SidebarPage>
|
||||
<Sidebar>
|
||||
<SidebarLogo />
|
||||
@@ -163,7 +166,9 @@ export const Root = ({ children }: PropsWithChildren<{}>) => (
|
||||
to="cost-insights"
|
||||
text="Cost Insights"
|
||||
/>
|
||||
<SidebarItem icon={GraphiQLIcon} to="graphiql" text="GraphiQL" />
|
||||
{
|
||||
/* HIGHLY EXPERIMENTAL. DO NOT USE THIS IN YOUR APP */ extensionTree.getSidebarItems()
|
||||
}
|
||||
<SidebarItem icon={Score} to="score-board" text="Score board" />
|
||||
</SidebarScrollWrapper>
|
||||
<SidebarDivider />
|
||||
|
||||
Reference in New Issue
Block a user