|
|
@ -1,5 +1,5 @@ |
|
|
|
import React, { useEffect, useReducer, useState } from 'react' |
|
|
|
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 { loadFiles, setCallBacks } from '../lib/listeners' |
|
|
|
import { openDiff, openFile, saveToken, setModifiedDecorator, setPlugin, setUntrackedDecorator, statusChanged } from '../lib/pluginActions' |
|
|
|
import { openDiff, openFile, saveToken, setModifiedDecorator, setPlugin, setUntrackedDecorator, statusChanged } from '../lib/pluginActions' |
|
|
|
import { gitActionsContext, pluginActionsContext } from '../state/context' |
|
|
|
import { gitActionsContext, pluginActionsContext } from '../state/context' |
|
|
@ -30,12 +30,15 @@ import { BranchHeader } from './branchHeader' |
|
|
|
import { SourceControl } from './panels/sourcontrol' |
|
|
|
import { SourceControl } from './panels/sourcontrol' |
|
|
|
import { GitHubCredentials } from './panels/githubcredentials' |
|
|
|
import { GitHubCredentials } from './panels/githubcredentials' |
|
|
|
import { Setup } from './panels/setup' |
|
|
|
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 gitPluginContext = React.createContext<gitState>(defaultGitState) |
|
|
|
export const loaderContext = React.createContext<loaderState>(defaultLoaderState) |
|
|
|
export const loaderContext = React.createContext<loaderState>(defaultLoaderState) |
|
|
|
|
|
|
|
|
|
|
|
interface IGitUi { |
|
|
|
interface IGitUi { |
|
|
|
plugin: ViewPlugin |
|
|
|
plugin: Plugin<any, CustomRemixApi> |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export const GitUI = (props: IGitUi) => { |
|
|
|
export const GitUI = (props: IGitUi) => { |
|
|
@ -44,6 +47,7 @@ export const GitUI = (props: IGitUi) => { |
|
|
|
const [loaderState, loaderDispatch] = useReducer(loaderReducer, defaultLoaderState) |
|
|
|
const [loaderState, loaderDispatch] = useReducer(loaderReducer, defaultLoaderState) |
|
|
|
const [activePanel, setActivePanel] = useState<string>("0") |
|
|
|
const [activePanel, setActivePanel] = useState<string>("0") |
|
|
|
const [setup, setSetup] = useState<boolean>(false) |
|
|
|
const [setup, setSetup] = useState<boolean>(false) |
|
|
|
|
|
|
|
const [needsInit, setNeedsInit] = useState<boolean>(true) |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
|
setCallBacks(plugin, gitDispatch, loaderDispatch) |
|
|
|
setCallBacks(plugin, gitDispatch, loaderDispatch) |
|
|
@ -62,7 +66,7 @@ export const GitUI = (props: IGitUi) => { |
|
|
|
setSetup(!(username && email)) |
|
|
|
setSetup(!(username && email)) |
|
|
|
} |
|
|
|
} |
|
|
|
checkconfig() |
|
|
|
checkconfig() |
|
|
|
},[gitState.gitHubAccessToken, gitState.gitHubUser, gitState.userEmails]) |
|
|
|
}, [gitState.gitHubAccessToken, gitState.gitHubUser, gitState.userEmails]) |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
|
|
|
|
|
|
|
|
@ -90,6 +94,8 @@ export const GitUI = (props: IGitUi) => { |
|
|
|
updatestate() |
|
|
|
updatestate() |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setNeedsInit(!(gitState.currentBranch && gitState.currentBranch.name !== '')) |
|
|
|
|
|
|
|
|
|
|
|
}, [gitState.gitHubUser, gitState.currentBranch, gitState.remotes, gitState.gitHubAccessToken]) |
|
|
|
}, [gitState.gitHubUser, gitState.currentBranch, gitState.remotes, gitState.gitHubAccessToken]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -121,7 +127,8 @@ export const GitUI = (props: IGitUi) => { |
|
|
|
removeRemote, |
|
|
|
removeRemote, |
|
|
|
sendToGitLog, |
|
|
|
sendToGitLog, |
|
|
|
clearGitLog, |
|
|
|
clearGitLog, |
|
|
|
getFileStatusMatrix |
|
|
|
getFileStatusMatrix, |
|
|
|
|
|
|
|
init |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const pluginActionsProviderValue = { |
|
|
|
const pluginActionsProviderValue = { |
|
|
@ -139,16 +146,18 @@ export const GitUI = (props: IGitUi) => { |
|
|
|
<gitPluginContext.Provider value={gitState}> |
|
|
|
<gitPluginContext.Provider value={gitState}> |
|
|
|
<loaderContext.Provider value={loaderState}> |
|
|
|
<loaderContext.Provider value={loaderState}> |
|
|
|
<gitActionsContext.Provider value={gitActionsProviderValue}> |
|
|
|
<gitActionsContext.Provider value={gitActionsProviderValue}> |
|
|
|
<BranchHeader/> |
|
|
|
<BranchHeader /> |
|
|
|
<pluginActionsContext.Provider value={pluginActionsProviderValue}> |
|
|
|
<pluginActionsContext.Provider value={pluginActionsProviderValue}> |
|
|
|
{setup? <Setup></Setup>: null} |
|
|
|
{setup && !needsInit ? <Setup></Setup> : null} |
|
|
|
|
|
|
|
{needsInit ? <Init></Init> : null} |
|
|
|
|
|
|
|
{!setup && !needsInit ? |
|
|
|
<Accordion activeKey={activePanel} defaultActiveKey="0"> |
|
|
|
<Accordion activeKey={activePanel} defaultActiveKey="0"> |
|
|
|
<SourceControlNavigation eventKey="0" activePanel={activePanel} callback={setActivePanel} /> |
|
|
|
<SourceControlNavigation eventKey="0" activePanel={activePanel} callback={setActivePanel} /> |
|
|
|
|
|
|
|
|
|
|
|
<Accordion.Collapse className='bg-light' eventKey="0"> |
|
|
|
<Accordion.Collapse className='bg-light' eventKey="0"> |
|
|
|
<> |
|
|
|
<> |
|
|
|
<SourceControlBase><CommitMessage/></SourceControlBase> |
|
|
|
<SourceControlBase><CommitMessage /></SourceControlBase> |
|
|
|
<SourceControl/> |
|
|
|
<SourceControl /> |
|
|
|
</> |
|
|
|
</> |
|
|
|
</Accordion.Collapse> |
|
|
|
</Accordion.Collapse> |
|
|
|
<hr></hr> |
|
|
|
<hr></hr> |
|
|
@ -169,7 +178,7 @@ export const GitUI = (props: IGitUi) => { |
|
|
|
<BranchesNavigation eventKey="2" activePanel={activePanel} callback={setActivePanel} /> |
|
|
|
<BranchesNavigation eventKey="2" activePanel={activePanel} callback={setActivePanel} /> |
|
|
|
<Accordion.Collapse className='bg-light' eventKey="2"> |
|
|
|
<Accordion.Collapse className='bg-light' eventKey="2"> |
|
|
|
<> |
|
|
|
<> |
|
|
|
<Branches/></> |
|
|
|
<Branches /></> |
|
|
|
</Accordion.Collapse> |
|
|
|
</Accordion.Collapse> |
|
|
|
<hr></hr> |
|
|
|
<hr></hr> |
|
|
|
<RemotesNavigation eventKey="5" activePanel={activePanel} callback={setActivePanel} /> |
|
|
|
<RemotesNavigation eventKey="5" activePanel={activePanel} callback={setActivePanel} /> |
|
|
@ -197,12 +206,12 @@ export const GitUI = (props: IGitUi) => { |
|
|
|
<LogNavigation eventKey="6" activePanel={activePanel} callback={setActivePanel} /> |
|
|
|
<LogNavigation eventKey="6" activePanel={activePanel} callback={setActivePanel} /> |
|
|
|
<Accordion.Collapse className='bg-light' eventKey="6"> |
|
|
|
<Accordion.Collapse className='bg-light' eventKey="6"> |
|
|
|
<> |
|
|
|
<> |
|
|
|
<LogViewer/> |
|
|
|
<LogViewer /> |
|
|
|
</> |
|
|
|
</> |
|
|
|
</Accordion.Collapse> |
|
|
|
</Accordion.Collapse> |
|
|
|
|
|
|
|
|
|
|
|
</Accordion> |
|
|
|
</Accordion> |
|
|
|
|
|
|
|
: null} |
|
|
|
</pluginActionsContext.Provider> |
|
|
|
</pluginActionsContext.Provider> |
|
|
|
</gitActionsContext.Provider> |
|
|
|
</gitActionsContext.Provider> |
|
|
|
</loaderContext.Provider> |
|
|
|
</loaderContext.Provider> |
|
|
|