2023-04-27 17:04:33 -04:00
|
|
|
import React from 'react';
|
2023-06-01 12:12:16 -04:00
|
|
|
import { Navigate, Outlet, Route, Routes } from 'react-router-dom';
|
2023-04-27 17:04:33 -04:00
|
|
|
|
2023-06-01 12:12:16 -04:00
|
|
|
import AppHeader from 'components/AppHeader';
|
|
|
|
import Backdrop from 'components/Backdrop';
|
|
|
|
import ServerContentPage from 'components/ServerContentPage';
|
|
|
|
import ConnectionRequired from 'components/ConnectionRequired';
|
|
|
|
import { toAsyncPageRoute } from 'components/router/AsyncRoute';
|
|
|
|
import { toViewManagerPageRoute } from 'components/router/LegacyRoute';
|
2023-04-27 17:04:33 -04:00
|
|
|
|
2023-06-01 12:12:16 -04:00
|
|
|
import { ASYNC_ADMIN_ROUTES, ASYNC_USER_ROUTES } from './routes/asyncRoutes';
|
|
|
|
import { LEGACY_ADMIN_ROUTES, LEGACY_PUBLIC_ROUTES, LEGACY_USER_ROUTES } from './routes/legacyRoutes';
|
2023-09-15 10:31:48 -04:00
|
|
|
import { REDIRECTS } from './routes/_redirects';
|
|
|
|
import { toRedirectRoute } from 'components/router/Redirect';
|
2023-06-01 12:12:16 -04:00
|
|
|
|
|
|
|
const Layout = () => (
|
2023-04-27 17:04:33 -04:00
|
|
|
<>
|
|
|
|
<Backdrop />
|
|
|
|
<AppHeader />
|
|
|
|
|
|
|
|
<div className='mainAnimatedPages skinBody' />
|
|
|
|
<div className='skinBody'>
|
2023-06-01 12:12:16 -04:00
|
|
|
<Outlet />
|
2023-04-27 17:04:33 -04:00
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
|
2023-06-01 12:12:16 -04:00
|
|
|
const StableApp = () => (
|
|
|
|
<Routes>
|
|
|
|
<Route element={<Layout />}>
|
|
|
|
{/* User routes */}
|
|
|
|
<Route path='/' element={<ConnectionRequired />}>
|
|
|
|
{ASYNC_USER_ROUTES.map(toAsyncPageRoute)}
|
|
|
|
{LEGACY_USER_ROUTES.map(toViewManagerPageRoute)}
|
|
|
|
</Route>
|
|
|
|
|
|
|
|
{/* Admin routes */}
|
|
|
|
<Route path='/' element={<ConnectionRequired isAdminRequired />}>
|
|
|
|
{ASYNC_ADMIN_ROUTES.map(toAsyncPageRoute)}
|
|
|
|
{LEGACY_ADMIN_ROUTES.map(toViewManagerPageRoute)}
|
|
|
|
|
|
|
|
<Route path='configurationpage' element={
|
|
|
|
<ServerContentPage view='/web/configurationpage' />
|
|
|
|
} />
|
|
|
|
</Route>
|
|
|
|
|
|
|
|
{/* Public routes */}
|
|
|
|
<Route path='/' element={<ConnectionRequired isUserRequired={false} />}>
|
|
|
|
<Route index element={<Navigate replace to='/home.html' />} />
|
|
|
|
|
|
|
|
{LEGACY_PUBLIC_ROUTES.map(toViewManagerPageRoute)}
|
|
|
|
</Route>
|
|
|
|
|
|
|
|
{/* Suppress warnings for unhandled routes */}
|
|
|
|
<Route path='*' element={null} />
|
2023-06-09 03:01:27 -04:00
|
|
|
|
|
|
|
{/* Redirects for old paths */}
|
2023-09-15 10:31:48 -04:00
|
|
|
{REDIRECTS.map(toRedirectRoute)}
|
2023-06-01 12:12:16 -04:00
|
|
|
</Route>
|
|
|
|
</Routes>
|
|
|
|
);
|
|
|
|
|
2023-04-27 17:04:33 -04:00
|
|
|
export default StableApp;
|