diff --git a/src/apps/experimental/App.tsx b/src/apps/experimental/App.tsx index 3b58bb6aa60..0013ef04301 100644 --- a/src/apps/experimental/App.tsx +++ b/src/apps/experimental/App.tsx @@ -1,114 +1,43 @@ -import React, { useCallback, useEffect, useState } from 'react'; -import AppBar from '@mui/material/AppBar'; -import Box from '@mui/material/Box'; -import { ThemeProvider } from '@mui/material/styles'; -import { useLocation } from 'react-router-dom'; +import React from 'react'; +import { Navigate, Route, Routes } from 'react-router-dom'; -import AppHeader from 'components/AppHeader'; -import Backdrop from 'components/Backdrop'; -import { useApi } from 'hooks/useApi'; -import { useLocalStorage } from 'hooks/useLocalStorage'; +import ConnectionRequired from 'components/ConnectionRequired'; +import ServerContentPage from 'components/ServerContentPage'; +import { toAsyncPageRoute } from 'components/router/AsyncRoute'; +import { toViewManagerPageRoute } from 'components/router/LegacyRoute'; -import AppToolbar from './components/AppToolbar'; -import AppDrawer, { DRAWER_WIDTH, isDrawerPath } from './components/drawers/AppDrawer'; -import ElevationScroll from './components/ElevationScroll'; -import { ExperimentalAppRoutes } from './routes/AppRoutes'; -import theme from './theme'; - -import './AppOverrides.scss'; - -interface ExperimentalAppSettings { - isDrawerPinned: boolean -} - -const DEFAULT_EXPERIMENTAL_APP_SETTINGS: ExperimentalAppSettings = { - isDrawerPinned: false -}; +import AppLayout from './AppLayout'; +import { ASYNC_ADMIN_ROUTES, ASYNC_USER_ROUTES } from './routes/asyncRoutes'; +import { LEGACY_ADMIN_ROUTES, LEGACY_PUBLIC_ROUTES, LEGACY_USER_ROUTES } from './routes/legacyRoutes'; const ExperimentalApp = () => { - const [ appSettings, setAppSettings ] = useLocalStorage('ExperimentalAppSettings', DEFAULT_EXPERIMENTAL_APP_SETTINGS); - const [ isDrawerActive, setIsDrawerActive ] = useState(appSettings.isDrawerPinned); - const { user } = useApi(); - const location = useLocation(); - - const isDrawerAvailable = isDrawerPath(location.pathname); - const isDrawerOpen = isDrawerActive && isDrawerAvailable && Boolean(user); - - useEffect(() => { - if (isDrawerActive !== appSettings.isDrawerPinned) { - setAppSettings({ - ...appSettings, - isDrawerPinned: isDrawerActive - }); - } - }, [ appSettings, isDrawerActive, setAppSettings ]); - - const onToggleDrawer = useCallback(() => { - setIsDrawerActive(!isDrawerActive); - }, [ isDrawerActive, setIsDrawerActive ]); - return ( - - - -
- {/* - * 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. - */} - -
- - - - muiTheme.zIndex.drawer + 1 }} - > - - - - - - - -
-
- -
- - - + + }> + {/* User routes */} + }> + {ASYNC_USER_ROUTES.map(toAsyncPageRoute)} + {LEGACY_USER_ROUTES.map(toViewManagerPageRoute)} + + + {/* Admin routes */} + }> + {ASYNC_ADMIN_ROUTES.map(toAsyncPageRoute)} + {LEGACY_ADMIN_ROUTES.map(toViewManagerPageRoute)} + + + } /> + + + {/* Public routes */} + }> + } /> + + {LEGACY_PUBLIC_ROUTES.map(toViewManagerPageRoute)} + + + ); }; diff --git a/src/apps/experimental/AppLayout.tsx b/src/apps/experimental/AppLayout.tsx new file mode 100644 index 00000000000..71824e0d73f --- /dev/null +++ b/src/apps/experimental/AppLayout.tsx @@ -0,0 +1,114 @@ +import React, { useCallback, useEffect, useState } from 'react'; +import AppBar from '@mui/material/AppBar'; +import Box from '@mui/material/Box'; +import { ThemeProvider } from '@mui/material/styles'; +import { Outlet, useLocation } from 'react-router-dom'; + +import AppHeader from 'components/AppHeader'; +import Backdrop from 'components/Backdrop'; +import { useApi } from 'hooks/useApi'; +import { useLocalStorage } from 'hooks/useLocalStorage'; + +import AppToolbar from './components/AppToolbar'; +import AppDrawer, { DRAWER_WIDTH, isDrawerPath } from './components/drawers/AppDrawer'; +import ElevationScroll from './components/ElevationScroll'; +import theme from './theme'; + +import './AppOverrides.scss'; + +interface ExperimentalAppSettings { + isDrawerPinned: boolean +} + +const DEFAULT_EXPERIMENTAL_APP_SETTINGS: ExperimentalAppSettings = { + isDrawerPinned: false +}; + +const AppLayout = () => { + const [ appSettings, setAppSettings ] = useLocalStorage('ExperimentalAppSettings', DEFAULT_EXPERIMENTAL_APP_SETTINGS); + const [ isDrawerActive, setIsDrawerActive ] = useState(appSettings.isDrawerPinned); + const { user } = useApi(); + const location = useLocation(); + + const isDrawerAvailable = isDrawerPath(location.pathname); + const isDrawerOpen = isDrawerActive && isDrawerAvailable && Boolean(user); + + useEffect(() => { + if (isDrawerActive !== appSettings.isDrawerPinned) { + setAppSettings({ + ...appSettings, + isDrawerPinned: isDrawerActive + }); + } + }, [ appSettings, isDrawerActive, setAppSettings ]); + + const onToggleDrawer = useCallback(() => { + setIsDrawerActive(!isDrawerActive); + }, [ isDrawerActive, setIsDrawerActive ]); + + return ( + + + +
+ {/* + * 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. + */} + +
+ + + + muiTheme.zIndex.drawer + 1 }} + > + + + + + + + +
+
+ +
+ + + + ); +}; + +export default AppLayout; diff --git a/src/apps/experimental/components/drawers/AppDrawer.tsx b/src/apps/experimental/components/drawers/AppDrawer.tsx index 49ccab09fd9..ffd9ba119ea 100644 --- a/src/apps/experimental/components/drawers/AppDrawer.tsx +++ b/src/apps/experimental/components/drawers/AppDrawer.tsx @@ -80,9 +80,6 @@ const AppDrawer: FC = ({ /> )) } - - {/* Suppress warnings for unhandled routes */} - ); diff --git a/src/apps/experimental/components/tabs/AppTabs.tsx b/src/apps/experimental/components/tabs/AppTabs.tsx index 383bf8ab21f..02eec57077b 100644 --- a/src/apps/experimental/components/tabs/AppTabs.tsx +++ b/src/apps/experimental/components/tabs/AppTabs.tsx @@ -83,9 +83,6 @@ const AppTabs: FC = ({ /> )) } - - {/* Suppress warnings for unhandled routes */} - ); }; diff --git a/src/apps/experimental/routes/AppRoutes.tsx b/src/apps/experimental/routes/AppRoutes.tsx deleted file mode 100644 index 8c01a026757..00000000000 --- a/src/apps/experimental/routes/AppRoutes.tsx +++ /dev/null @@ -1,42 +0,0 @@ -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 'components/router/AsyncRoute'; -import { toViewManagerPageRoute } from 'components/router/LegacyRoute'; - -import { ASYNC_ADMIN_ROUTES, ASYNC_USER_ROUTES } from './asyncRoutes'; -import { LEGACY_ADMIN_ROUTES, LEGACY_PUBLIC_ROUTES, LEGACY_USER_ROUTES } from './legacyRoutes'; - -export const ExperimentalAppRoutes = () => ( - - - {/* User routes */} - }> - {ASYNC_USER_ROUTES.map(toAsyncPageRoute)} - {LEGACY_USER_ROUTES.map(toViewManagerPageRoute)} - - - {/* Admin routes */} - }> - {ASYNC_ADMIN_ROUTES.map(toAsyncPageRoute)} - {LEGACY_ADMIN_ROUTES.map(toViewManagerPageRoute)} - - - } /> - - - {/* Public routes */} - }> - } /> - - {LEGACY_PUBLIC_ROUTES.map(toViewManagerPageRoute)} - - - {/* Suppress warnings for unhandled routes */} - - - -); diff --git a/src/apps/stable/App.tsx b/src/apps/stable/App.tsx index 7d619f62305..bbaec1b922a 100644 --- a/src/apps/stable/App.tsx +++ b/src/apps/stable/App.tsx @@ -1,19 +1,58 @@ import React from 'react'; +import { Navigate, Outlet, Route, Routes } from 'react-router-dom'; -import AppHeader from '../../components/AppHeader'; -import Backdrop from '../../components/Backdrop'; -import { AppRoutes } from './routes/AppRoutes'; +import AppHeader from 'components/AppHeader'; +import Backdrop from 'components/Backdrop'; +import ServerContentPage from 'components/ServerContentPage'; +import ConnectionRequired from 'components/ConnectionRequired'; +import { toAsyncPageRoute } from 'components/router/AsyncRoute'; +import { toViewManagerPageRoute } from 'components/router/LegacyRoute'; -const StableApp = () => ( +import { ASYNC_ADMIN_ROUTES, ASYNC_USER_ROUTES } from './routes/asyncRoutes'; +import { LEGACY_ADMIN_ROUTES, LEGACY_PUBLIC_ROUTES, LEGACY_USER_ROUTES } from './routes/legacyRoutes'; + +const Layout = () => ( <>
- +
); +const StableApp = () => ( + + }> + {/* User routes */} + }> + {ASYNC_USER_ROUTES.map(toAsyncPageRoute)} + {LEGACY_USER_ROUTES.map(toViewManagerPageRoute)} + + + {/* Admin routes */} + }> + {ASYNC_ADMIN_ROUTES.map(toAsyncPageRoute)} + {LEGACY_ADMIN_ROUTES.map(toViewManagerPageRoute)} + + + } /> + + + {/* Public routes */} + }> + } /> + + {LEGACY_PUBLIC_ROUTES.map(toViewManagerPageRoute)} + + + {/* Suppress warnings for unhandled routes */} + + + +); + export default StableApp; diff --git a/src/apps/stable/routes/AppRoutes.tsx b/src/apps/stable/routes/AppRoutes.tsx deleted file mode 100644 index fb3527da75b..00000000000 --- a/src/apps/stable/routes/AppRoutes.tsx +++ /dev/null @@ -1,41 +0,0 @@ -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 '../../../components/router/AsyncRoute'; -import { toViewManagerPageRoute } from '../../../components/router/LegacyRoute'; -import { ASYNC_ADMIN_ROUTES, ASYNC_USER_ROUTES } from './asyncRoutes'; -import { LEGACY_ADMIN_ROUTES, LEGACY_PUBLIC_ROUTES, LEGACY_USER_ROUTES } from './legacyRoutes'; - -export const AppRoutes = () => ( - - - {/* User routes */} - }> - {ASYNC_USER_ROUTES.map(toAsyncPageRoute)} - {LEGACY_USER_ROUTES.map(toViewManagerPageRoute)} - - - {/* Admin routes */} - }> - {ASYNC_ADMIN_ROUTES.map(toAsyncPageRoute)} - {LEGACY_ADMIN_ROUTES.map(toViewManagerPageRoute)} - - - } /> - - - {/* Public routes */} - }> - } /> - - {LEGACY_PUBLIC_ROUTES.map(toViewManagerPageRoute)} - - - {/* Suppress warnings for unhandled routes */} - - - -);