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 pathUserGitHubAppsArea.tsx
More file actions
67 lines (56 loc) · 2.29 KB
/
Copy pathUserGitHubAppsArea.tsx
File metadata and controls
67 lines (56 loc) · 2.29 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
import type { FC } from 'react'
import { Route, Routes } 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 { ErrorAlert, LoadingSpinner } from '@sourcegraph/wildcard'
import { type SiteExternalServiceConfigResult, type SiteExternalServiceConfigVariables } from '../../graphql-operations'
import { SITE_EXTERNAL_SERVICE_CONFIG } from '../../site-admin/backend'
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
}
export const UserGitHubAppsArea: 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}
userOwned={true}
/>
}
/>
<Route
path=":appID"
element={
<GitHubAppPage
headerParentBreadcrumb={{ to: '/user/github-apps', text: 'GitHub Apps' }}
telemetryRecorder={props.platformContext.telemetryRecorder}
userOwned={true}
{...props}
/>
}
/>
</Routes>
)
}