diff --git a/src/components/AccessDeniedDescription.tsx b/src/components/AccessDeniedDescription.tsx new file mode 100644 index 0000000..4b334f1 --- /dev/null +++ b/src/components/AccessDeniedDescription.tsx @@ -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 ( +
+
Access Denied
+ {hasToken ? ( + <> +

+ Current access token is either invalid or not granted with permissions to access this + project. +

+ {platform === GitHub && ( +

+ You can grant or request access{' '} + + here + {' '} + if you setup Gitako with OAuth. +

+ )} + + ) : ( +

+ Gitako needs access token to read this project. Please setup access token in the settings + panel below. +

+ )} +
+ ) +} diff --git a/src/components/SideBar.tsx b/src/components/SideBar.tsx index c475100..7c2c374 100644 --- a/src/components/SideBar.tsx +++ b/src/components/SideBar.tsx @@ -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 + return } async function trySetUpAccessTokenWithCode() { diff --git a/src/platforms/GitHub/components.tsx b/src/platforms/GitHub/components.tsx deleted file mode 100644 index eef51ba..0000000 --- a/src/platforms/GitHub/components.tsx +++ /dev/null @@ -1,39 +0,0 @@ -import { GITHUB_OAUTH } from 'env' -import * as React from 'react' - -export function GitHubAccessDeniedError({ hasToken }: { hasToken: boolean }) { - return ( -
-
Access Denied
- {hasToken ? ( - <> -

- Current access token is either invalid or not granted with permissions to access this - project. -

-

- You can grant or request access{' '} - - here - {' '} - if you setup Gitako with OAuth. -

- - ) : ( -

- Gitako needs access token to read this project due to{' '} - - GitHub rate limiting - {' '} - and{' '} - - auth needs - - . Please setup access token in the settings panel below. -

- )} -
- ) -}