1
0
Fork 0
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:
grafixeyehero 2023-04-13 00:33:32 +03:00 committed by Bill Thornton
parent 4ea9f0147a
commit 12c1ae3590
10 changed files with 50 additions and 64 deletions

View file

@ -3,7 +3,7 @@ import React from 'react';
import { HistoryRouter } from './components/HistoryRouter'; import { HistoryRouter } from './components/HistoryRouter';
import { ApiProvider } from './hooks/useApi'; import { ApiProvider } from './hooks/useApi';
import AppRoutes from './routes/index'; import { AppRoutes } from './routes';
const App = ({ history }: { history: History }) => { const App = ({ history }: { history: History }) => {
return ( return (

View file

@ -1,7 +1,7 @@
import React from 'react'; import React from 'react';
import { Route } from 'react-router-dom'; import { Route } from 'react-router-dom';
import AsyncPage from '../../components/AsyncPage'; import AsyncPage from '../components/AsyncPage';
export interface AsyncRoute { export interface AsyncRoute {
/** The URL path for this route. */ /** The URL path for this route. */
@ -17,6 +17,3 @@ export const toAsyncPageRoute = (route: AsyncRoute) => (
element={<AsyncPage page={route.page} />} element={<AsyncPage page={route.page} />}
/> />
); );
export * from './admin';
export * from './user';

View file

@ -1,7 +1,7 @@
import React from 'react'; import React from 'react';
import { Route } from 'react-router-dom'; import { Route } from 'react-router-dom';
import ViewManagerPage, { ViewManagerPageProps } from '../../components/viewManager/ViewManagerPage'; import ViewManagerPage, { ViewManagerPageProps } from '../components/viewManager/ViewManagerPage';
export interface LegacyRoute { export interface LegacyRoute {
path: string, path: string,
@ -19,7 +19,3 @@ export function toViewManagerPageRoute(route: LegacyRoute) {
/> />
); );
} }
export * from './admin';
export * from './public';
export * from './user';

View file

@ -1,4 +1,4 @@
import { AsyncRoute } from '.'; import { AsyncRoute } from '../../AsyncRoute';
export const ASYNC_USER_ROUTES: AsyncRoute[] = [ export const ASYNC_USER_ROUTES: AsyncRoute[] = [
{ path: 'search.html', page: 'search' } { path: 'search.html', page: 'search' }

View 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>
);

View file

@ -1,4 +1,4 @@
import { LegacyRoute } from '.'; import { LegacyRoute } from '../../LegacyRoute';
export const LEGACY_ADMIN_ROUTES: LegacyRoute[] = [ export const LEGACY_ADMIN_ROUTES: LegacyRoute[] = [
{ {

View file

@ -1,4 +1,4 @@
import { LegacyRoute } from '.'; import { LegacyRoute } from '../../LegacyRoute';
export const LEGACY_PUBLIC_ROUTES: LegacyRoute[] = [ export const LEGACY_PUBLIC_ROUTES: LegacyRoute[] = [
{ {

View file

@ -1,4 +1,4 @@
import { LegacyRoute } from '.'; import { LegacyRoute } from '../../LegacyRoute';
export const LEGACY_USER_ROUTES: LegacyRoute[] = [ export const LEGACY_USER_ROUTES: LegacyRoute[] = [
{ {

View file

@ -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' }
];

View file

@ -1,40 +1 @@
import React from 'react'; export * from './appRoutes';
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;