parent
9b0389616e
commit
320f4420bd
@ -1,51 +0,0 @@ |
||||
import React, { useEffect } from "react"; |
||||
import { gitActionsContext, pluginActionsContext } from "../../state/context"; |
||||
import { gitPluginContext, loaderContext } from "../gitui"; |
||||
import axios from "axios"; |
||||
import { CopyToClipboard } from "@remix-ui/clipboard"; |
||||
import { Card } from "react-bootstrap"; |
||||
|
||||
export const GitHubAuth = () => { |
||||
const context = React.useContext(gitPluginContext) |
||||
const actions = React.useContext(gitActionsContext) |
||||
const loader = React.useContext(loaderContext) |
||||
const pluginActions = React.useContext(pluginActionsContext) |
||||
const [gitHubResponse, setGitHubResponse] = React.useState<any>(null) |
||||
const [authorized, setAuthorized] = React.useState<boolean>(false) |
||||
|
||||
useEffect(() => { |
||||
checkConnection() |
||||
}, [context.gitHubAccessToken, loader.plugin]) |
||||
|
||||
const checkConnection = async () => { |
||||
console.log('checkConnection', context.gitHubAccessToken) |
||||
await actions.getGitHubUser() |
||||
} |
||||
|
||||
useEffect(() => { |
||||
console.log('context.rateLimit', context.rateLimit) |
||||
}, [context.rateLimit]) |
||||
|
||||
return ( |
||||
<> |
||||
{(context.gitHubUser && context.gitHubUser.login) ? null : |
||||
<li className="text-warning list-group-item d-flex justify-content-between align-items-center"> |
||||
Not connected to GitHub. Add a valid token.</li> |
||||
} |
||||
{ |
||||
(context.gitHubUser && context.gitHubUser.login) ? |
||||
<div className="pt-2"> |
||||
<Card> |
||||
<Card.Body> |
||||
<Card.Title>Connected as {context.gitHubUser.login}</Card.Title> |
||||
<Card.Text> |
||||
<img src={context.gitHubUser.avatar_url} className="w-100" /> |
||||
<a target="_blank" href={context.gitHubUser.html_url}>{context.gitHubUser.html_url}</a> |
||||
</Card.Text> |
||||
</Card.Body> |
||||
</Card> |
||||
</div>: null |
||||
} |
||||
|
||||
</>) |
||||
} |
@ -0,0 +1,51 @@ |
||||
import { ReadCommitResult } from "isomorphic-git" |
||||
import { branch, branchDifference, commitChange, fileStatusResult, GitHubUser, gitLog, pagedCommits, remote, remoteBranch, repository, userEmails } from "../types" |
||||
|
||||
export interface ActionPayloadTypes { |
||||
FILE_STATUS: fileStatusResult[], |
||||
FILE_STATUS_MERGE: fileStatusResult[] |
||||
SET_COMMITS: ReadCommitResult[] |
||||
SET_BRANCHES: branch[] |
||||
SET_CURRENT_BRANCH: branch |
||||
SET_CAN_USE_APP: boolean |
||||
SET_REPO_NAME: string |
||||
SET_LOADING: boolean |
||||
SET_REPOS: repository[] |
||||
SET_REMOTE_BRANCHES: remoteBranch[] |
||||
SET_CAN_COMMIT: boolean |
||||
SET_REMOTES: remote[] |
||||
SET_UPSTREAM: remote |
||||
SET_COMMIT_CHANGES: commitChange[] |
||||
RESET_REMOTE_BRANCH_COMMITS: { |
||||
branch: branch |
||||
pagedCommits: pagedCommits[] |
||||
} |
||||
SET_REMOTE_BRANCH_COMMITS: { |
||||
branch: branch |
||||
commits: pagedCommits[] |
||||
} |
||||
SET_LOCAL_BRANCH_COMMITS: { |
||||
branch: branch |
||||
commits: ReadCommitResult[] |
||||
} |
||||
SET_BRANCH_DIFFERENCES: { |
||||
branch: branch |
||||
remote: remote |
||||
branchDifference: branchDifference |
||||
} |
||||
SET_GITHUB_USER: GitHubUser |
||||
SET_RATE_LIMIT: any |
||||
SET_GITHUB_ACCESS_TOKEN: string |
||||
SET_SCOPES: string[] |
||||
SET_DEFAULT_REMOTE: remote |
||||
SET_LOG: gitLog |
||||
CLEAR_LOG: void |
||||
SET_USER_EMAILS: userEmails |
||||
} |
||||
|
||||
export interface Action<T extends keyof ActionPayloadTypes> { |
||||
type: T, |
||||
payload: ActionPayloadTypes[T] |
||||
} |
||||
|
||||
export type Actions = {[A in keyof ActionPayloadTypes]: Action<A>}[keyof ActionPayloadTypes] |
Loading…
Reference in new issue