Refactor app structure

This commit is contained in:
Bill Thornton 2023-04-27 17:04:33 -04:00
parent 06b0fed11d
commit d748372a28
23 changed files with 88 additions and 42 deletions

View File

@ -76,21 +76,24 @@ Jellyfin Web is the frontend used for most of the clients available for end user
```
.
└── src
├── assets # Static assets
├── components # Higher order visual components and React components
├── controllers # Legacy page views and controllers 🧹
├── elements # Basic webcomponents and React wrappers 🧹
├── hooks # Custom React hooks
├── legacy # Polyfills for legacy browsers
├── libraries # Third party libraries 🧹
├── plugins # Client plugins
├── routes # React routes/pages
├── scripts # Random assortment of visual components and utilities 🐉
├── strings # Translation files
├── styles # Common app Sass stylesheets
├── themes # CSS themes
├── types # Common TypeScript interfaces/types
└── utils # Utility functions
├── apps
│   ├── experimental # New experimental app layout
│   └── stable # Classic (stable) app layout
├── assets # Static assets
├── components # Higher order visual components and React components
├── controllers # Legacy page views and controllers 🧹
├── elements # Basic webcomponents and React wrappers 🧹
├── hooks # Custom React hooks
├── legacy # Polyfills for legacy browsers
├── libraries # Third party libraries 🧹
├── plugins # Client plugins
├── routes # React routes/pages
├── scripts # Random assortment of visual components and utilities 🐉
├── strings # Translation files
├── styles # Common app Sass stylesheets
├── themes # CSS themes
├── types # Common TypeScript interfaces/types
└── utils # Utility functions
```
- 🧹 — Needs cleanup

View File

@ -1,13 +1,16 @@
import loadable from '@loadable/component';
import { History } from '@remix-run/router';
import React from 'react';
import StableApp from './apps/stable/App';
import AppHeader from './components/AppHeader';
import Backdrop from './components/Backdrop';
import { HistoryRouter } from './components/HistoryRouter';
import { ApiProvider } from './hooks/useApi';
import { AppRoutes, ExperimentalAppRoutes } from './routes';
const App = ({ history }: { history: History }) => {
const ExperimentalApp = loadable(() => import('./apps/experimental/App'));
const RootApp = ({ history }: { history: History }) => {
const layoutMode = localStorage.getItem('layout');
return (
@ -18,11 +21,15 @@ const App = ({ history }: { history: History }) => {
<div className='mainAnimatedPages skinBody' />
<div className='skinBody'>
{layoutMode === 'experimental' ? <ExperimentalAppRoutes /> : <AppRoutes /> }
{
layoutMode === 'experimental' ?
<ExperimentalApp /> :
<StableApp />
}
</div>
</HistoryRouter>
</ApiProvider>
);
};
export default App;
export default RootApp;

View File

@ -0,0 +1,19 @@
import React from 'react';
import AppHeader from '../../components/AppHeader';
import Backdrop from '../../components/Backdrop';
import { ExperimentalAppRoutes } from './routes/AppRoutes';
const ExperimentalApp = () => (
<>
<Backdrop />
<AppHeader />
<div className='mainAnimatedPages skinBody' />
<div className='skinBody'>
<ExperimentalAppRoutes />
</div>
</>
);
export default ExperimentalApp;

View File

@ -1,10 +1,10 @@
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 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';

View File

@ -1,4 +1,4 @@
import { AsyncRoute } from '../../AsyncRoute';
import { AsyncRoute } from '../../../../components/router/AsyncRoute';
export const ASYNC_ADMIN_ROUTES: AsyncRoute[] = [
{ path: 'usernew.html', page: 'user/usernew' },

View File

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

View File

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

View File

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

View File

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

19
src/apps/stable/App.tsx Normal file
View File

@ -0,0 +1,19 @@
import React from 'react';
import AppHeader from '../../components/AppHeader';
import Backdrop from '../../components/Backdrop';
import { AppRoutes } from './routes/AppRoutes';
const StableApp = () => (
<>
<Backdrop />
<AppHeader />
<div className='mainAnimatedPages skinBody' />
<div className='skinBody'>
<AppRoutes />
</div>
</>
);
export default StableApp;

View File

@ -1,10 +1,10 @@
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 ConnectionRequired from '../../../components/ConnectionRequired';
import ServerContentPage from '../../../components/ServerContentPage';
import { toAsyncPageRoute } from '../../../components/router/AsyncRoute';
import { toViewManagerPageRoute } from '../../../components/router/LegacyRoute';
import { ASYNC_USER_ROUTES } from './asyncRoutes';
import { LEGACY_ADMIN_ROUTES, LEGACY_PUBLIC_ROUTES, LEGACY_USER_ROUTES } from './legacyRoutes';

View File

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

View File

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

View File

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

View File

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

View File

@ -1,7 +1,7 @@
import React from 'react';
import { Route } from 'react-router-dom';
import AsyncPage from '../components/AsyncPage';
import AsyncPage from '../AsyncPage';
export interface AsyncRoute {
/** The URL path for this route. */

View File

@ -1,7 +1,7 @@
import React from 'react';
import { Route } from 'react-router-dom';
import ViewManagerPage, { ViewManagerPageProps } from '../components/viewManager/ViewManagerPage';
import ViewManagerPage, { ViewManagerPageProps } from '../viewManager/ViewManagerPage';
export interface LegacyRoute {
path: string,

View File

@ -34,7 +34,7 @@ import './legacy/htmlMediaElement';
import './legacy/vendorStyles';
import { currentSettings } from './scripts/settings/userSettings';
import taskButton from './scripts/taskbutton';
import App from './App.tsx';
import RootApp from './RootApp.tsx';
import './styles/livetv.scss';
import './styles/dashboard.scss';
@ -151,7 +151,7 @@ async function onAppReady() {
ReactDOM.render(
<StrictMode>
<App history={history} />
<RootApp history={history} />
</StrictMode>,
root
);

View File

@ -1,2 +0,0 @@
export * from './appRoutes';
export * from './experimentalAppRoutes';