feat(plugin-explore): migrate to new routing api
This commit is contained in:
@@ -28,6 +28,7 @@ import { hot } from 'react-hot-loader/root';
|
||||
import { providers } from './identityProviders';
|
||||
import { Router as CatalogRouter } from '@backstage/plugin-catalog';
|
||||
import { Router as DocsRouter } from '@backstage/plugin-techdocs';
|
||||
import { Router as ExploreRouter } from '@backstage/plugin-explore';
|
||||
import { Route, Routes, Navigate } from 'react-router';
|
||||
|
||||
import { EntityPage } from './components/catalog/EntityPage';
|
||||
@@ -55,12 +56,13 @@ const deprecatedAppRoutes = app.getRoutes();
|
||||
|
||||
const AppRoutes = () => (
|
||||
<Routes>
|
||||
<Navigate key="/" to="/catalog" />
|
||||
<Route
|
||||
path="/catalog/*"
|
||||
element={<CatalogRouter EntityPage={EntityPage} />}
|
||||
/>
|
||||
<Route path="/docs/*" element={<DocsRouter />} />
|
||||
<Navigate key="/" to="/catalog" />
|
||||
<Route path="/explore/*" element={<ExploreRouter />} />
|
||||
{...deprecatedAppRoutes}
|
||||
</Routes>
|
||||
);
|
||||
|
||||
@@ -11,6 +11,8 @@ import { AppSidebar } from './sidebar';
|
||||
import { Route, Routes, Navigate } from 'react-router';
|
||||
import { Router as CatalogRouter } from '@backstage/plugin-catalog';
|
||||
import { Router as DocsRouter } from '@backstage/plugin-techdocs';
|
||||
import { Router as ExploreRouter } from '@backstage/plugin-explore';
|
||||
|
||||
import { EntityPage } from './components/catalog/EntityPage';
|
||||
|
||||
const app = createApp({
|
||||
@@ -30,12 +32,13 @@ const App: FC<{}> = () => (
|
||||
<SidebarPage>
|
||||
<AppSidebar />
|
||||
<Routes>
|
||||
<Navigate key="/" to="/catalog" />
|
||||
<Route
|
||||
path="/catalog/*"
|
||||
element={<CatalogRouter EntityPage={EntityPage} />}
|
||||
/>
|
||||
<Route path="/docs/*" element={<DocsRouter />} />
|
||||
<Navigate key="/" to="/catalog" />
|
||||
<Route path="/explore/*" element={<ExploreRouter />} />
|
||||
{deprecatedAppRoutes}
|
||||
</Routes>
|
||||
</SidebarPage>
|
||||
|
||||
@@ -29,7 +29,8 @@
|
||||
"classnames": "^2.2.6",
|
||||
"react": "^16.13.1",
|
||||
"react-dom": "^16.13.1",
|
||||
"react-use": "^15.3.3"
|
||||
"react-use": "^15.3.3",
|
||||
"react-router": "6.0.0-beta.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@backstage/cli": "^0.1.1-alpha.21",
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import React, { FC } from 'react';
|
||||
import React from 'react';
|
||||
import { makeStyles, Typography } from '@material-ui/core';
|
||||
import {
|
||||
Content,
|
||||
@@ -107,7 +107,7 @@ const toolsCards = [
|
||||
},
|
||||
];
|
||||
|
||||
const ExplorePluginPage: FC<{}> = () => {
|
||||
export const ExplorePluginPage = () => {
|
||||
const classes = useStyles();
|
||||
return (
|
||||
<Page theme={pageTheme.home}>
|
||||
@@ -130,5 +130,3 @@ const ExplorePluginPage: FC<{}> = () => {
|
||||
</Page>
|
||||
);
|
||||
};
|
||||
|
||||
export default ExplorePluginPage;
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import React from 'react';
|
||||
import { Route, Routes } from 'react-router';
|
||||
import { ExplorePluginPage } from './ExplorePluginPage';
|
||||
import { rootRouteRef } from '../plugin';
|
||||
|
||||
export const Router = () => (
|
||||
<Routes>
|
||||
<Route path={`/${rootRouteRef.path}`} element={<ExplorePluginPage />} />
|
||||
</Routes>
|
||||
);
|
||||
@@ -15,3 +15,4 @@
|
||||
*/
|
||||
|
||||
export { plugin } from './plugin';
|
||||
export { Router } from './components/Router';
|
||||
|
||||
@@ -14,12 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { createPlugin } from '@backstage/core';
|
||||
import ExplorePluginPage from './components/ExplorePluginPage';
|
||||
import { createPlugin, createRouteRef } from '@backstage/core';
|
||||
|
||||
export const rootRouteRef = createRouteRef({ path: '', title: 'Explore' });
|
||||
export const plugin = createPlugin({
|
||||
id: 'explore',
|
||||
register({ router }) {
|
||||
router.registerRoute('/explore', ExplorePluginPage);
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user