From 30a976969fc5b179af2cb751228d3fc5cd8cd029 Mon Sep 17 00:00:00 2001 From: EnixCoda Date: Sun, 29 Mar 2020 18:05:22 +0800 Subject: [PATCH] feat: gave a try on Gitee OAuth and gave up --- .../settings/AccessTokenSettings.tsx | 26 ++++++++++++------- src/env.ts | 8 +++--- src/platforms/GitHub/index.ts | 9 ++++--- src/platforms/Gitee/index.ts | 16 +++++++----- 4 files changed, 36 insertions(+), 23 deletions(-) diff --git a/src/components/settings/AccessTokenSettings.tsx b/src/components/settings/AccessTokenSettings.tsx index 6986f0f..30c9f33 100644 --- a/src/components/settings/AccessTokenSettings.tsx +++ b/src/components/settings/AccessTokenSettings.tsx @@ -2,11 +2,12 @@ import { Button, TextInput } from '@primer/components' import { wikiLinks } from 'components/settings/SettingsBar' import { useConfigs } from 'containers/ConfigsContext' import { usePlatform } from 'containers/PlatformContext' +import { Gitee } from 'platforms/Gitee' import * as React from 'react' import { useStates } from 'utils/hooks/useStates' import { SettingsSection } from './SettingsSection' -const ACCESS_TOKEN_REGEXP = /^[0-9a-f]{40}$/ +const ACCESS_TOKEN_REGEXP = /^[0-9a-f]+$/ type Props = {} @@ -75,15 +76,20 @@ export function AccessTokenSettings(props: React.PropsWithChildren) { ) : (
- { - // use js here to make sure redirect_uri is latest url - window.location.href = platform.getOAuthLink() - }} - > - Create with OAuth (recommended) - + {platform === Gitee ? ( + // disabled for Gitee as it does not support dynamic redirect_uri + OAuth for Gitee is unavailable + ) : ( + { + // use js here to make sure redirect_uri is latest url + window.location.href = platform.getOAuthLink() + }} + > + Create with OAuth (recommended) + + )}