mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Merge pull request #5167 from thornbill/fix-routing-crash
Fix stable app crash due to missing nav components
This commit is contained in:
commit
0d63bdc052
5 changed files with 43 additions and 43 deletions
|
@ -29,6 +29,10 @@ export default function RootAppRouter({ history }: Readonly<{ history: History}>
|
||||||
return <RouterProvider router={router} />;
|
return <RouterProvider router={router} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Layout component that renders legacy components required on all pages.
|
||||||
|
* NOTE: The app will crash if these get removed from the DOM.
|
||||||
|
*/
|
||||||
function RootAppLayout() {
|
function RootAppLayout() {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|
|
@ -2,7 +2,6 @@ import React from 'react';
|
||||||
import { RouteObject, redirect } from 'react-router-dom';
|
import { RouteObject, redirect } from 'react-router-dom';
|
||||||
|
|
||||||
import { REDIRECTS } from 'apps/dashboard/routes/_redirects';
|
import { REDIRECTS } from 'apps/dashboard/routes/_redirects';
|
||||||
import { DASHBOARD_APP_PATHS } from 'apps/dashboard/routes/routes';
|
|
||||||
import ConnectionRequired from 'components/ConnectionRequired';
|
import ConnectionRequired from 'components/ConnectionRequired';
|
||||||
import { toAsyncPageRoute } from 'components/router/AsyncRoute';
|
import { toAsyncPageRoute } from 'components/router/AsyncRoute';
|
||||||
import { toViewManagerPageRoute } from 'components/router/LegacyRoute';
|
import { toViewManagerPageRoute } from 'components/router/LegacyRoute';
|
||||||
|
@ -32,11 +31,5 @@ export const EXPERIMENTAL_APP_ROUTES: RouteObject[] = [
|
||||||
},
|
},
|
||||||
|
|
||||||
/* Redirects for old paths */
|
/* Redirects for old paths */
|
||||||
...REDIRECTS.map(toRedirectRoute),
|
...REDIRECTS.map(toRedirectRoute)
|
||||||
|
|
||||||
/* Ignore dashboard routes */
|
|
||||||
...Object.entries(DASHBOARD_APP_PATHS).map(([, path]) => ({
|
|
||||||
path: `/${path}/*`,
|
|
||||||
element: null
|
|
||||||
}))
|
|
||||||
];
|
];
|
||||||
|
|
|
@ -1,24 +1,12 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Outlet, useLocation } from 'react-router-dom';
|
import { Outlet } from 'react-router-dom';
|
||||||
|
|
||||||
import AppBody from 'components/AppBody';
|
import AppBody from 'components/AppBody';
|
||||||
import { DASHBOARD_APP_PATHS } from 'apps/dashboard/routes/routes';
|
|
||||||
import Backdrop from 'components/Backdrop';
|
|
||||||
import AppHeader from 'components/AppHeader';
|
|
||||||
|
|
||||||
export default function AppLayout() {
|
export default function AppLayout() {
|
||||||
const location = useLocation();
|
|
||||||
const isNewLayoutPath = Object.values(DASHBOARD_APP_PATHS)
|
|
||||||
.some(path => location.pathname.startsWith(`/${path}`));
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<AppBody>
|
||||||
<Backdrop />
|
<Outlet />
|
||||||
<AppHeader isHidden={isNewLayoutPath} />
|
</AppBody>
|
||||||
|
|
||||||
<AppBody>
|
|
||||||
<Outlet />
|
|
||||||
</AppBody>
|
|
||||||
</>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,42 @@
|
||||||
import { History } from '@remix-run/router';
|
import { History } from '@remix-run/router';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { RouterProvider, createHashRouter } from 'react-router-dom';
|
import { Outlet, RouterProvider, createHashRouter, useLocation } from 'react-router-dom';
|
||||||
|
|
||||||
import { DASHBOARD_APP_ROUTES } from 'apps/dashboard/routes/routes';
|
|
||||||
import { useLegacyRouterSync } from 'hooks/useLegacyRouterSync';
|
import { useLegacyRouterSync } from 'hooks/useLegacyRouterSync';
|
||||||
import { STABLE_APP_ROUTES } from './routes/routes';
|
import { STABLE_APP_ROUTES } from './routes/routes';
|
||||||
|
import Backdrop from 'components/Backdrop';
|
||||||
|
import AppHeader from 'components/AppHeader';
|
||||||
|
import { DASHBOARD_APP_PATHS, DASHBOARD_APP_ROUTES } from 'apps/dashboard/routes/routes';
|
||||||
|
|
||||||
const router = createHashRouter([
|
const router = createHashRouter([{
|
||||||
...STABLE_APP_ROUTES,
|
element: <StableAppLayout />,
|
||||||
...DASHBOARD_APP_ROUTES
|
children: [
|
||||||
]);
|
...STABLE_APP_ROUTES,
|
||||||
|
...DASHBOARD_APP_ROUTES
|
||||||
|
]
|
||||||
|
}]);
|
||||||
|
|
||||||
export default function StableAppRouter({ history }: Readonly<{ history: History }>) {
|
export default function StableAppRouter({ history }: Readonly<{ history: History }>) {
|
||||||
useLegacyRouterSync({ router, history });
|
useLegacyRouterSync({ router, history });
|
||||||
|
|
||||||
return <RouterProvider router={router} />;
|
return <RouterProvider router={router} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Layout component that renders legacy components required on all pages.
|
||||||
|
* NOTE: The app will crash if these get removed from the DOM.
|
||||||
|
*/
|
||||||
|
function StableAppLayout() {
|
||||||
|
const location = useLocation();
|
||||||
|
const isNewLayoutPath = Object.values(DASHBOARD_APP_PATHS)
|
||||||
|
.some(path => location.pathname.startsWith(`/${path}`));
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Backdrop />
|
||||||
|
<AppHeader isHidden={isNewLayoutPath} />
|
||||||
|
|
||||||
|
<Outlet />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
import { RouteObject, redirect } from 'react-router-dom';
|
import { RouteObject, redirect } from 'react-router-dom';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import { DASHBOARD_APP_PATHS } from 'apps/dashboard/routes/routes';
|
|
||||||
import ConnectionRequired from 'components/ConnectionRequired';
|
import ConnectionRequired from 'components/ConnectionRequired';
|
||||||
import { toAsyncPageRoute } from 'components/router/AsyncRoute';
|
import { toAsyncPageRoute } from 'components/router/AsyncRoute';
|
||||||
import { toViewManagerPageRoute } from 'components/router/LegacyRoute';
|
import { toViewManagerPageRoute } from 'components/router/LegacyRoute';
|
||||||
import { toRedirectRoute } from 'components/router/Redirect';
|
import { toRedirectRoute } from 'components/router/Redirect';
|
||||||
|
|
||||||
import AppLayout from '../AppLayout';
|
import AppLayout from '../AppLayout';
|
||||||
|
|
||||||
import { REDIRECTS } from './_redirects';
|
import { REDIRECTS } from './_redirects';
|
||||||
import { ASYNC_USER_ROUTES } from './asyncRoutes';
|
import { ASYNC_USER_ROUTES } from './asyncRoutes';
|
||||||
import { LEGACY_PUBLIC_ROUTES, LEGACY_USER_ROUTES } from './legacyRoutes';
|
import { LEGACY_PUBLIC_ROUTES, LEGACY_USER_ROUTES } from './legacyRoutes';
|
||||||
|
@ -27,20 +28,10 @@ export const STABLE_APP_ROUTES: RouteObject[] = [
|
||||||
|
|
||||||
/* Public routes */
|
/* Public routes */
|
||||||
{ index: true, loader: () => redirect('/home.html') },
|
{ index: true, loader: () => redirect('/home.html') },
|
||||||
...LEGACY_PUBLIC_ROUTES.map(toViewManagerPageRoute),
|
...LEGACY_PUBLIC_ROUTES.map(toViewManagerPageRoute)
|
||||||
|
|
||||||
/* Suppress warnings for unhandled routes */
|
|
||||||
{ path: '*', element: null }
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
/* Redirects for old paths */
|
/* Redirects for old paths */
|
||||||
...REDIRECTS.map(toRedirectRoute),
|
...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