Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pterodactyl
GitHub Repository: pterodactyl/panel
Path: blob/1.0-develop/resources/scripts/routers/routes.ts
7458 views
1
import React, { lazy } from 'react';
2
import ServerConsole from '@/components/server/console/ServerConsoleContainer';
3
import DatabasesContainer from '@/components/server/databases/DatabasesContainer';
4
import ScheduleContainer from '@/components/server/schedules/ScheduleContainer';
5
import UsersContainer from '@/components/server/users/UsersContainer';
6
import BackupContainer from '@/components/server/backups/BackupContainer';
7
import NetworkContainer from '@/components/server/network/NetworkContainer';
8
import StartupContainer from '@/components/server/startup/StartupContainer';
9
import FileManagerContainer from '@/components/server/files/FileManagerContainer';
10
import SettingsContainer from '@/components/server/settings/SettingsContainer';
11
import AccountOverviewContainer from '@/components/dashboard/AccountOverviewContainer';
12
import AccountApiContainer from '@/components/dashboard/AccountApiContainer';
13
import AccountSSHContainer from '@/components/dashboard/ssh/AccountSSHContainer';
14
import ActivityLogContainer from '@/components/dashboard/activity/ActivityLogContainer';
15
import ServerActivityLogContainer from '@/components/server/ServerActivityLogContainer';
16
17
// Each of the router files is already code split out appropriately — so
18
// all of the items above will only be loaded in when that router is loaded.
19
//
20
// These specific lazy loaded routes are to avoid loading in heavy screens
21
// for the server dashboard when they're only needed for specific instances.
22
const FileEditContainer = lazy(() => import('@/components/server/files/FileEditContainer'));
23
const ScheduleEditContainer = lazy(() => import('@/components/server/schedules/ScheduleEditContainer'));
24
25
interface RouteDefinition {
26
path: string;
27
// If undefined is passed this route is still rendered into the router itself
28
// but no navigation link is displayed in the sub-navigation menu.
29
name: string | undefined;
30
component: React.ComponentType;
31
exact?: boolean;
32
}
33
34
interface ServerRouteDefinition extends RouteDefinition {
35
permission: string | string[] | null;
36
}
37
38
interface Routes {
39
// All of the routes available under "/account"
40
account: RouteDefinition[];
41
// All of the routes available under "/server/:id"
42
server: ServerRouteDefinition[];
43
}
44
45
export default {
46
account: [
47
{
48
path: '/',
49
name: 'Account',
50
component: AccountOverviewContainer,
51
exact: true,
52
},
53
{
54
path: '/api',
55
name: 'API Credentials',
56
component: AccountApiContainer,
57
},
58
{
59
path: '/ssh',
60
name: 'SSH Keys',
61
component: AccountSSHContainer,
62
},
63
{
64
path: '/activity',
65
name: 'Activity',
66
component: ActivityLogContainer,
67
},
68
],
69
server: [
70
{
71
path: '/',
72
permission: null,
73
name: 'Console',
74
component: ServerConsole,
75
exact: true,
76
},
77
{
78
path: '/files',
79
permission: 'file.*',
80
name: 'Files',
81
component: FileManagerContainer,
82
},
83
{
84
path: '/files/:action(edit|new)',
85
permission: 'file.*',
86
name: undefined,
87
component: FileEditContainer,
88
},
89
{
90
path: '/databases',
91
permission: 'database.*',
92
name: 'Databases',
93
component: DatabasesContainer,
94
},
95
{
96
path: '/schedules',
97
permission: 'schedule.*',
98
name: 'Schedules',
99
component: ScheduleContainer,
100
},
101
{
102
path: '/schedules/:id',
103
permission: 'schedule.*',
104
name: undefined,
105
component: ScheduleEditContainer,
106
},
107
{
108
path: '/users',
109
permission: 'user.*',
110
name: 'Users',
111
component: UsersContainer,
112
},
113
{
114
path: '/backups',
115
permission: 'backup.*',
116
name: 'Backups',
117
component: BackupContainer,
118
},
119
{
120
path: '/network',
121
permission: 'allocation.*',
122
name: 'Network',
123
component: NetworkContainer,
124
},
125
{
126
path: '/startup',
127
permission: 'startup.*',
128
name: 'Startup',
129
component: StartupContainer,
130
},
131
{
132
path: '/settings',
133
permission: ['settings.*', 'file.sftp'],
134
name: 'Settings',
135
component: SettingsContainer,
136
},
137
{
138
path: '/activity',
139
permission: 'activity.*',
140
name: 'Activity',
141
component: ServerActivityLogContainer,
142
},
143
],
144
} as Routes;
145
146