|
|
|
@ -1,5 +1,5 @@ |
|
|
|
|
import React, { useEffect, useReducer, useState } from 'react' |
|
|
|
|
import { add, addall, checkout, checkoutfile, clone, commit, createBranch, remoteBranches, repositories, rm, getCommitChanges, diff, resolveRef, getBranchCommits, setUpstreamRemote, loadGitHubUserFromToken, getBranches, getRemotes, remoteCommits, saveGitHubCredentials, getGitHubCredentialsFromLocalStorage, fetch, pull, push, setDefaultRemote, addRemote, removeRemote, sendToGitLog, clearGitLog, getBranchDifferences, getFileStatusMatrix } from '../lib/gitactions' |
|
|
|
|
import { add, addall, checkout, checkoutfile, clone, commit, createBranch, remoteBranches, repositories, rm, getCommitChanges, diff, resolveRef, getBranchCommits, setUpstreamRemote, loadGitHubUserFromToken, getBranches, getRemotes, remoteCommits, saveGitHubCredentials, getGitHubCredentialsFromLocalStorage, fetch, pull, push, setDefaultRemote, addRemote, removeRemote, sendToGitLog, clearGitLog, getBranchDifferences, getFileStatusMatrix, init } from '../lib/gitactions' |
|
|
|
|
import { loadFiles, setCallBacks } from '../lib/listeners' |
|
|
|
|
import { openDiff, openFile, saveToken, setModifiedDecorator, setPlugin, setUntrackedDecorator, statusChanged } from '../lib/pluginActions' |
|
|
|
|
import { gitActionsContext, pluginActionsContext } from '../state/context' |
|
|
|
@ -30,12 +30,15 @@ import { BranchHeader } from './branchHeader' |
|
|
|
|
import { SourceControl } from './panels/sourcontrol' |
|
|
|
|
import { GitHubCredentials } from './panels/githubcredentials' |
|
|
|
|
import { Setup } from './panels/setup' |
|
|
|
|
import { Init } from './panels/init' |
|
|
|
|
import { CustomRemixApi } from "@remix-api"; |
|
|
|
|
import { Plugin } from "@remixproject/engine"; |
|
|
|
|
|
|
|
|
|
export const gitPluginContext = React.createContext<gitState>(defaultGitState) |
|
|
|
|
export const loaderContext = React.createContext<loaderState>(defaultLoaderState) |
|
|
|
|
|
|
|
|
|
interface IGitUi { |
|
|
|
|
plugin: ViewPlugin |
|
|
|
|
plugin: Plugin<any, CustomRemixApi> |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export const GitUI = (props: IGitUi) => { |
|
|
|
@ -44,6 +47,7 @@ export const GitUI = (props: IGitUi) => { |
|
|
|
|
const [loaderState, loaderDispatch] = useReducer(loaderReducer, defaultLoaderState) |
|
|
|
|
const [activePanel, setActivePanel] = useState<string>("0") |
|
|
|
|
const [setup, setSetup] = useState<boolean>(false) |
|
|
|
|
const [needsInit, setNeedsInit] = useState<boolean>(true) |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
setCallBacks(plugin, gitDispatch, loaderDispatch) |
|
|
|
@ -54,7 +58,7 @@ export const GitUI = (props: IGitUi) => { |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
async function checkconfig() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const username = await plugin.call('settings', 'get', 'settings/github-user-name') |
|
|
|
|
const email = await plugin.call('settings', 'get', 'settings/github-email') |
|
|
|
|
const token = await plugin.call('settings', 'get', 'settings/gist-access-token') |
|
|
|
@ -62,7 +66,7 @@ export const GitUI = (props: IGitUi) => { |
|
|
|
|
setSetup(!(username && email)) |
|
|
|
|
} |
|
|
|
|
checkconfig() |
|
|
|
|
},[gitState.gitHubAccessToken, gitState.gitHubUser, gitState.userEmails]) |
|
|
|
|
}, [gitState.gitHubAccessToken, gitState.gitHubUser, gitState.userEmails]) |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
|
|
|
|
@ -90,8 +94,10 @@ export const GitUI = (props: IGitUi) => { |
|
|
|
|
updatestate() |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
setNeedsInit(!(gitState.currentBranch && gitState.currentBranch.name !== '')) |
|
|
|
|
|
|
|
|
|
}, [gitState.gitHubUser, gitState.currentBranch, gitState.remotes, gitState.gitHubAccessToken]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const gitActionsProviderValue = { |
|
|
|
|
commit, |
|
|
|
@ -121,7 +127,8 @@ export const GitUI = (props: IGitUi) => { |
|
|
|
|
removeRemote, |
|
|
|
|
sendToGitLog, |
|
|
|
|
clearGitLog, |
|
|
|
|
getFileStatusMatrix |
|
|
|
|
getFileStatusMatrix, |
|
|
|
|
init |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const pluginActionsProviderValue = { |
|
|
|
@ -139,70 +146,72 @@ export const GitUI = (props: IGitUi) => { |
|
|
|
|
<gitPluginContext.Provider value={gitState}> |
|
|
|
|
<loaderContext.Provider value={loaderState}> |
|
|
|
|
<gitActionsContext.Provider value={gitActionsProviderValue}> |
|
|
|
|
<BranchHeader/> |
|
|
|
|
<BranchHeader /> |
|
|
|
|
<pluginActionsContext.Provider value={pluginActionsProviderValue}> |
|
|
|
|
{setup? <Setup></Setup>: null} |
|
|
|
|
<Accordion activeKey={activePanel} defaultActiveKey="0"> |
|
|
|
|
<SourceControlNavigation eventKey="0" activePanel={activePanel} callback={setActivePanel} /> |
|
|
|
|
|
|
|
|
|
<Accordion.Collapse className='bg-light' eventKey="0"> |
|
|
|
|
<> |
|
|
|
|
<SourceControlBase><CommitMessage/></SourceControlBase> |
|
|
|
|
<SourceControl/> |
|
|
|
|
</> |
|
|
|
|
</Accordion.Collapse> |
|
|
|
|
<hr></hr> |
|
|
|
|
<CommandsNavigation eventKey="1" activePanel={activePanel} callback={setActivePanel} /> |
|
|
|
|
<Accordion.Collapse className='bg-light' eventKey="1"> |
|
|
|
|
<> |
|
|
|
|
<Commands></Commands> |
|
|
|
|
</> |
|
|
|
|
</Accordion.Collapse> |
|
|
|
|
<hr></hr> |
|
|
|
|
<CommitsNavigation title={`COMMITS`} eventKey="3" activePanel={activePanel} callback={setActivePanel} showButtons={true} /> |
|
|
|
|
<Accordion.Collapse className='bg-light' eventKey="3"> |
|
|
|
|
<> |
|
|
|
|
<Commits /> |
|
|
|
|
</> |
|
|
|
|
</Accordion.Collapse> |
|
|
|
|
<hr></hr> |
|
|
|
|
<BranchesNavigation eventKey="2" activePanel={activePanel} callback={setActivePanel} /> |
|
|
|
|
<Accordion.Collapse className='bg-light' eventKey="2"> |
|
|
|
|
<> |
|
|
|
|
<Branches/></> |
|
|
|
|
</Accordion.Collapse> |
|
|
|
|
<hr></hr> |
|
|
|
|
<RemotesNavigation eventKey="5" activePanel={activePanel} callback={setActivePanel} /> |
|
|
|
|
<Accordion.Collapse className='bg-light' eventKey="5"> |
|
|
|
|
<> |
|
|
|
|
<Remotes></Remotes> |
|
|
|
|
</> |
|
|
|
|
</Accordion.Collapse> |
|
|
|
|
<hr></hr> |
|
|
|
|
<CloneNavigation eventKey="4" activePanel={activePanel} callback={setActivePanel} /> |
|
|
|
|
<Accordion.Collapse className='bg-light' eventKey="4"> |
|
|
|
|
<> |
|
|
|
|
<Clone /></> |
|
|
|
|
</Accordion.Collapse> |
|
|
|
|
<hr></hr> |
|
|
|
|
<GitHubNavigation eventKey="7" activePanel={activePanel} callback={setActivePanel} /> |
|
|
|
|
<Accordion.Collapse className='bg-light' eventKey="7"> |
|
|
|
|
<> |
|
|
|
|
<GetDeviceCode></GetDeviceCode> |
|
|
|
|
<hr></hr> |
|
|
|
|
<GitHubCredentials></GitHubCredentials> |
|
|
|
|
</> |
|
|
|
|
</Accordion.Collapse> |
|
|
|
|
<hr></hr> |
|
|
|
|
<LogNavigation eventKey="6" activePanel={activePanel} callback={setActivePanel} /> |
|
|
|
|
<Accordion.Collapse className='bg-light' eventKey="6"> |
|
|
|
|
<> |
|
|
|
|
<LogViewer/> |
|
|
|
|
</> |
|
|
|
|
</Accordion.Collapse> |
|
|
|
|
|
|
|
|
|
</Accordion> |
|
|
|
|
|
|
|
|
|
{setup && !needsInit ? <Setup></Setup> : null} |
|
|
|
|
{needsInit ? <Init></Init> : null} |
|
|
|
|
{!setup && !needsInit ? |
|
|
|
|
<Accordion activeKey={activePanel} defaultActiveKey="0"> |
|
|
|
|
<SourceControlNavigation eventKey="0" activePanel={activePanel} callback={setActivePanel} /> |
|
|
|
|
|
|
|
|
|
<Accordion.Collapse className='bg-light' eventKey="0"> |
|
|
|
|
<> |
|
|
|
|
<SourceControlBase><CommitMessage /></SourceControlBase> |
|
|
|
|
<SourceControl /> |
|
|
|
|
</> |
|
|
|
|
</Accordion.Collapse> |
|
|
|
|
<hr></hr> |
|
|
|
|
<CommandsNavigation eventKey="1" activePanel={activePanel} callback={setActivePanel} /> |
|
|
|
|
<Accordion.Collapse className='bg-light' eventKey="1"> |
|
|
|
|
<> |
|
|
|
|
<Commands></Commands> |
|
|
|
|
</> |
|
|
|
|
</Accordion.Collapse> |
|
|
|
|
<hr></hr> |
|
|
|
|
<CommitsNavigation title={`COMMITS`} eventKey="3" activePanel={activePanel} callback={setActivePanel} showButtons={true} /> |
|
|
|
|
<Accordion.Collapse className='bg-light' eventKey="3"> |
|
|
|
|
<> |
|
|
|
|
<Commits /> |
|
|
|
|
</> |
|
|
|
|
</Accordion.Collapse> |
|
|
|
|
<hr></hr> |
|
|
|
|
<BranchesNavigation eventKey="2" activePanel={activePanel} callback={setActivePanel} /> |
|
|
|
|
<Accordion.Collapse className='bg-light' eventKey="2"> |
|
|
|
|
<> |
|
|
|
|
<Branches /></> |
|
|
|
|
</Accordion.Collapse> |
|
|
|
|
<hr></hr> |
|
|
|
|
<RemotesNavigation eventKey="5" activePanel={activePanel} callback={setActivePanel} /> |
|
|
|
|
<Accordion.Collapse className='bg-light' eventKey="5"> |
|
|
|
|
<> |
|
|
|
|
<Remotes></Remotes> |
|
|
|
|
</> |
|
|
|
|
</Accordion.Collapse> |
|
|
|
|
<hr></hr> |
|
|
|
|
<CloneNavigation eventKey="4" activePanel={activePanel} callback={setActivePanel} /> |
|
|
|
|
<Accordion.Collapse className='bg-light' eventKey="4"> |
|
|
|
|
<> |
|
|
|
|
<Clone /></> |
|
|
|
|
</Accordion.Collapse> |
|
|
|
|
<hr></hr> |
|
|
|
|
<GitHubNavigation eventKey="7" activePanel={activePanel} callback={setActivePanel} /> |
|
|
|
|
<Accordion.Collapse className='bg-light' eventKey="7"> |
|
|
|
|
<> |
|
|
|
|
<GetDeviceCode></GetDeviceCode> |
|
|
|
|
<hr></hr> |
|
|
|
|
<GitHubCredentials></GitHubCredentials> |
|
|
|
|
</> |
|
|
|
|
</Accordion.Collapse> |
|
|
|
|
<hr></hr> |
|
|
|
|
<LogNavigation eventKey="6" activePanel={activePanel} callback={setActivePanel} /> |
|
|
|
|
<Accordion.Collapse className='bg-light' eventKey="6"> |
|
|
|
|
<> |
|
|
|
|
<LogViewer /> |
|
|
|
|
</> |
|
|
|
|
</Accordion.Collapse> |
|
|
|
|
|
|
|
|
|
</Accordion> |
|
|
|
|
: null} |
|
|
|
|
</pluginActionsContext.Provider> |
|
|
|
|
</gitActionsContext.Provider> |
|
|
|
|
</loaderContext.Provider> |
|
|
|
|