This repository was archived by the owner on Sep 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathroutes.tsx
More file actions
515 lines (496 loc) · 19.4 KB
/
routes.tsx
File metadata and controls
515 lines (496 loc) · 19.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
import { Navigate, useLocation } from 'react-router-dom'
import { lazyComponent } from '@sourcegraph/shared/src/util/lazyComponent'
import { FeedbackBadge } from '@sourcegraph/wildcard'
import type { BatchSpecsPageProps } from '../enterprise/batches/BatchSpecsPage'
import { SHOW_BUSINESS_FEATURES } from '../enterprise/dotcom/productSubscriptions/features'
import { OwnAnalyticsPage } from '../enterprise/own/admin-ui/OwnAnalyticsPage'
import type { SiteAdminRolesPageProps } from '../enterprise/rbac/SiteAdminRolesPage'
import type { RoleAssignmentModalProps } from '../enterprise/site-admin/UserManagement/components/RoleAssignmentModal'
import { GitHubAppKind } from '../graphql-operations'
import { checkRequestAccessAllowed } from '../util/checkRequestAccessAllowed'
import { isPackagesEnabled } from './flags'
import { PermissionsSyncJobsTable } from './permissions-center/PermissionsSyncJobsTable'
import type { SiteAdminAreaRoute } from './SiteAdminArea'
const AnalyticsOverviewPage = lazyComponent(() => import('./analytics/AnalyticsOverviewPage'), 'AnalyticsOverviewPage')
const AnalyticsSearchPage = lazyComponent(() => import('./analytics/AnalyticsSearchPage'), 'AnalyticsSearchPage')
const AnalyticsCodeIntelPage = lazyComponent(
() => import('./analytics/AnalyticsCodeIntelPage'),
'AnalyticsCodeIntelPage'
)
const AnalyticsExtensionsPage = lazyComponent(
() => import('./analytics/AnalyticsExtensionsPage'),
'AnalyticsExtensionsPage'
)
const AnalyticsUsersPage = lazyComponent(() => import('./analytics/AnalyticsUsersPage'), 'AnalyticsUsersPage')
const AnalyticsCodyPage = lazyComponent(() => import('./analytics/AnalyticsCodyPage'), 'AnalyticsCodyPage')
const AnalyticsCodeInsightsPage = lazyComponent(
() => import('./analytics/AnalyticsCodeInsightsPage'),
'AnalyticsCodeInsightsPage'
)
const AnalyticsBatchChangesPage = lazyComponent(
() => import('./analytics/AnalyticsBatchChangesPage'),
'AnalyticsBatchChangesPage'
)
const AnalyticsNotebooksPage = lazyComponent(
() => import('./analytics/AnalyticsNotebooksPage'),
'AnalyticsNotebooksPage'
)
const SiteAdminConfigurationPage = lazyComponent(
() => import('./SiteAdminConfigurationPage'),
'SiteAdminConfigurationPage'
)
const SiteAdminSettingsPage = lazyComponent(() => import('./SiteAdminSettingsPage'), 'SiteAdminSettingsPage')
const SiteAdminOnboardingTourPage = lazyComponent(
() => import('./SiteAdminOnboardingTourPage'),
'SiteAdminOnboardingTourPage'
)
const SiteAdminExternalServicesArea = lazyComponent(
() => import('./SiteAdminExternalServicesArea'),
'SiteAdminExternalServicesArea'
)
const SiteAdminGitHubAppsArea = lazyComponent(() => import('./SiteAdminGitHubAppsArea'), 'SiteAdminGitHubAppsArea')
const SiteAdminRepositoriesPage = lazyComponent(
() => import('./SiteAdminRepositoriesPage'),
'SiteAdminRepositoriesPage'
)
const SiteAdminOrgsPage = lazyComponent(() => import('./SiteAdminOrgsPage'), 'SiteAdminOrgsPage')
export const UsersManagement = lazyComponent(() => import('./UserManagement'), 'UsersManagement')
const AccessRequestsPage = lazyComponent(() => import('./AccessRequestsPage'), 'AccessRequestsPage')
const SiteAdminCreateUserPage = lazyComponent(() => import('./SiteAdminCreateUserPage'), 'SiteAdminCreateUserPage')
const SiteAdminTokensPage = lazyComponent(() => import('./SiteAdminTokensPage'), 'SiteAdminTokensPage')
const SiteAdminUpdatesPage = lazyComponent(() => import('./SiteAdminUpdatesPage'), 'SiteAdminUpdatesPage')
const SiteAdminPingsPage = lazyComponent(() => import('./SiteAdminPingsPage'), 'SiteAdminPingsPage')
const SiteAdminReportBugPage = lazyComponent(() => import('./SiteAdminReportBugPage'), 'SiteAdminReportBugPage')
const SiteAdminSurveyResponsesPage = lazyComponent(
() => import('./SiteAdminSurveyResponsesPage'),
'SiteAdminSurveyResponsesPage'
)
const SiteAdminMigrationsPage = lazyComponent(() => import('./SiteAdminMigrationsPage'), 'SiteAdminMigrationsPage')
const SiteAdminOutboundRequestsPage = lazyComponent(
() => import('./SiteAdminOutboundRequestsPage'),
'SiteAdminOutboundRequestsPage'
)
const SiteAdminBackgroundJobsPage = lazyComponent(
() => import('./SiteAdminBackgroundJobsPage'),
'SiteAdminBackgroundJobsPage'
)
const SiteAdminFeatureFlagsPage = lazyComponent(
() => import('./SiteAdminFeatureFlagsPage'),
'SiteAdminFeatureFlagsPage'
)
const SiteAdminFeatureFlagConfigurationPage = lazyComponent(
() => import('./SiteAdminFeatureFlagConfigurationPage'),
'SiteAdminFeatureFlagConfigurationPage'
)
const OutboundWebhooksPage = lazyComponent(
() => import('./outbound-webhooks/OutboundWebhooksPage'),
'OutboundWebhooksPage'
)
const OutgoingWebhookCreatePage = lazyComponent(() => import('./outbound-webhooks/CreatePage'), 'CreatePage')
const OutgoingWebhookEditPage = lazyComponent(() => import('./outbound-webhooks/EditPage'), 'EditPage')
const SiteAdminWebhooksPage = lazyComponent(() => import('./SiteAdminWebhooksPage'), 'SiteAdminWebhooksPage')
const SiteAdminWebhookCreatePage = lazyComponent(
() => import('./SiteAdminWebhookCreatePage'),
'SiteAdminWebhookCreatePage'
)
const SiteAdminWebhookPage = lazyComponent(() => import('./SiteAdminWebhookPage'), 'SiteAdminWebhookPage')
const SiteAdminSlowRequestsPage = lazyComponent(
() => import('./SiteAdminSlowRequestsPage'),
'SiteAdminSlowRequestsPage'
)
const SiteAdminWebhookUpdatePage = lazyComponent(
() => import('./SiteAdminWebhookUpdatePage'),
'SiteAdminWebhookUpdatePage'
)
const SiteAdminPackagesPage = lazyComponent(() => import('./SiteAdminPackagesPage'), 'SiteAdminPackagesPage')
const GitserversPageProps = lazyComponent(() => import('./SiteAdminGitserversPage'), 'SiteAdminGitserversPage')
const SiteAdminProductSubscriptionPage = lazyComponent(
() => import('../enterprise/site-admin/productSubscription/SiteAdminProductSubscriptionPage'),
'SiteAdminProductSubscriptionPage'
)
const SiteAdminProductCustomersPage = lazyComponent(
() => import('../enterprise/site-admin/dotcom/customers/SiteAdminCustomersPage'),
'SiteAdminProductCustomersPage'
)
const SiteAdminCreateProductSubscriptionPage = lazyComponent(
() => import('../enterprise/site-admin/dotcom/productSubscriptions/SiteAdminCreateProductSubscriptionPage'),
'SiteAdminCreateProductSubscriptionPage'
)
const DotComSiteAdminProductSubscriptionPage = lazyComponent(
() => import('../enterprise/site-admin/dotcom/productSubscriptions/SiteAdminProductSubscriptionPage'),
'SiteAdminProductSubscriptionPage'
)
const SiteAdminProductSubscriptionsPage = lazyComponent(
() => import('../enterprise/site-admin/dotcom/productSubscriptions/SiteAdminProductSubscriptionsPage'),
'SiteAdminProductSubscriptionsPage'
)
const SiteAdminLicenseKeyLookupPage = lazyComponent(
() => import('../enterprise/site-admin/dotcom/productSubscriptions/SiteAdminLicenseKeyLookupPage'),
'SiteAdminLicenseKeyLookupPage'
)
const SiteAdminAuthenticationProvidersPage = lazyComponent(
() => import('../enterprise/site-admin/SiteAdminAuthenticationProvidersPage'),
'SiteAdminAuthenticationProvidersPage'
)
const SiteAdminExternalAccountsPage = lazyComponent(
() => import('../enterprise/site-admin/SiteAdminExternalAccountsPage'),
'SiteAdminExternalAccountsPage'
)
const BatchChangesSiteConfigSettingsPage = lazyComponent(
() => import('../enterprise/batches/settings/BatchChangesSiteConfigSettingsPage'),
'BatchChangesSiteConfigSettingsPage'
)
const BatchChangesCreateGitHubAppPage = lazyComponent(
() => import('../enterprise/batches/settings/BatchChangesCreateGitHubAppPage'),
'BatchChangesCreateGitHubAppPage'
)
const GitHubAppPage = lazyComponent(() => import('../components/gitHubApps/GitHubAppPage'), 'GitHubAppPage')
const BatchSpecsPage = lazyComponent<BatchSpecsPageProps, 'BatchSpecsPage'>(
() => import('../enterprise/batches/BatchSpecsPage'),
'BatchSpecsPage'
)
const AdminCodeIntelArea = lazyComponent(
() => import('../enterprise/codeintel/admin/AdminCodeIntelArea'),
'AdminCodeIntelArea'
)
const SiteAdminPreciseIndexPage = lazyComponent(
() => import('../enterprise/site-admin/SiteAdminPreciseIndexPage'),
'SiteAdminPreciseIndexPage'
)
const ExecutorsSiteAdminArea = lazyComponent(
() => import('../enterprise/executors/ExecutorsSiteAdminArea'),
'ExecutorsSiteAdminArea'
)
const SiteAdminRolesPage = lazyComponent<SiteAdminRolesPageProps, 'SiteAdminRolesPage'>(
() => import('../enterprise/rbac/SiteAdminRolesPage'),
'SiteAdminRolesPage'
)
const RoleAssignmentModal = lazyComponent<RoleAssignmentModalProps, 'RoleAssignmentModal'>(
() => import('../enterprise/site-admin/UserManagement/components/RoleAssignmentModal'),
'RoleAssignmentModal'
)
const CodeInsightsJobsPage = lazyComponent(
() => import('../enterprise/insights/admin-ui/CodeInsightsJobs'),
'CodeInsightsJobs'
)
const OwnStatusPage = lazyComponent(() => import('../enterprise/own/admin-ui/OwnStatusPage'), 'OwnStatusPage')
export const otherSiteAdminRoutes: readonly SiteAdminAreaRoute[] = [
{
path: '/',
render: props => <AnalyticsOverviewPage {...props} />,
},
{
path: '/analytics/search',
render: props => <AnalyticsSearchPage {...props} />,
condition: () => window.context?.codeSearchEnabledOnInstance,
},
{
path: '/analytics/code-intel',
render: props => <AnalyticsCodeIntelPage {...props} />,
condition: () => window.context?.codeSearchEnabledOnInstance,
},
{
path: '/analytics/extensions',
render: props => <AnalyticsExtensionsPage {...props} />,
},
{
path: '/analytics/users',
render: props => <AnalyticsUsersPage {...props} />,
},
{
path: '/analytics/cody',
render: props => <AnalyticsCodyPage {...props} />,
condition: () => window.context?.codyEnabledOnInstance,
},
{
path: '/analytics/code-insights',
render: props => <AnalyticsCodeInsightsPage {...props} />,
condition: ({ codeInsightsEnabled }) => codeInsightsEnabled,
},
{
path: '/analytics/batch-changes',
render: props => <AnalyticsBatchChangesPage {...props} />,
condition: ({ batchChangesEnabled }) => batchChangesEnabled,
},
{
path: '/analytics/notebooks',
render: props => <AnalyticsNotebooksPage {...props} />,
condition: () => window.context?.codeSearchEnabledOnInstance,
},
{
path: '/configuration',
render: props => <SiteAdminConfigurationPage {...props} />,
},
{
path: '/global-settings',
render: props => <SiteAdminSettingsPage {...props} />,
},
{
path: '/end-user-onboarding',
render: props => <SiteAdminOnboardingTourPage {...props} />,
condition: ({ endUserOnboardingEnabled }) => endUserOnboardingEnabled,
},
{
path: '/github-apps/*',
render: props => <SiteAdminGitHubAppsArea {...props} />,
},
{
path: '/external-services/*',
render: props => <SiteAdminExternalServicesArea {...props} />,
},
{
path: '/repositories',
render: props => <SiteAdminRepositoriesPage {...props} />,
},
{
path: '/organizations',
render: props => <SiteAdminOrgsPage {...props} />,
},
{
path: '/account-requests',
render: props => <AccessRequestsPage {...props} />,
condition: () => checkRequestAccessAllowed(window.context),
},
{
path: '/users/new',
render: props => <SiteAdminCreateUserPage {...props} />,
},
{
path: '/tokens',
render: props => <SiteAdminTokensPage {...props} />,
},
{
path: '/updates',
render: props => <SiteAdminUpdatesPage {...props} />,
},
{
path: '/pings',
render: props => <SiteAdminPingsPage {...props} />,
},
{
path: '/report-bug',
render: props => <SiteAdminReportBugPage {...props} />,
},
{
path: '/surveys',
render: props => <SiteAdminSurveyResponsesPage {...props} />,
},
{
path: '/migrations',
render: props => <SiteAdminMigrationsPage {...props} />,
},
{
path: '/outbound-requests',
render: props => <SiteAdminOutboundRequestsPage {...props} />,
},
{
path: '/background-jobs',
render: props => <SiteAdminBackgroundJobsPage {...props} />,
},
{
path: '/feature-flags',
render: props => <SiteAdminFeatureFlagsPage {...props} />,
},
{
path: '/feature-flags/configuration/:name',
render: props => <SiteAdminFeatureFlagConfigurationPage {...props} />,
},
{
path: '/webhooks/outgoing',
render: props => <OutboundWebhooksPage {...props} />,
},
{
path: '/webhooks/outgoing/create',
render: props => <OutgoingWebhookCreatePage {...props} />,
},
{
path: '/webhooks/outgoing/:id',
render: props => <OutgoingWebhookEditPage {...props} />,
},
{
path: '/webhooks/incoming',
render: props => <SiteAdminWebhooksPage {...props} />,
},
{
path: '/webhooks/incoming/create',
render: props => <SiteAdminWebhookCreatePage {...props} />,
},
{
path: '/webhooks/incoming/:id',
render: props => <SiteAdminWebhookPage {...props} />,
},
{
path: '/webhooks/incoming/:id/edit',
render: props => <SiteAdminWebhookUpdatePage {...props} />,
},
{
path: '/slow-requests',
render: props => <SiteAdminSlowRequestsPage {...props} />,
},
{
path: '/packages',
render: props => <SiteAdminPackagesPage {...props} />,
condition: isPackagesEnabled,
},
{
path: '/permissions-syncs',
render: props => <PermissionsSyncJobsTable {...props} />,
},
{
path: '/gitservers',
render: props => <GitserversPageProps {...props} />,
},
{
path: '/users',
render: props => (
<UsersManagement
renderAssignmentModal={(onCancel, onSuccess, user) => (
<RoleAssignmentModal onCancel={onCancel} onSuccess={onSuccess} user={user} />
)}
{...props}
/>
),
},
{
path: '/license',
render: props => (
<SiteAdminProductSubscriptionPage telemetryRecorder={props.platformContext.telemetryRecorder} />
),
},
{
path: '/dotcom/customers',
render: props => <SiteAdminProductCustomersPage telemetryRecorder={props.platformContext.telemetryRecorder} />,
condition: () => SHOW_BUSINESS_FEATURES,
},
{
path: '/dotcom/product/subscriptions/new',
render: props => <SiteAdminCreateProductSubscriptionPage {...props} />,
condition: () => SHOW_BUSINESS_FEATURES,
},
{
path: '/dotcom/product/subscriptions/:subscriptionUUID',
render: props => <DotComSiteAdminProductSubscriptionPage {...props} />,
condition: () => SHOW_BUSINESS_FEATURES,
},
{
path: '/dotcom/product/subscriptions',
render: props => (
<SiteAdminProductSubscriptionsPage {...props} telemetryRecorder={props.platformContext.telemetryRecorder} />
),
condition: () => SHOW_BUSINESS_FEATURES,
},
{
path: '/dotcom/product/licenses',
render: props => <SiteAdminLicenseKeyLookupPage {...props} />,
condition: () => SHOW_BUSINESS_FEATURES,
},
{
path: '/auth/providers',
render: () => <SiteAdminAuthenticationProvidersPage />,
},
{
path: '/auth/external-accounts',
render: () => <SiteAdminExternalAccountsPage />,
},
{
path: '/batch-changes',
render: props => <BatchChangesSiteConfigSettingsPage {...props} />,
condition: ({ batchChangesEnabled }) => batchChangesEnabled,
},
{
path: '/batch-changes/github-apps/new',
render: ({ authenticatedUser }) => (
<BatchChangesCreateGitHubAppPage
authenticatedUser={authenticatedUser}
kind={GitHubAppKind.COMMIT_SIGNING}
/>
),
condition: ({ batchChangesEnabled }) => batchChangesEnabled,
},
{
path: '/batch-changes/github-apps/:appID',
render: props => (
<GitHubAppPage
headerParentBreadcrumb={{ to: '/site-admin/batch-changes', text: 'Batch Changes settings' }}
headerAnnotation={<FeedbackBadge status="beta" feedback={{ mailto: 'support@sourcegraph.com' }} />}
telemetryService={props.telemetryService}
telemetryRecorder={props.platformContext.telemetryRecorder}
userOwned={false}
/>
),
condition: ({ batchChangesEnabled }) => batchChangesEnabled,
},
{
path: '/batch-changes/specs',
render: props => <BatchSpecsPage {...props} />,
condition: ({ batchChangesEnabled, batchChangesExecutionEnabled }) =>
batchChangesEnabled && batchChangesExecutionEnabled,
},
// Old batch changes webhooks logs page redirects to new incoming webhooks page.
// The old page components and documentation are still available in the codebase
// but should be fully removed in the next release.
{
path: '/batch-changes/webhook-logs',
render: () => <Navigate to="/site-admin/webhooks/incoming" replace={true} />,
condition: ({ batchChangesEnabled, batchChangesWebhookLogsEnabled }) =>
batchChangesEnabled && batchChangesWebhookLogsEnabled,
},
// Enterprise maintenance area
{
exact: true,
path: '/code-insights-jobs',
render: props => <CodeInsightsJobsPage {...props} />,
condition: ({ codeInsightsEnabled }) => codeInsightsEnabled,
},
{
exact: true,
path: '/own-signal-page',
render: props => <OwnStatusPage telemetryRecorder={props.platformContext.telemetryRecorder} />,
},
// Code intelligence redirect
{
path: '/code-intelligence/*',
render: () => <NavigateToCodeGraph />,
condition: () => window.context?.codeSearchEnabledOnInstance,
},
// Code graph routes
{
path: '/code-graph/*',
render: props => <AdminCodeIntelArea {...props} />,
condition: () => window.context?.codeSearchEnabledOnInstance,
},
{
path: '/lsif-uploads/:id',
render: props => <SiteAdminPreciseIndexPage {...props} />,
},
// Executor routes
{
path: '/executors/*',
render: props => <ExecutorsSiteAdminArea telemetryRecorder={props.platformContext.telemetryRecorder} />,
condition: () => Boolean(window.context?.executorsEnabled),
},
// rbac-related routes
{
path: '/roles',
exact: true,
render: props => <SiteAdminRolesPage telemetryRecorder={props.platformContext.telemetryRecorder} />,
},
// Own analytics
{
exact: true,
path: '/analytics/own',
render: props => <OwnAnalyticsPage telemetryRecorder={props.platformContext.telemetryRecorder} />,
},
]
function NavigateToCodeGraph(): JSX.Element {
const location = useLocation()
return <Navigate to={location.pathname.replace('/code-intelligence', '/code-graph')} />
}
const siteAdminUserManagementRoute: SiteAdminAreaRoute = {
path: '/users',
render: props => <UsersManagement renderAssignmentModal={() => null} {...props} />,
}
export const siteAdminAreaRoutes: readonly SiteAdminAreaRoute[] = [
...otherSiteAdminRoutes,
siteAdminUserManagementRoute,
]