2023-09-20 16:25:11 -04:00
|
|
|
import loadable from '@loadable/component';
|
2023-09-20 00:02:26 -04:00
|
|
|
import React from 'react';
|
|
|
|
import { Route, Routes } from 'react-router-dom';
|
|
|
|
|
|
|
|
import ConnectionRequired from 'components/ConnectionRequired';
|
|
|
|
import { toViewManagerPageRoute } from 'components/router/LegacyRoute';
|
2023-09-20 16:25:11 -04:00
|
|
|
import { AsyncPageProps, AsyncRoute, toAsyncPageRoute } from 'components/router/AsyncRoute';
|
2023-09-20 00:02:26 -04:00
|
|
|
import { toRedirectRoute } from 'components/router/Redirect';
|
|
|
|
import ServerContentPage from 'components/ServerContentPage';
|
|
|
|
|
|
|
|
import { REDIRECTS } from './routes/_redirects';
|
|
|
|
import { ASYNC_ADMIN_ROUTES } from './routes/_asyncRoutes';
|
|
|
|
import { LEGACY_ADMIN_ROUTES } from './routes/_legacyRoutes';
|
|
|
|
import AppLayout from './AppLayout';
|
|
|
|
|
2023-09-20 16:25:11 -04:00
|
|
|
const DashboardAsyncPage = loadable(
|
|
|
|
(props: { page: string }) => import(/* webpackChunkName: "[request]" */ `./routes/${props.page}`),
|
|
|
|
{ cacheKey: (props: AsyncPageProps) => props.page }
|
|
|
|
);
|
|
|
|
|
|
|
|
const toDashboardAsyncPageRoute = (route: AsyncRoute) => (
|
|
|
|
toAsyncPageRoute({
|
|
|
|
...route,
|
|
|
|
element: DashboardAsyncPage
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
2023-09-20 00:02:26 -04:00
|
|
|
const DashboardApp = () => (
|
|
|
|
<Routes>
|
|
|
|
<Route element={<ConnectionRequired isAdminRequired />}>
|
|
|
|
<Route element={<AppLayout />}>
|
|
|
|
<Route path='dashboard'>
|
2023-09-20 16:25:11 -04:00
|
|
|
{ASYNC_ADMIN_ROUTES.map(toDashboardAsyncPageRoute)}
|
2023-09-20 00:02:26 -04:00
|
|
|
{LEGACY_ADMIN_ROUTES.map(toViewManagerPageRoute)}
|
|
|
|
</Route>
|
|
|
|
|
|
|
|
{/* TODO: Should the metadata manager be a separate app? */}
|
|
|
|
{toViewManagerPageRoute({
|
|
|
|
path: 'metadata',
|
|
|
|
pageProps: {
|
|
|
|
controller: 'edititemmetadata',
|
|
|
|
view: 'edititemmetadata.html'
|
|
|
|
}
|
|
|
|
})}
|
|
|
|
|
|
|
|
<Route path='configurationpage' element={
|
|
|
|
<ServerContentPage view='/web/configurationpage' />
|
|
|
|
} />
|
|
|
|
|
|
|
|
{/* Suppress warnings for unhandled routes */}
|
|
|
|
<Route path='*' element={null} />
|
|
|
|
</Route>
|
|
|
|
</Route>
|
|
|
|
|
|
|
|
{/* Redirects for old paths */}
|
|
|
|
{REDIRECTS.map(toRedirectRoute)}
|
|
|
|
</Routes>
|
|
|
|
);
|
|
|
|
|
|
|
|
export default DashboardApp;
|