Merge branch 'feature/access-token-help' into develop

This commit is contained in:
EnixCoda 2019-11-20 10:45:11 +08:00
commit 73fea83d20
No known key found for this signature in database
GPG key ID: FE06F5DFC1C9B8E4
2 changed files with 29 additions and 15 deletions

View file

@ -109,7 +109,7 @@ const RawGitako: React.FC<Props & ConnectorState> = function RawGitako(props) {
<div className={'gitako-side-bar-content'}>
{metaData && <MetaBar metaData={metaData} />}
{errorDueToAuth
? renderAccessDeniedError()
? renderAccessDeniedError(Boolean(accessToken))
: metaData && (
<FileExplorer
toggleShowSettings={toggleShowSettings}
@ -137,22 +137,37 @@ RawGitako.defaultProps = {
export const SideBar = connect(SideBarCore)(RawGitako)
function renderAccessDeniedError() {
function renderAccessDeniedError(hasToken: boolean) {
return (
<div className={'description'}>
<h5>Access Denied</h5>
<p>
Due to{' '}
<a target="_blank" href="https://developer.github.com/v3/#rate-limiting">
limitation of GitHub
</a>{' '}
or{' '}
<a target="_blank" href="https://developer.github.com/v3/#authentication">
auth needs
</a>
, Gitako needs access token to continue. Please follow the instructions in the settings
panel below.
</p>
{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/${oauth.clientId}`}>
here
</a>{' '}
if you setup Gitako with OAuth.
</p>
</>
) : (
<p>
Gitako needs access token to read this project due to{' '}
<a target="_blank" href="https://developer.github.com/v3/#rate-limiting">
GitHub rate limiting
</a>{' '}
and{' '}
<a target="_blank" href="https://developer.github.com/v3/#authentication">
auth needs
</a>
. Please setup access token in the settings panel below.
</p>
)}
</div>
)
}

View file

@ -140,7 +140,6 @@ export const handleError: BoundMethodCreator<[Error]> = dispatch => async err =>
) {
dispatch.set({ errorDueToAuth: true })
dispatch.call(setShowSettings, true)
dispatch.call(setShouldShow, true)
} else {
dispatch.call(setError, 'Gitako ate a bug, but it should recovery soon!')
throw err