mirror of
https://github.com/EnixCoda/Gitako.git
synced 2026-03-11 08:54:44 +00:00
refactor: reuse access denied description
This commit is contained in:
parent
ea1123bfec
commit
ed3b117d30
3 changed files with 39 additions and 41 deletions
37
src/components/AccessDeniedDescription.tsx
Normal file
37
src/components/AccessDeniedDescription.tsx
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
import { usePlatform } from 'containers/PlatformContext'
|
||||
import { GITHUB_OAUTH } from 'env'
|
||||
import { GitHub } from 'platforms/GitHub'
|
||||
import * as React from 'react'
|
||||
|
||||
export function AccessDeniedDescription({ hasToken }: { hasToken: boolean }) {
|
||||
const platform = usePlatform()
|
||||
return (
|
||||
<div className={'description'}>
|
||||
<h5>Access Denied</h5>
|
||||
{hasToken ? (
|
||||
<>
|
||||
<p>
|
||||
Current access token is either invalid or not granted with permissions to access this
|
||||
project.
|
||||
</p>
|
||||
{platform === GitHub && (
|
||||
<p>
|
||||
You can grant or request access{' '}
|
||||
<a
|
||||
href={`https://github.com/settings/connections/applications/${GITHUB_OAUTH.clientId}`}
|
||||
>
|
||||
here
|
||||
</a>{' '}
|
||||
if you setup Gitako with OAuth.
|
||||
</p>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
<p>
|
||||
Gitako needs access token to read this project. Please setup access token in the settings
|
||||
panel below.
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
import { raiseError } from 'analytics'
|
||||
import { AccessDeniedDescription } from 'components/AccessDeniedDescription'
|
||||
import { FileExplorer } from 'components/FileExplorer'
|
||||
import { MetaBar } from 'components/MetaBar'
|
||||
import { Portal } from 'components/Portal'
|
||||
|
|
@ -12,7 +13,6 @@ import { SideBarCore } from 'driver/core'
|
|||
import { ConnectorState, Props } from 'driver/core/SideBar'
|
||||
import { platform } from 'platforms'
|
||||
import { useGitHubAttachCopyFileButton, useGitHubAttachCopySnippetButton } from 'platforms/GitHub'
|
||||
import { GitHubAccessDeniedError } from 'platforms/GitHub/components'
|
||||
import * as React from 'react'
|
||||
import { useEvent, useUpdateEffect } from 'react-use'
|
||||
import { cx } from 'utils/cx'
|
||||
|
|
@ -144,7 +144,7 @@ RawGitako.defaultProps = {
|
|||
export const SideBar = connect(SideBarCore)(RawGitako)
|
||||
|
||||
function AccessDeniedError({ hasToken }: { hasToken: boolean }) {
|
||||
return <GitHubAccessDeniedError hasToken={hasToken} />
|
||||
return <AccessDeniedDescription hasToken={hasToken} />
|
||||
}
|
||||
|
||||
async function trySetUpAccessTokenWithCode() {
|
||||
|
|
|
|||
|
|
@ -1,39 +0,0 @@
|
|||
import { GITHUB_OAUTH } from 'env'
|
||||
import * as React from 'react'
|
||||
|
||||
export function GitHubAccessDeniedError({ hasToken }: { hasToken: boolean }) {
|
||||
return (
|
||||
<div className={'description'}>
|
||||
<h5>Access Denied</h5>
|
||||
{hasToken ? (
|
||||
<>
|
||||
<p>
|
||||
Current access token is either invalid or not granted with permissions to access this
|
||||
project.
|
||||
</p>
|
||||
<p>
|
||||
You can grant or request access{' '}
|
||||
<a
|
||||
href={`https://github.com/settings/connections/applications/${GITHUB_OAUTH.clientId}`}
|
||||
>
|
||||
here
|
||||
</a>{' '}
|
||||
if you setup Gitako with OAuth.
|
||||
</p>
|
||||
</>
|
||||
) : (
|
||||
<p>
|
||||
Gitako needs access token to read this project due to{' '}
|
||||
<a href="https://developer.github.com/v3/#rate-limiting" target="_blank">
|
||||
GitHub rate limiting
|
||||
</a>{' '}
|
||||
and{' '}
|
||||
<a href="https://developer.github.com/v3/#authentication" target="_blank">
|
||||
auth needs
|
||||
</a>
|
||||
. Please setup access token in the settings panel below.
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Loading…
Reference in a new issue