From bd1ae96b62f7ba1b50f1a2951d1975d076c9e411 Mon Sep 17 00:00:00 2001 From: Bill Thornton Date: Wed, 20 Sep 2023 16:25:11 -0400 Subject: [PATCH] Move routes to dashboard app --- src/apps/dashboard/App.tsx | 17 +- .../components/activityTable/LogLevelChip.tsx | 0 .../components/activityTable/OverviewCell.tsx | 0 .../dataGrid}/GridActionsCellLink.tsx | 0 src/apps/dashboard/routes/_asyncRoutes.ts | 16 +- src/apps/dashboard/routes/_redirects.ts | 16 +- .../routes}/activity.tsx | 6 +- .../routes}/notifications.tsx | 0 .../routes/users/access.tsx} | 0 .../routes/users/index.tsx} | 0 .../routes/users/new.tsx} | 0 .../routes/users/parentalcontrol.tsx} | 0 .../routes/users/password.tsx} | 0 .../routes/users/profile.tsx} | 0 .../components/drawers/AppDrawer.tsx | 2 - src/apps/stable/routes/asyncRoutes/admin.ts | 11 -- src/apps/stable/routes/legacyRoutes/admin.ts | 179 ------------------ 17 files changed, 29 insertions(+), 218 deletions(-) rename src/apps/{experimental => dashboard}/components/activityTable/LogLevelChip.tsx (100%) rename src/apps/{experimental => dashboard}/components/activityTable/OverviewCell.tsx (100%) rename src/apps/{experimental/components => dashboard/components/dataGrid}/GridActionsCellLink.tsx (100%) rename src/apps/{experimental/routes/dashboard => dashboard/routes}/activity.tsx (97%) rename src/apps/{stable/routes/dashboard => dashboard/routes}/notifications.tsx (100%) rename src/apps/{stable/routes/user/userlibraryaccess.tsx => dashboard/routes/users/access.tsx} (100%) rename src/apps/{stable/routes/user/userprofiles.tsx => dashboard/routes/users/index.tsx} (100%) rename src/apps/{stable/routes/user/usernew.tsx => dashboard/routes/users/new.tsx} (100%) rename src/apps/{stable/routes/user/userparentalcontrol.tsx => dashboard/routes/users/parentalcontrol.tsx} (100%) rename src/apps/{stable/routes/user/userpassword.tsx => dashboard/routes/users/password.tsx} (100%) rename src/apps/{stable/routes/user/useredit.tsx => dashboard/routes/users/profile.tsx} (100%) delete mode 100644 src/apps/stable/routes/asyncRoutes/admin.ts delete mode 100644 src/apps/stable/routes/legacyRoutes/admin.ts diff --git a/src/apps/dashboard/App.tsx b/src/apps/dashboard/App.tsx index a5f09d97a..232c8e77c 100644 --- a/src/apps/dashboard/App.tsx +++ b/src/apps/dashboard/App.tsx @@ -1,9 +1,10 @@ +import loadable from '@loadable/component'; import React from 'react'; import { Route, Routes } from 'react-router-dom'; import ConnectionRequired from 'components/ConnectionRequired'; import { toViewManagerPageRoute } from 'components/router/LegacyRoute'; -import { toAsyncPageRoute } from 'components/router/AsyncRoute'; +import { AsyncPageProps, AsyncRoute, toAsyncPageRoute } from 'components/router/AsyncRoute'; import { toRedirectRoute } from 'components/router/Redirect'; import ServerContentPage from 'components/ServerContentPage'; @@ -12,12 +13,24 @@ import { ASYNC_ADMIN_ROUTES } from './routes/_asyncRoutes'; import { LEGACY_ADMIN_ROUTES } from './routes/_legacyRoutes'; import AppLayout from './AppLayout'; +const DashboardAsyncPage = loadable( + (props: { page: string }) => import(/* webpackChunkName: "[request]" */ `./routes/${props.page}`), + { cacheKey: (props: AsyncPageProps) => props.page } +); + +const toDashboardAsyncPageRoute = (route: AsyncRoute) => ( + toAsyncPageRoute({ + ...route, + element: DashboardAsyncPage + }) +); + const DashboardApp = () => ( }> }> - {ASYNC_ADMIN_ROUTES.map(toAsyncPageRoute)} + {ASYNC_ADMIN_ROUTES.map(toDashboardAsyncPageRoute)} {LEGACY_ADMIN_ROUTES.map(toViewManagerPageRoute)} diff --git a/src/apps/experimental/components/activityTable/LogLevelChip.tsx b/src/apps/dashboard/components/activityTable/LogLevelChip.tsx similarity index 100% rename from src/apps/experimental/components/activityTable/LogLevelChip.tsx rename to src/apps/dashboard/components/activityTable/LogLevelChip.tsx diff --git a/src/apps/experimental/components/activityTable/OverviewCell.tsx b/src/apps/dashboard/components/activityTable/OverviewCell.tsx similarity index 100% rename from src/apps/experimental/components/activityTable/OverviewCell.tsx rename to src/apps/dashboard/components/activityTable/OverviewCell.tsx diff --git a/src/apps/experimental/components/GridActionsCellLink.tsx b/src/apps/dashboard/components/dataGrid/GridActionsCellLink.tsx similarity index 100% rename from src/apps/experimental/components/GridActionsCellLink.tsx rename to src/apps/dashboard/components/dataGrid/GridActionsCellLink.tsx diff --git a/src/apps/dashboard/routes/_asyncRoutes.ts b/src/apps/dashboard/routes/_asyncRoutes.ts index 4dc364beb..8cae66877 100644 --- a/src/apps/dashboard/routes/_asyncRoutes.ts +++ b/src/apps/dashboard/routes/_asyncRoutes.ts @@ -1,12 +1,12 @@ import type { AsyncRoute } from 'components/router/AsyncRoute'; export const ASYNC_ADMIN_ROUTES: AsyncRoute[] = [ - { path: 'activity', page: 'dashboard/activity' }, - { path: 'notifications', page: 'dashboard/notifications' }, - { path: 'users/new', page: 'user/usernew' }, - { path: 'users', page: 'user/userprofiles' }, - { path: 'users/profile', page: 'user/useredit' }, - { path: 'users/access', page: 'user/userlibraryaccess' }, - { path: 'users/parentalcontrol', page: 'user/userparentalcontrol' }, - { path: 'users/password', page: 'user/userpassword' } + { path: 'activity' }, + { path: 'notifications' }, + { path: 'users/new' }, + { path: 'users' }, + { path: 'users/profile' }, + { path: 'users/access' }, + { path: 'users/parentalcontrol' }, + { path: 'users/password' } ]; diff --git a/src/apps/dashboard/routes/_redirects.ts b/src/apps/dashboard/routes/_redirects.ts index a2786fe53..2191a3faf 100644 --- a/src/apps/dashboard/routes/_redirects.ts +++ b/src/apps/dashboard/routes/_redirects.ts @@ -1,16 +1,13 @@ import type { Redirect } from 'components/router/Redirect'; export const REDIRECTS: Redirect[] = [ - // FIXME: URL params are not included in redirects { from: 'addplugin.html', to: '/dashboard/plugins/add' }, { from: 'apikeys.html', to: '/dashboard/keys' }, { from: 'availableplugins.html', to: '/dashboard/plugins/catalog' }, { from: 'dashboard.html', to: '/dashboard' }, { from: 'dashboardgeneral.html', to: '/dashboard/settings' }, - // FIXME: URL params are not included in redirects { from: 'device.html', to: '/dashboard/devices/edit' }, { from: 'devices.html', to: '/dashboard/devices' }, - // FIXME: URL params are not included in redirects { from: 'dlnaprofile.html', to: '/dashboard/dlna/profiles/edit' }, { from: 'dlnaprofiles.html', to: '/dashboard/dlna/profiles' }, { from: 'dlnasettings.html', to: '/dashboard/dlna' }, @@ -19,11 +16,9 @@ export const REDIRECTS: Redirect[] = [ { from: 'installedplugins.html', to: '/dashboard/plugins' }, { from: 'library.html', to: '/dashboard/libraries' }, { from: 'librarydisplay.html', to: '/dashboard/libraries/display' }, - // FIXME: URL params are not included in redirects { from: 'livetvguideprovider.html', to: '/dashboard/livetv/guide' }, { from: 'livetvsettings.html', to: '/dashboard/recordings' }, { from: 'livetvstatus.html', to: '/dashboard/livetv' }, - // FIXME: URL params are not included in redirects { from: 'livetvtuner.html', to: '/dashboard/livetv/tuner' }, { from: 'log.html', to: '/dashboard/logs' }, { from: 'metadataimages.html', to: '/dashboard/libraries/metadata' }, @@ -33,19 +28,14 @@ export const REDIRECTS: Redirect[] = [ { from: 'playbackconfiguration.html', to: '/dashboard/playback/resume' }, { from: 'quickConnect.html', to: '/dashboard/quickconnect' }, { from: 'repositories.html', to: '/dashboard/plugins/repositories' }, - // FIXME: URL params are not included in redirects { from: 'scheduledtask.html', to: '/dashboard/tasks/edit' }, { from: 'scheduledtasks.html', to: '/dashboard/tasks' }, { from: 'serveractivity.html', to: '/dashboard/activity' }, { from: 'streamingsettings.html', to: '/dashboard/playback/streaming' }, - { from: 'usernew.html', to: '/dashboard/users/add' }, - { from: 'userprofiles.html', to: '/dashboard/users' }, - // FIXME: URL params are not included in redirects { from: 'useredit.html', to: '/dashboard/users/profile' }, - // FIXME: URL params are not included in redirects { from: 'userlibraryaccess.html', to: '/dashboard/users/access' }, - // FIXME: URL params are not included in redirects + { from: 'usernew.html', to: '/dashboard/users/add' }, { from: 'userparentalcontrol.html', to: '/dashboard/users/parentalcontrol' }, - // FIXME: URL params are not included in redirects - { from: 'userpassword.html', to: '/dashboard/users/password' } + { from: 'userpassword.html', to: '/dashboard/users/password' }, + { from: 'userprofiles.html', to: '/dashboard/users' } ]; diff --git a/src/apps/experimental/routes/dashboard/activity.tsx b/src/apps/dashboard/routes/activity.tsx similarity index 97% rename from src/apps/experimental/routes/dashboard/activity.tsx rename to src/apps/dashboard/routes/activity.tsx index f007e104d..125140ca0 100644 --- a/src/apps/experimental/routes/dashboard/activity.tsx +++ b/src/apps/dashboard/routes/activity.tsx @@ -19,9 +19,9 @@ import { parseISO8601Date, toLocaleDateString, toLocaleTimeString } from 'script import globalize from 'scripts/globalize'; import { toBoolean } from 'utils/string'; -import LogLevelChip from '../../components/activityTable/LogLevelChip'; -import OverviewCell from '../../components/activityTable/OverviewCell'; -import GridActionsCellLink from '../../components/GridActionsCellLink'; +import LogLevelChip from '../components/activityTable/LogLevelChip'; +import OverviewCell from '../components/activityTable/OverviewCell'; +import GridActionsCellLink from '../components/dataGrid/GridActionsCellLink'; const DEFAULT_PAGE_SIZE = 25; const VIEW_PARAM = 'useractivity'; diff --git a/src/apps/stable/routes/dashboard/notifications.tsx b/src/apps/dashboard/routes/notifications.tsx similarity index 100% rename from src/apps/stable/routes/dashboard/notifications.tsx rename to src/apps/dashboard/routes/notifications.tsx diff --git a/src/apps/stable/routes/user/userlibraryaccess.tsx b/src/apps/dashboard/routes/users/access.tsx similarity index 100% rename from src/apps/stable/routes/user/userlibraryaccess.tsx rename to src/apps/dashboard/routes/users/access.tsx diff --git a/src/apps/stable/routes/user/userprofiles.tsx b/src/apps/dashboard/routes/users/index.tsx similarity index 100% rename from src/apps/stable/routes/user/userprofiles.tsx rename to src/apps/dashboard/routes/users/index.tsx diff --git a/src/apps/stable/routes/user/usernew.tsx b/src/apps/dashboard/routes/users/new.tsx similarity index 100% rename from src/apps/stable/routes/user/usernew.tsx rename to src/apps/dashboard/routes/users/new.tsx diff --git a/src/apps/stable/routes/user/userparentalcontrol.tsx b/src/apps/dashboard/routes/users/parentalcontrol.tsx similarity index 100% rename from src/apps/stable/routes/user/userparentalcontrol.tsx rename to src/apps/dashboard/routes/users/parentalcontrol.tsx diff --git a/src/apps/stable/routes/user/userpassword.tsx b/src/apps/dashboard/routes/users/password.tsx similarity index 100% rename from src/apps/stable/routes/user/userpassword.tsx rename to src/apps/dashboard/routes/users/password.tsx diff --git a/src/apps/stable/routes/user/useredit.tsx b/src/apps/dashboard/routes/users/profile.tsx similarity index 100% rename from src/apps/stable/routes/user/useredit.tsx rename to src/apps/dashboard/routes/users/profile.tsx diff --git a/src/apps/experimental/components/drawers/AppDrawer.tsx b/src/apps/experimental/components/drawers/AppDrawer.tsx index 06d8a4917..7e4abf33c 100644 --- a/src/apps/experimental/components/drawers/AppDrawer.tsx +++ b/src/apps/experimental/components/drawers/AppDrawer.tsx @@ -27,8 +27,6 @@ const MAIN_DRAWER_ROUTES = [ ].filter(route => !DRAWERLESS_ROUTES.includes(route.path)); const ADMIN_DRAWER_ROUTES = [ - // ...ASYNC_ADMIN_ROUTES, - // ...LEGACY_ADMIN_ROUTES, { path: '/configurationpage' } // Plugin configuration page ].filter(route => !DRAWERLESS_ROUTES.includes(route.path)); diff --git a/src/apps/stable/routes/asyncRoutes/admin.ts b/src/apps/stable/routes/asyncRoutes/admin.ts deleted file mode 100644 index 72bcc6f32..000000000 --- a/src/apps/stable/routes/asyncRoutes/admin.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { AsyncRoute } from '../../../../components/router/AsyncRoute'; - -export const ASYNC_ADMIN_ROUTES: AsyncRoute[] = [ - { path: 'notificationsettings.html', page: 'dashboard/notifications' }, - { path: 'usernew.html', page: 'user/usernew' }, - { path: 'userprofiles.html', page: 'user/userprofiles' }, - { path: 'useredit.html', page: 'user/useredit' }, - { path: 'userlibraryaccess.html', page: 'user/userlibraryaccess' }, - { path: 'userparentalcontrol.html', page: 'user/userparentalcontrol' }, - { path: 'userpassword.html', page: 'user/userpassword' } -]; diff --git a/src/apps/stable/routes/legacyRoutes/admin.ts b/src/apps/stable/routes/legacyRoutes/admin.ts deleted file mode 100644 index fd430feeb..000000000 --- a/src/apps/stable/routes/legacyRoutes/admin.ts +++ /dev/null @@ -1,179 +0,0 @@ -import { LegacyRoute } from '../../../../components/router/LegacyRoute'; - -export const LEGACY_ADMIN_ROUTES: LegacyRoute[] = [ - { - path: 'dashboard.html', - pageProps: { - controller: 'dashboard/dashboard', - view: 'dashboard/dashboard.html' - } - }, { - path: 'dashboardgeneral.html', - pageProps: { - controller: 'dashboard/general', - view: 'dashboard/general.html' - } - }, { - path: 'networking.html', - pageProps: { - controller: 'dashboard/networking', - view: 'dashboard/networking.html' - } - }, { - path: 'devices.html', - pageProps: { - controller: 'dashboard/devices/devices', - view: 'dashboard/devices/devices.html' - } - }, { - path: 'device.html', - pageProps: { - controller: 'dashboard/devices/device', - view: 'dashboard/devices/device.html' - } - }, { - path: 'dlnaprofile.html', - pageProps: { - controller: 'dashboard/dlna/profile', - view: 'dashboard/dlna/profile.html' - } - }, { - path: 'dlnaprofiles.html', - pageProps: { - controller: 'dashboard/dlna/profiles', - view: 'dashboard/dlna/profiles.html' - } - }, { - path: 'dlnasettings.html', - pageProps: { - controller: 'dashboard/dlna/settings', - view: 'dashboard/dlna/settings.html' - } - }, { - path: 'addplugin.html', - pageProps: { - controller: 'dashboard/plugins/add/index', - view: 'dashboard/plugins/add/index.html' - } - }, { - path: 'library.html', - pageProps: { - controller: 'dashboard/library', - view: 'dashboard/library.html' - } - }, { - path: 'librarydisplay.html', - pageProps: { - controller: 'dashboard/librarydisplay', - view: 'dashboard/librarydisplay.html' - } - }, { - path: 'edititemmetadata.html', - pageProps: { - controller: 'edititemmetadata', - view: 'edititemmetadata.html' - } - }, { - path: 'encodingsettings.html', - pageProps: { - controller: 'dashboard/encodingsettings', - view: 'dashboard/encodingsettings.html' - } - }, { - path: 'log.html', - pageProps: { - controller: 'dashboard/logs', - view: 'dashboard/logs.html' - } - }, { - path: 'metadataimages.html', - pageProps: { - controller: 'dashboard/metadataImages', - view: 'dashboard/metadataimages.html' - } - }, { - path: 'metadatanfo.html', - pageProps: { - controller: 'dashboard/metadatanfo', - view: 'dashboard/metadatanfo.html' - } - }, { - path: 'playbackconfiguration.html', - pageProps: { - controller: 'dashboard/playback', - view: 'dashboard/playback.html' - } - }, { - path: 'availableplugins.html', - pageProps: { - controller: 'dashboard/plugins/available/index', - view: 'dashboard/plugins/available/index.html' - } - }, { - path: 'repositories.html', - pageProps: { - controller: 'dashboard/plugins/repositories/index', - view: 'dashboard/plugins/repositories/index.html' - } - }, { - path: 'livetvguideprovider.html', - pageProps: { - controller: 'livetvguideprovider', - view: 'livetvguideprovider.html' - } - }, { - path: 'livetvsettings.html', - pageProps: { - controller: 'livetvsettings', - view: 'livetvsettings.html' - } - }, { - path: 'livetvstatus.html', - pageProps: { - controller: 'livetvstatus', - view: 'livetvstatus.html' - } - }, { - path: 'livetvtuner.html', - pageProps: { - controller: 'livetvtuner', - view: 'livetvtuner.html' - } - }, { - path: 'installedplugins.html', - pageProps: { - controller: 'dashboard/plugins/installed/index', - view: 'dashboard/plugins/installed/index.html' - } - }, { - path: 'scheduledtask.html', - pageProps: { - controller: 'dashboard/scheduledtasks/scheduledtask', - view: 'dashboard/scheduledtasks/scheduledtask.html' - } - }, { - path: 'scheduledtasks.html', - pageProps: { - controller: 'dashboard/scheduledtasks/scheduledtasks', - view: 'dashboard/scheduledtasks/scheduledtasks.html' - } - }, { - path: 'dashboard/activity', - pageProps: { - controller: 'dashboard/serveractivity', - view: 'dashboard/serveractivity.html' - } - }, { - path: 'apikeys.html', - pageProps: { - controller: 'dashboard/apikeys', - view: 'dashboard/apikeys.html' - } - }, { - path: 'streamingsettings.html', - pageProps: { - view: 'dashboard/streaming.html', - controller: 'dashboard/streaming' - } - } -];