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 pathSiteAdminGitHubAppsArea.tsx
More file actions
109 lines (95 loc) · 3.26 KB
/
SiteAdminGitHubAppsArea.tsx
File metadata and controls
109 lines (95 loc) · 3.26 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
import type { FC } from 'react'
import { Routes, Route } from 'react-router-dom'
import { useQuery } from '@sourcegraph/http-client'
import type { AuthenticatedUser } from '@sourcegraph/shared/src/auth'
import type { PlatformContextProps } from '@sourcegraph/shared/src/platform/context'
import type { TelemetryProps } from '@sourcegraph/shared/src/telemetry/telemetryService'
import { lazyComponent } from '@sourcegraph/shared/src/util/lazyComponent'
import { LoadingSpinner, ErrorAlert } from '@sourcegraph/wildcard'
import {
GitHubAppDomain,
GitHubAppKind,
type SiteExternalServiceConfigResult,
type SiteExternalServiceConfigVariables,
} from '../graphql-operations'
import { SITE_EXTERNAL_SERVICE_CONFIG } from './backend'
const CreateGitHubAppPage = lazyComponent(
() => import('../components/gitHubApps/CreateGitHubAppPage'),
'CreateGitHubAppPage'
)
const GitHubAppPage = lazyComponent(() => import('../components/gitHubApps/GitHubAppPage'), 'GitHubAppPage')
const GitHubAppsPage = lazyComponent(() => import('../components/gitHubApps/GitHubAppsPage'), 'GitHubAppsPage')
interface Props extends TelemetryProps, PlatformContextProps {
authenticatedUser: AuthenticatedUser
batchChangesEnabled: boolean
}
const DEFAULT_EVENTS = [
'repository',
'public',
'member',
'membership',
'organization',
'team',
'team_add',
'meta',
'push',
]
const DEFAULT_PERMISSIONS = {
contents: 'read',
emails: 'read',
members: 'read',
metadata: 'read',
}
export const SiteAdminGitHubAppsArea: FC<Props> = props => {
const { data, error, loading } = useQuery<SiteExternalServiceConfigResult, SiteExternalServiceConfigVariables>(
SITE_EXTERNAL_SERVICE_CONFIG,
{}
)
if (error && !loading) {
return <ErrorAlert error={error} />
}
if (loading && !error) {
return <LoadingSpinner />
}
if (!data) {
return null
}
return (
<Routes>
<Route
index={true}
element={
<GitHubAppsPage
batchChangesEnabled={props.batchChangesEnabled}
telemetryRecorder={props.platformContext.telemetryRecorder}
isSiteAdmin={true}
/>
}
/>
<Route
path="new"
element={
<CreateGitHubAppPage
appKind={GitHubAppKind.REPO_SYNC}
defaultEvents={DEFAULT_EVENTS}
defaultPermissions={DEFAULT_PERMISSIONS}
appDomain={GitHubAppDomain.REPOS}
telemetryRecorder={props.platformContext.telemetryRecorder}
{...props}
/>
}
/>
<Route
path=":appID"
element={
<GitHubAppPage
headerParentBreadcrumb={{ to: '/site-admin/github-apps', text: 'GitHub Apps' }}
telemetryRecorder={props.platformContext.telemetryRecorder}
isSiteAdmin={true}
{...props}
/>
}
/>
</Routes>
)
}