2022-11-25 21:25:03 +01:00
|
|
|
import type { ComponentType } from 'react';
|
|
|
|
import { lazy } from 'react';
|
|
|
|
|
2022-06-12 17:36:55 +02:00
|
|
|
import DatabasesContainer from '@/components/server/databases/DatabasesContainer';
|
|
|
|
import ScheduleContainer from '@/components/server/schedules/ScheduleContainer';
|
|
|
|
import UsersContainer from '@/components/server/users/UsersContainer';
|
|
|
|
import BackupContainer from '@/components/server/backups/BackupContainer';
|
|
|
|
import NetworkContainer from '@/components/server/network/NetworkContainer';
|
|
|
|
import StartupContainer from '@/components/server/startup/StartupContainer';
|
2022-06-12 17:56:00 +02:00
|
|
|
import FileManagerContainer from '@/components/server/files/FileManagerContainer';
|
|
|
|
import SettingsContainer from '@/components/server/settings/SettingsContainer';
|
2022-06-12 19:33:25 +02:00
|
|
|
import AccountOverviewContainer from '@/components/dashboard/AccountOverviewContainer';
|
|
|
|
import AccountApiContainer from '@/components/dashboard/AccountApiContainer';
|
|
|
|
import AccountSSHContainer from '@/components/dashboard/ssh/AccountSSHContainer';
|
|
|
|
import ActivityLogContainer from '@/components/dashboard/activity/ActivityLogContainer';
|
2022-06-12 21:16:48 +02:00
|
|
|
import ServerActivityLogContainer from '@/components/server/ServerActivityLogContainer';
|
2022-06-12 17:36:55 +02:00
|
|
|
|
2022-06-12 19:33:25 +02:00
|
|
|
// Each of the router files is already code split out appropriately — so
|
2022-11-25 21:25:03 +01:00
|
|
|
// all the items above will only be loaded in when that router is loaded.
|
2022-06-12 19:33:25 +02:00
|
|
|
//
|
|
|
|
// These specific lazy loaded routes are to avoid loading in heavy screens
|
|
|
|
// for the server dashboard when they're only needed for specific instances.
|
2023-01-25 19:39:07 +01:00
|
|
|
const ServerConsoleContainer = lazy(() => import('@/components/server/console/ServerConsoleContainer'));
|
2022-06-12 17:36:55 +02:00
|
|
|
const FileEditContainer = lazy(() => import('@/components/server/files/FileEditContainer'));
|
|
|
|
const ScheduleEditContainer = lazy(() => import('@/components/server/schedules/ScheduleEditContainer'));
|
|
|
|
|
2022-06-12 19:33:25 +02:00
|
|
|
interface RouteDefinition {
|
2022-11-25 21:25:03 +01:00
|
|
|
/**
|
|
|
|
* Route is the path that will be matched against, this field supports wildcards.
|
|
|
|
*/
|
|
|
|
route: string;
|
|
|
|
/**
|
|
|
|
* Path is the path that will be used for any navbars or links, do not use wildcards or fancy
|
|
|
|
* matchers here. If this field is left undefined, this route will not have a navigation element,
|
|
|
|
*/
|
|
|
|
path?: string;
|
2022-06-12 17:36:55 +02:00
|
|
|
// If undefined is passed this route is still rendered into the router itself
|
|
|
|
// but no navigation link is displayed in the sub-navigation menu.
|
|
|
|
name: string | undefined;
|
2022-11-25 21:25:03 +01:00
|
|
|
component: ComponentType;
|
|
|
|
end?: boolean;
|
2022-06-12 17:36:55 +02:00
|
|
|
}
|
|
|
|
|
2022-06-12 19:33:25 +02:00
|
|
|
interface ServerRouteDefinition extends RouteDefinition {
|
2022-11-25 21:25:03 +01:00
|
|
|
permission?: string | string[];
|
2022-06-12 19:33:25 +02:00
|
|
|
}
|
|
|
|
|
2022-06-12 17:36:55 +02:00
|
|
|
interface Routes {
|
2022-11-25 21:25:03 +01:00
|
|
|
// All the routes available under "/account"
|
2022-06-12 19:33:25 +02:00
|
|
|
account: RouteDefinition[];
|
2022-11-25 21:25:03 +01:00
|
|
|
// All the routes available under "/server/:id"
|
2022-06-12 17:36:55 +02:00
|
|
|
server: ServerRouteDefinition[];
|
|
|
|
}
|
|
|
|
|
|
|
|
export default {
|
2022-06-12 19:33:25 +02:00
|
|
|
account: [
|
|
|
|
{
|
2022-11-25 21:25:03 +01:00
|
|
|
route: '',
|
|
|
|
path: '',
|
2022-06-12 19:33:25 +02:00
|
|
|
name: 'Account',
|
|
|
|
component: AccountOverviewContainer,
|
2022-11-25 21:25:03 +01:00
|
|
|
end: true,
|
2022-06-12 19:33:25 +02:00
|
|
|
},
|
|
|
|
{
|
2022-11-25 21:25:03 +01:00
|
|
|
route: 'api',
|
|
|
|
path: 'api',
|
2022-06-12 19:33:25 +02:00
|
|
|
name: 'API Credentials',
|
|
|
|
component: AccountApiContainer,
|
|
|
|
},
|
|
|
|
{
|
2022-11-25 21:25:03 +01:00
|
|
|
route: 'ssh',
|
|
|
|
path: 'ssh',
|
2022-06-12 19:33:25 +02:00
|
|
|
name: 'SSH Keys',
|
|
|
|
component: AccountSSHContainer,
|
|
|
|
},
|
|
|
|
{
|
2022-11-25 21:25:03 +01:00
|
|
|
route: 'activity',
|
|
|
|
path: 'activity',
|
2022-06-12 19:33:25 +02:00
|
|
|
name: 'Activity',
|
|
|
|
component: ActivityLogContainer,
|
|
|
|
},
|
|
|
|
],
|
2022-06-12 17:36:55 +02:00
|
|
|
server: [
|
|
|
|
{
|
2022-11-25 21:25:03 +01:00
|
|
|
route: '',
|
|
|
|
path: '',
|
2022-06-12 17:36:55 +02:00
|
|
|
permission: null,
|
|
|
|
name: 'Console',
|
2023-01-25 19:39:07 +01:00
|
|
|
component: ServerConsoleContainer,
|
2022-11-25 21:25:03 +01:00
|
|
|
end: true,
|
2022-06-12 17:36:55 +02:00
|
|
|
},
|
|
|
|
{
|
2022-11-25 21:25:03 +01:00
|
|
|
route: 'files/*',
|
|
|
|
path: 'files',
|
2022-06-12 17:36:55 +02:00
|
|
|
permission: 'file.*',
|
|
|
|
name: 'Files',
|
|
|
|
component: FileManagerContainer,
|
|
|
|
},
|
|
|
|
{
|
2023-01-12 19:22:24 +01:00
|
|
|
route: 'files/:action/*',
|
2022-06-12 17:36:55 +02:00
|
|
|
permission: 'file.*',
|
|
|
|
name: undefined,
|
|
|
|
component: FileEditContainer,
|
|
|
|
},
|
|
|
|
{
|
2022-11-25 21:25:03 +01:00
|
|
|
route: 'databases/*',
|
|
|
|
path: 'databases',
|
2022-06-12 17:36:55 +02:00
|
|
|
permission: 'database.*',
|
|
|
|
name: 'Databases',
|
|
|
|
component: DatabasesContainer,
|
|
|
|
},
|
|
|
|
{
|
2022-11-25 21:25:03 +01:00
|
|
|
route: 'schedules/*',
|
|
|
|
path: 'schedules',
|
2022-06-12 17:36:55 +02:00
|
|
|
permission: 'schedule.*',
|
|
|
|
name: 'Schedules',
|
|
|
|
component: ScheduleContainer,
|
|
|
|
},
|
|
|
|
{
|
2022-11-25 21:25:03 +01:00
|
|
|
route: 'schedules/:id/*',
|
2022-06-12 17:36:55 +02:00
|
|
|
permission: 'schedule.*',
|
|
|
|
name: undefined,
|
|
|
|
component: ScheduleEditContainer,
|
|
|
|
},
|
|
|
|
{
|
2022-11-25 21:25:03 +01:00
|
|
|
route: 'users/*',
|
|
|
|
path: 'users',
|
2022-06-12 17:36:55 +02:00
|
|
|
permission: 'user.*',
|
|
|
|
name: 'Users',
|
|
|
|
component: UsersContainer,
|
|
|
|
},
|
|
|
|
{
|
2022-11-25 21:25:03 +01:00
|
|
|
route: 'backups/*',
|
|
|
|
path: 'backups',
|
2022-06-12 17:36:55 +02:00
|
|
|
permission: 'backup.*',
|
|
|
|
name: 'Backups',
|
|
|
|
component: BackupContainer,
|
|
|
|
},
|
|
|
|
{
|
2022-11-25 21:25:03 +01:00
|
|
|
route: 'network/*',
|
|
|
|
path: 'network',
|
2022-06-12 17:36:55 +02:00
|
|
|
permission: 'allocation.*',
|
|
|
|
name: 'Network',
|
|
|
|
component: NetworkContainer,
|
|
|
|
},
|
|
|
|
{
|
2022-11-25 21:25:03 +01:00
|
|
|
route: 'startup/*',
|
|
|
|
path: 'startup',
|
2022-06-12 17:36:55 +02:00
|
|
|
permission: 'startup.*',
|
|
|
|
name: 'Startup',
|
|
|
|
component: StartupContainer,
|
|
|
|
},
|
|
|
|
{
|
2022-11-25 21:25:03 +01:00
|
|
|
route: 'settings/*',
|
|
|
|
path: 'settings',
|
2022-06-26 21:13:52 +02:00
|
|
|
permission: ['settings.*', 'file.sftp'],
|
2022-06-12 17:36:55 +02:00
|
|
|
name: 'Settings',
|
|
|
|
component: SettingsContainer,
|
|
|
|
},
|
2022-06-12 21:16:48 +02:00
|
|
|
{
|
2022-11-25 21:25:03 +01:00
|
|
|
route: 'activity/*',
|
|
|
|
path: 'activity',
|
2022-06-12 21:16:48 +02:00
|
|
|
permission: 'activity.*',
|
|
|
|
name: 'Activity',
|
|
|
|
component: ServerActivityLogContainer,
|
|
|
|
},
|
2022-06-12 17:36:55 +02:00
|
|
|
],
|
|
|
|
} as Routes;
|