mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Move shared components to common layout
This commit is contained in:
parent
6101e04ca8
commit
d5e703287a
5 changed files with 39 additions and 31 deletions
|
@ -11,6 +11,8 @@ import { HistoryRouter } from 'components/router/HistoryRouter';
|
||||||
import { ApiProvider } from 'hooks/useApi';
|
import { ApiProvider } from 'hooks/useApi';
|
||||||
import { WebConfigProvider } from 'hooks/useWebConfig';
|
import { WebConfigProvider } from 'hooks/useWebConfig';
|
||||||
import theme from 'themes/theme';
|
import theme from 'themes/theme';
|
||||||
|
import { useLocation } from 'react-router-dom';
|
||||||
|
import { DASHBOARD_APP_PATHS } from './apps/dashboard/App';
|
||||||
|
|
||||||
const DashboardApp = loadable(() => import('./apps/dashboard/App'));
|
const DashboardApp = loadable(() => import('./apps/dashboard/App'));
|
||||||
const ExperimentalApp = loadable(() => import('./apps/experimental/App'));
|
const ExperimentalApp = loadable(() => import('./apps/experimental/App'));
|
||||||
|
@ -22,10 +24,14 @@ const RootAppLayout = () => {
|
||||||
const layoutMode = localStorage.getItem('layout');
|
const layoutMode = localStorage.getItem('layout');
|
||||||
const isExperimentalLayout = layoutMode === 'experimental';
|
const isExperimentalLayout = layoutMode === 'experimental';
|
||||||
|
|
||||||
|
const location = useLocation();
|
||||||
|
const isNewLayoutPath = Object.values(DASHBOARD_APP_PATHS)
|
||||||
|
.some(path => location.pathname.startsWith(`/${path}`));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Backdrop />
|
<Backdrop />
|
||||||
<AppHeader isHidden={isExperimentalLayout} />
|
<AppHeader isHidden={isExperimentalLayout || isNewLayoutPath} />
|
||||||
|
|
||||||
{
|
{
|
||||||
isExperimentalLayout ?
|
isExperimentalLayout ?
|
||||||
|
|
|
@ -25,25 +25,31 @@ const toDashboardAsyncPageRoute = (route: AsyncRoute) => (
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const DASHBOARD_APP_PATHS = {
|
||||||
|
Dashboard: 'dashboard',
|
||||||
|
MetadataManager: 'metadata',
|
||||||
|
PluginConfig: 'configurationpage'
|
||||||
|
};
|
||||||
|
|
||||||
const DashboardApp = () => (
|
const DashboardApp = () => (
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route element={<ConnectionRequired isAdminRequired />}>
|
<Route element={<ConnectionRequired isAdminRequired />}>
|
||||||
<Route element={<AppLayout />}>
|
<Route element={<AppLayout />}>
|
||||||
<Route path='dashboard'>
|
<Route path={DASHBOARD_APP_PATHS.Dashboard}>
|
||||||
{ASYNC_ADMIN_ROUTES.map(toDashboardAsyncPageRoute)}
|
{ASYNC_ADMIN_ROUTES.map(toDashboardAsyncPageRoute)}
|
||||||
{LEGACY_ADMIN_ROUTES.map(toViewManagerPageRoute)}
|
{LEGACY_ADMIN_ROUTES.map(toViewManagerPageRoute)}
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
{/* TODO: Should the metadata manager be a separate app? */}
|
{/* TODO: Should the metadata manager be a separate app? */}
|
||||||
{toViewManagerPageRoute({
|
{toViewManagerPageRoute({
|
||||||
path: 'metadata',
|
path: DASHBOARD_APP_PATHS.MetadataManager,
|
||||||
pageProps: {
|
pageProps: {
|
||||||
controller: 'edititemmetadata',
|
controller: 'edititemmetadata',
|
||||||
view: 'edititemmetadata.html'
|
view: 'edititemmetadata.html'
|
||||||
}
|
}
|
||||||
})}
|
})}
|
||||||
|
|
||||||
<Route path='configurationpage' element={
|
<Route path={DASHBOARD_APP_PATHS.PluginConfig} element={
|
||||||
<ServerContentPage view='/web/configurationpage' />
|
<ServerContentPage view='/web/configurationpage' />
|
||||||
} />
|
} />
|
||||||
|
|
||||||
|
|
|
@ -1,29 +1,15 @@
|
||||||
import { ThemeProvider } from '@mui/material/styles';
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Outlet } from 'react-router-dom';
|
import { Outlet } from 'react-router-dom';
|
||||||
|
|
||||||
import AppHeader from 'components/AppHeader';
|
import AppBody from 'components/AppBody';
|
||||||
import Backdrop from 'components/Backdrop';
|
|
||||||
import theme from 'themes/theme';
|
import '../experimental/AppOverrides.scss';
|
||||||
|
|
||||||
const AppLayout = () => {
|
const AppLayout = () => {
|
||||||
return (
|
return (
|
||||||
<ThemeProvider theme={theme}>
|
<AppBody>
|
||||||
<Backdrop />
|
<Outlet />
|
||||||
|
</AppBody>
|
||||||
<div style={{ display: 'none' }}>
|
|
||||||
{/*
|
|
||||||
* TODO: These components are not used, but views interact with them directly so the need to be
|
|
||||||
* present in the dom. We add them in a hidden element to prevent errors.
|
|
||||||
*/}
|
|
||||||
<AppHeader />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className='mainAnimatedPages skinBody' />
|
|
||||||
<div className='skinBody'>
|
|
||||||
<Outlet />
|
|
||||||
</div>
|
|
||||||
</ThemeProvider>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ import { toRedirectRoute } from 'components/router/Redirect';
|
||||||
import AppLayout from './AppLayout';
|
import AppLayout from './AppLayout';
|
||||||
import { ASYNC_USER_ROUTES } from './routes/asyncRoutes';
|
import { ASYNC_USER_ROUTES } from './routes/asyncRoutes';
|
||||||
import { LEGACY_PUBLIC_ROUTES, LEGACY_USER_ROUTES } from './routes/legacyRoutes';
|
import { LEGACY_PUBLIC_ROUTES, LEGACY_USER_ROUTES } from './routes/legacyRoutes';
|
||||||
|
import { DASHBOARD_APP_PATHS } from 'apps/dashboard/App';
|
||||||
|
|
||||||
const ExperimentalApp = () => {
|
const ExperimentalApp = () => {
|
||||||
return (
|
return (
|
||||||
|
@ -33,9 +34,13 @@ const ExperimentalApp = () => {
|
||||||
{REDIRECTS.map(toRedirectRoute)}
|
{REDIRECTS.map(toRedirectRoute)}
|
||||||
|
|
||||||
{/* Ignore dashboard routes */}
|
{/* Ignore dashboard routes */}
|
||||||
<Route path='/configurationpage/*' element={null} />
|
{Object.entries(DASHBOARD_APP_PATHS).map(([ key, path ]) => (
|
||||||
<Route path='/dashboard/*' element={null} />
|
<Route
|
||||||
<Route path='/metadata/*' element={null} />
|
key={key}
|
||||||
|
path={`/${path}/*`}
|
||||||
|
element={null}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
</Routes>
|
</Routes>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,11 +5,12 @@ import AppBody from 'components/AppBody';
|
||||||
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 { ASYNC_USER_ROUTES } from './routes/asyncRoutes';
|
import { ASYNC_USER_ROUTES } from './routes/asyncRoutes';
|
||||||
import { LEGACY_PUBLIC_ROUTES, LEGACY_USER_ROUTES } from './routes/legacyRoutes';
|
import { LEGACY_PUBLIC_ROUTES, LEGACY_USER_ROUTES } from './routes/legacyRoutes';
|
||||||
import { REDIRECTS } from './routes/_redirects';
|
import { REDIRECTS } from './routes/_redirects';
|
||||||
import { toRedirectRoute } from 'components/router/Redirect';
|
import { DASHBOARD_APP_PATHS } from 'apps/dashboard/App';
|
||||||
|
|
||||||
const Layout = () => (
|
const Layout = () => (
|
||||||
<AppBody>
|
<AppBody>
|
||||||
|
@ -34,9 +35,13 @@ const StableApp = () => (
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
{/* Ignore dashboard routes */}
|
{/* Ignore dashboard routes */}
|
||||||
<Route path='/configurationpage/*' element={null} />
|
{Object.entries(DASHBOARD_APP_PATHS).map(([ key, path ]) => (
|
||||||
<Route path='/dashboard/*' element={null} />
|
<Route
|
||||||
<Route path='/metadata/*' element={null} />
|
key={key}
|
||||||
|
path={`/${path}/*`}
|
||||||
|
element={null}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
|
||||||
{/* Suppress warnings for unhandled routes */}
|
{/* Suppress warnings for unhandled routes */}
|
||||||
<Route path='*' element={null} />
|
<Route path='*' element={null} />
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue