mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Merge pull request #4834 from grhallenbeck/dev-react-router
Migrate React Router to React Data Router pattern
This commit is contained in:
commit
35429ca61f
17 changed files with 346 additions and 302 deletions
42
src/apps/experimental/routes/routes.tsx
Normal file
42
src/apps/experimental/routes/routes.tsx
Normal file
|
@ -0,0 +1,42 @@
|
|||
import React from 'react';
|
||||
import { RouteObject, redirect } from 'react-router-dom';
|
||||
|
||||
import { REDIRECTS } from 'apps/dashboard/routes/_redirects';
|
||||
import { DASHBOARD_APP_PATHS } from 'apps/dashboard/routes/routes';
|
||||
import ConnectionRequired from 'components/ConnectionRequired';
|
||||
import { toAsyncPageRoute } from 'components/router/AsyncRoute';
|
||||
import { toViewManagerPageRoute } from 'components/router/LegacyRoute';
|
||||
import { toRedirectRoute } from 'components/router/Redirect';
|
||||
import AppLayout from '../AppLayout';
|
||||
import { ASYNC_USER_ROUTES } from './asyncRoutes';
|
||||
import { LEGACY_PUBLIC_ROUTES, LEGACY_USER_ROUTES } from './legacyRoutes';
|
||||
|
||||
export const EXPERIMENTAL_APP_ROUTES: RouteObject[] = [
|
||||
{
|
||||
path: '/*',
|
||||
element: <AppLayout />,
|
||||
children: [
|
||||
{
|
||||
/* User routes: Any child route of this layout is authenticated */
|
||||
element: <ConnectionRequired isUserRequired />,
|
||||
children: [
|
||||
...ASYNC_USER_ROUTES.map(toAsyncPageRoute),
|
||||
...LEGACY_USER_ROUTES.map(toViewManagerPageRoute)
|
||||
]
|
||||
},
|
||||
|
||||
/* Public routes */
|
||||
{ index: true, loader: () => redirect('/home.html') },
|
||||
...LEGACY_PUBLIC_ROUTES.map(toViewManagerPageRoute)
|
||||
]
|
||||
},
|
||||
|
||||
/* Redirects for old paths */
|
||||
...REDIRECTS.map(toRedirectRoute),
|
||||
|
||||
/* Ignore dashboard routes */
|
||||
...Object.entries(DASHBOARD_APP_PATHS).map(([, path]) => ({
|
||||
path: `/${path}/*`,
|
||||
element: null
|
||||
}))
|
||||
];
|
Loading…
Add table
Add a link
Reference in a new issue