mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Preparing for experimental app routes
This commit is contained in:
parent
4ea9f0147a
commit
12c1ae3590
10 changed files with 50 additions and 64 deletions
|
@ -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 (
|
||||
|
|
|
@ -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={<AsyncPage page={route.page} />}
|
||||
/>
|
||||
);
|
||||
|
||||
export * from './admin';
|
||||
export * from './user';
|
|
@ -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';
|
|
@ -1,4 +1,4 @@
|
|||
import { AsyncRoute } from '.';
|
||||
import { AsyncRoute } from '../../AsyncRoute';
|
||||
|
||||
export const ASYNC_USER_ROUTES: AsyncRoute[] = [
|
||||
{ path: 'search.html', page: 'search' }
|
42
src/routes/appRoutes/index.tsx
Normal file
42
src/routes/appRoutes/index.tsx
Normal file
|
@ -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 = () => (
|
||||
<Routes>
|
||||
<Route path='/'>
|
||||
{/* User routes */}
|
||||
<Route path='/' element={<ConnectionRequired />}>
|
||||
{ASYNC_USER_ROUTES.map(toAsyncPageRoute)}
|
||||
{LEGACY_USER_ROUTES.map(toViewManagerPageRoute)}
|
||||
</Route>
|
||||
|
||||
{/* Admin routes */}
|
||||
<Route path='/' element={<ConnectionRequired isAdminRequired />}>
|
||||
{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} />
|
||||
</Route>
|
||||
</Routes>
|
||||
);
|
|
@ -1,4 +1,4 @@
|
|||
import { LegacyRoute } from '.';
|
||||
import { LegacyRoute } from '../../LegacyRoute';
|
||||
|
||||
export const LEGACY_ADMIN_ROUTES: LegacyRoute[] = [
|
||||
{
|
|
@ -1,4 +1,4 @@
|
|||
import { LegacyRoute } from '.';
|
||||
import { LegacyRoute } from '../../LegacyRoute';
|
||||
|
||||
export const LEGACY_PUBLIC_ROUTES: LegacyRoute[] = [
|
||||
{
|
|
@ -1,4 +1,4 @@
|
|||
import { LegacyRoute } from '.';
|
||||
import { LegacyRoute } from '../../LegacyRoute';
|
||||
|
||||
export const LEGACY_USER_ROUTES: LegacyRoute[] = [
|
||||
{
|
|
@ -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' }
|
||||
];
|
|
@ -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 = () => (
|
||||
<Routes>
|
||||
<Route path='/'>
|
||||
{/* User routes */}
|
||||
<Route path='/' element={<ConnectionRequired />}>
|
||||
{ASYNC_USER_ROUTES.map(toAsyncPageRoute)}
|
||||
{LEGACY_USER_ROUTES.map(toViewManagerPageRoute)}
|
||||
</Route>
|
||||
|
||||
{/* Admin routes */}
|
||||
<Route path='/' element={<ConnectionRequired isAdminRequired />}>
|
||||
{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} />
|
||||
</Route>
|
||||
</Routes>
|
||||
);
|
||||
|
||||
export default AppRoutes;
|
||||
export * from './appRoutes';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue