2022-11-25 20:25:03 +00:00
|
|
|
import type { ComponentType } from 'react';
|
|
|
|
import { lazy } from 'react';
|
|
|
|
|
2022-06-21 22:43:59 +00:00
|
|
|
import ServerConsole from '@/components/server/console/ServerConsoleContainer';
|
2022-06-12 15:36:55 +00: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 15:56:00 +00:00
|
|
|
import FileManagerContainer from '@/components/server/files/FileManagerContainer';
|
|
|
|
import SettingsContainer from '@/components/server/settings/SettingsContainer';
|
2022-06-12 17:33:25 +00: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 19:16:48 +00:00
|
|
|
import ServerActivityLogContainer from '@/components/server/ServerActivityLogContainer';
|
2022-06-12 15:36:55 +00:00
|
|
|
|
2022-06-12 17:33:25 +00:00
|
|
|
// Each of the router files is already code split out appropriately — so
|
2022-11-25 20:25:03 +00:00
|
|
|
// all the items above will only be loaded in when that router is loaded.
|
2022-06-12 17:33:25 +00: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.
|
2022-06-12 15:36:55 +00:00
|
|
|
const FileEditContainer = lazy(() => import('@/components/server/files/FileEditContainer'));
|
|
|
|
const ScheduleEditContainer = lazy(() => import('@/components/server/schedules/ScheduleEditContainer'));
|
|
|
|
|
2022-06-12 17:33:25 +00:00
|
|
|
interface RouteDefinition {
|
2022-11-25 20:25:03 +00: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 15:36:55 +00: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 20:25:03 +00:00
|
|
|
component: ComponentType;
|
|
|
|
end?: boolean;
|
2022-06-12 15:36:55 +00:00
|
|
|
}
|
|
|
|
|
2022-06-12 17:33:25 +00:00
|
|
|
interface ServerRouteDefinition extends RouteDefinition {
|
2022-11-25 20:25:03 +00:00
|
|
|
permission?: string | string[];
|
2022-06-12 17:33:25 +00:00
|
|
|
}
|
|
|
|
|
2022-06-12 15:36:55 +00:00
|
|
|
interface Routes {
|
2022-11-25 20:25:03 +00:00
|
|
|
// All the routes available under "/account"
|
2022-06-12 17:33:25 +00:00
|
|
|
account: RouteDefinition[];
|
2022-11-25 20:25:03 +00:00
|
|
|
// All the routes available under "/server/:id"
|
2022-06-12 15:36:55 +00:00
|
|
|
server: ServerRouteDefinition[];
|
|
|
|
}
|
|
|
|
|
|
|
|
export default {
|
2022-06-12 17:33:25 +00:00
|
|
|
account: [
|
|
|
|
{
|
2022-11-25 20:25:03 +00:00
|
|
|
route: '',
|
|
|
|
path: '',
|
2022-06-12 17:33:25 +00:00
|
|
|
name: 'Account',
|
|
|
|
component: AccountOverviewContainer,
|
2022-11-25 20:25:03 +00:00
|
|
|
end: true,
|
2022-06-12 17:33:25 +00:00
|
|
|
},
|
|
|
|
{
|
2022-11-25 20:25:03 +00:00
|
|
|
route: 'api',
|
|
|
|
path: 'api',
|
2022-06-12 17:33:25 +00:00
|
|
|
name: 'API Credentials',
|
|
|
|
component: AccountApiContainer,
|
|
|
|
},
|
|
|
|
{
|
2022-11-25 20:25:03 +00:00
|
|
|
route: 'ssh',
|
|
|
|
path: 'ssh',
|
2022-06-12 17:33:25 +00:00
|
|
|
name: 'SSH Keys',
|
|
|
|
component: AccountSSHContainer,
|
|
|
|
},
|
|
|
|
{
|
2022-11-25 20:25:03 +00:00
|
|
|
route: 'activity',
|
|
|
|
path: 'activity',
|
2022-06-12 17:33:25 +00:00
|
|
|
name: 'Activity',
|
|
|
|
component: ActivityLogContainer,
|
|
|
|
},
|
|
|
|
],
|
2022-06-12 15:36:55 +00:00
|
|
|
server: [
|
|
|
|
{
|
2022-11-25 20:25:03 +00:00
|
|
|
route: '',
|
|
|
|
path: '',
|
2022-06-12 15:36:55 +00:00
|
|
|
permission: null,
|
|
|
|
name: 'Console',
|
|
|
|
component: ServerConsole,
|
2022-11-25 20:25:03 +00:00
|
|
|
end: true,
|
2022-06-12 15:36:55 +00:00
|
|
|
},
|
|
|
|
{
|
2022-11-25 20:25:03 +00:00
|
|
|
route: 'files/*',
|
|
|
|
path: 'files',
|
2022-06-12 15:36:55 +00:00
|
|
|
permission: 'file.*',
|
|
|
|
name: 'Files',
|
|
|
|
component: FileManagerContainer,
|
|
|
|
},
|
|
|
|
{
|
2022-11-25 20:25:03 +00:00
|
|
|
route: 'files/edit/*',
|
|
|
|
permission: 'file.*',
|
|
|
|
name: undefined,
|
|
|
|
component: FileEditContainer,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
route: 'files/new/*',
|
2022-06-12 15:36:55 +00:00
|
|
|
permission: 'file.*',
|
|
|
|
name: undefined,
|
|
|
|
component: FileEditContainer,
|
|
|
|
},
|
|
|
|
{
|
2022-11-25 20:25:03 +00:00
|
|
|
route: 'databases/*',
|
|
|
|
path: 'databases',
|
2022-06-12 15:36:55 +00:00
|
|
|
permission: 'database.*',
|
|
|
|
name: 'Databases',
|
|
|
|
component: DatabasesContainer,
|
|
|
|
},
|
|
|
|
{
|
2022-11-25 20:25:03 +00:00
|
|
|
route: 'schedules/*',
|
|
|
|
path: 'schedules',
|
2022-06-12 15:36:55 +00:00
|
|
|
permission: 'schedule.*',
|
|
|
|
name: 'Schedules',
|
|
|
|
component: ScheduleContainer,
|
|
|
|
},
|
|
|
|
{
|
2022-11-25 20:25:03 +00:00
|
|
|
route: 'schedules/:id/*',
|
2022-06-12 15:36:55 +00:00
|
|
|
permission: 'schedule.*',
|
|
|
|
name: undefined,
|
|
|
|
component: ScheduleEditContainer,
|
|
|
|
},
|
|
|
|
{
|
2022-11-25 20:25:03 +00:00
|
|
|
route: 'users/*',
|
|
|
|
path: 'users',
|
2022-06-12 15:36:55 +00:00
|
|
|
permission: 'user.*',
|
|
|
|
name: 'Users',
|
|
|
|
component: UsersContainer,
|
|
|
|
},
|
|
|
|
{
|
2022-11-25 20:25:03 +00:00
|
|
|
route: 'backups/*',
|
|
|
|
path: 'backups',
|
2022-06-12 15:36:55 +00:00
|
|
|
permission: 'backup.*',
|
|
|
|
name: 'Backups',
|
|
|
|
component: BackupContainer,
|
|
|
|
},
|
|
|
|
{
|
2022-11-25 20:25:03 +00:00
|
|
|
route: 'network/*',
|
|
|
|
path: 'network',
|
2022-06-12 15:36:55 +00:00
|
|
|
permission: 'allocation.*',
|
|
|
|
name: 'Network',
|
|
|
|
component: NetworkContainer,
|
|
|
|
},
|
|
|
|
{
|
2022-11-25 20:25:03 +00:00
|
|
|
route: 'startup/*',
|
|
|
|
path: 'startup',
|
2022-06-12 15:36:55 +00:00
|
|
|
permission: 'startup.*',
|
|
|
|
name: 'Startup',
|
|
|
|
component: StartupContainer,
|
|
|
|
},
|
|
|
|
{
|
2022-11-25 20:25:03 +00:00
|
|
|
route: 'settings/*',
|
|
|
|
path: 'settings',
|
2022-06-26 19:13:52 +00:00
|
|
|
permission: ['settings.*', 'file.sftp'],
|
2022-06-12 15:36:55 +00:00
|
|
|
name: 'Settings',
|
|
|
|
component: SettingsContainer,
|
|
|
|
},
|
2022-06-12 19:16:48 +00:00
|
|
|
{
|
2022-11-25 20:25:03 +00:00
|
|
|
route: 'activity/*',
|
|
|
|
path: 'activity',
|
2022-06-12 19:16:48 +00:00
|
|
|
permission: 'activity.*',
|
|
|
|
name: 'Activity',
|
|
|
|
component: ServerActivityLogContainer,
|
|
|
|
},
|
2022-06-12 15:36:55 +00:00
|
|
|
],
|
|
|
|
} as Routes;
|