diff --git a/src/App.tsx b/src/App.tsx index 79828b6bd..b92a1c6b5 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -3,7 +3,7 @@ import React from 'react'; import { HistoryRouter } from './components/HistoryRouter'; import { ApiProvider } from './hooks/useApi'; -import AppRoutes from './routes/index'; +import { AppRoutes } from './routes'; const App = ({ history }: { history: History }) => { return ( diff --git a/src/routes/asyncRoutes/index.tsx b/src/routes/AsyncRoute.tsx similarity index 80% rename from src/routes/asyncRoutes/index.tsx rename to src/routes/AsyncRoute.tsx index 9b9df27dd..ba5bc90c4 100644 --- a/src/routes/asyncRoutes/index.tsx +++ b/src/routes/AsyncRoute.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { Route } from 'react-router-dom'; -import AsyncPage from '../../components/AsyncPage'; +import AsyncPage from '../components/AsyncPage'; export interface AsyncRoute { /** The URL path for this route. */ @@ -17,6 +17,3 @@ export const toAsyncPageRoute = (route: AsyncRoute) => ( element={} /> ); - -export * from './admin'; -export * from './user'; diff --git a/src/routes/legacyRoutes/index.tsx b/src/routes/LegacyRoute.tsx similarity index 70% rename from src/routes/legacyRoutes/index.tsx rename to src/routes/LegacyRoute.tsx index 8f498f98a..f548a122c 100644 --- a/src/routes/legacyRoutes/index.tsx +++ b/src/routes/LegacyRoute.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { Route } from 'react-router-dom'; -import ViewManagerPage, { ViewManagerPageProps } from '../../components/viewManager/ViewManagerPage'; +import ViewManagerPage, { ViewManagerPageProps } from '../components/viewManager/ViewManagerPage'; export interface LegacyRoute { path: string, @@ -19,7 +19,3 @@ export function toViewManagerPageRoute(route: LegacyRoute) { /> ); } - -export * from './admin'; -export * from './public'; -export * from './user'; diff --git a/src/routes/asyncRoutes/user.ts b/src/routes/appRoutes/asyncRoutes/user.ts similarity index 67% rename from src/routes/asyncRoutes/user.ts rename to src/routes/appRoutes/asyncRoutes/user.ts index ef3ad7c4f..23621101b 100644 --- a/src/routes/asyncRoutes/user.ts +++ b/src/routes/appRoutes/asyncRoutes/user.ts @@ -1,4 +1,4 @@ -import { AsyncRoute } from '.'; +import { AsyncRoute } from '../../AsyncRoute'; export const ASYNC_USER_ROUTES: AsyncRoute[] = [ { path: 'search.html', page: 'search' } diff --git a/src/routes/appRoutes/index.tsx b/src/routes/appRoutes/index.tsx new file mode 100644 index 000000000..07736d6fc --- /dev/null +++ b/src/routes/appRoutes/index.tsx @@ -0,0 +1,42 @@ +import React from 'react'; +import { Navigate, Route, Routes } from 'react-router-dom'; + +import ConnectionRequired from '../../components/ConnectionRequired'; +import ServerContentPage from '../../components/ServerContentPage'; +import { toAsyncPageRoute } from '../AsyncRoute'; +import { toViewManagerPageRoute } from '../LegacyRoute'; +import { ASYNC_USER_ROUTES } from './asyncRoutes/user'; +import { LEGACY_ADMIN_ROUTES } from './legacyRoutes/admin'; +import { LEGACY_PUBLIC_ROUTES } from './legacyRoutes/public'; +import { LEGACY_USER_ROUTES } from './legacyRoutes/user'; + +export const AppRoutes = () => ( + + + {/* User routes */} + }> + {ASYNC_USER_ROUTES.map(toAsyncPageRoute)} + {LEGACY_USER_ROUTES.map(toViewManagerPageRoute)} + + + {/* Admin routes */} + }> + {LEGACY_ADMIN_ROUTES.map(toViewManagerPageRoute)} + + + } /> + + + {/* Public routes */} + }> + } /> + + {LEGACY_PUBLIC_ROUTES.map(toViewManagerPageRoute)} + + + {/* Suppress warnings for unhandled routes */} + + + +); diff --git a/src/routes/legacyRoutes/admin.ts b/src/routes/appRoutes/legacyRoutes/admin.ts similarity index 99% rename from src/routes/legacyRoutes/admin.ts rename to src/routes/appRoutes/legacyRoutes/admin.ts index 152e9f1b1..055f97c57 100644 --- a/src/routes/legacyRoutes/admin.ts +++ b/src/routes/appRoutes/legacyRoutes/admin.ts @@ -1,4 +1,4 @@ -import { LegacyRoute } from '.'; +import { LegacyRoute } from '../../LegacyRoute'; export const LEGACY_ADMIN_ROUTES: LegacyRoute[] = [ { diff --git a/src/routes/legacyRoutes/public.ts b/src/routes/appRoutes/legacyRoutes/public.ts similarity index 97% rename from src/routes/legacyRoutes/public.ts rename to src/routes/appRoutes/legacyRoutes/public.ts index 0e0587552..15f8f0e8a 100644 --- a/src/routes/legacyRoutes/public.ts +++ b/src/routes/appRoutes/legacyRoutes/public.ts @@ -1,4 +1,4 @@ -import { LegacyRoute } from '.'; +import { LegacyRoute } from '../../LegacyRoute'; export const LEGACY_PUBLIC_ROUTES: LegacyRoute[] = [ { diff --git a/src/routes/legacyRoutes/user.ts b/src/routes/appRoutes/legacyRoutes/user.ts similarity index 98% rename from src/routes/legacyRoutes/user.ts rename to src/routes/appRoutes/legacyRoutes/user.ts index ff5dc6ad8..4179907cb 100644 --- a/src/routes/legacyRoutes/user.ts +++ b/src/routes/appRoutes/legacyRoutes/user.ts @@ -1,4 +1,4 @@ -import { LegacyRoute } from '.'; +import { LegacyRoute } from '../../LegacyRoute'; export const LEGACY_USER_ROUTES: LegacyRoute[] = [ { diff --git a/src/routes/asyncRoutes/admin.ts b/src/routes/asyncRoutes/admin.ts deleted file mode 100644 index 2d001ed1e..000000000 --- a/src/routes/asyncRoutes/admin.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { AsyncRoute } from '.'; - -export const ASYNC_ADMIN_ROUTES: AsyncRoute[] = [ - { path: 'usernew.html', page: 'user/usernew' }, - { path: 'userprofiles.html', page: 'user/userprofiles' }, - { path: 'useredit.html', page: 'user/useredit' }, - { path: 'userlibraryaccess.html', page: 'user/userlibraryaccess' }, - { path: 'userparentalcontrol.html', page: 'user/userparentalcontrol' }, - { path: 'userpassword.html', page: 'user/userpassword' } -]; diff --git a/src/routes/index.tsx b/src/routes/index.tsx index a628efcf3..56f72e121 100644 --- a/src/routes/index.tsx +++ b/src/routes/index.tsx @@ -1,40 +1 @@ -import React from 'react'; -import { Navigate, Route, Routes } from 'react-router-dom'; - -import { ASYNC_USER_ROUTES, toAsyncPageRoute } from './asyncRoutes'; -import ConnectionRequired from '../components/ConnectionRequired'; -import ServerContentPage from '../components/ServerContentPage'; -import { LEGACY_ADMIN_ROUTES, LEGACY_PUBLIC_ROUTES, LEGACY_USER_ROUTES, toViewManagerPageRoute } from './legacyRoutes'; - -const AppRoutes = () => ( - - - {/* User routes */} - }> - {ASYNC_USER_ROUTES.map(toAsyncPageRoute)} - {LEGACY_USER_ROUTES.map(toViewManagerPageRoute)} - - - {/* Admin routes */} - }> - {LEGACY_ADMIN_ROUTES.map(toViewManagerPageRoute)} - - - } /> - - - {/* Public routes */} - }> - } /> - - {LEGACY_PUBLIC_ROUTES.map(toViewManagerPageRoute)} - - - {/* Suppress warnings for unhandled routes */} - - - -); - -export default AppRoutes; +export * from './appRoutes';