rename button

pull/5370/head
Your Name 7 months ago
parent c6b1154fe1
commit 5327e37318
  1. 2
      libs/remix-ui/git/src/components/disabled.tsx
  2. 122
      libs/remix-ui/git/src/components/gitui.tsx
  3. 12
      libs/remix-ui/git/src/components/panels/version.tsx
  4. 417
      libs/remix-ui/git/src/state/gitreducer.tsx

@ -19,7 +19,7 @@ export const Disabled = () => {
(platform === appPlatformTypes.desktop) ? (platform === appPlatformTypes.desktop) ?
<div className='p-1'> <div className='p-1'>
<div><FormattedMessage id="gitui.openFolderMessage"/></div> <div><FormattedMessage id="gitui.openFolderMessage"/></div>
<div data-id="openFolderButton" onClick={async () => { await openFolderElectron(null) }} className='btn btn-primary w-100 my-1'><FormattedMessage id="electron.openFolder" /></div> <div data-id="openFolderButtonInDisabled" onClick={async () => { await openFolderElectron(null) }} className='btn btn-primary w-100 my-1'><FormattedMessage id="electron.openFolder" /></div>
<div data-id="cloneButton" onClick={async () => { await clone() }} className='btn btn-primary w-100'><FormattedMessage id="electron.gitClone" /></div> <div data-id="cloneButton" onClick={async () => { await clone() }} className='btn btn-primary w-100'><FormattedMessage id="electron.gitClone" /></div>
</div> </div>
: :

@ -181,67 +181,67 @@ export const GitUI = (props: IGitUi) => {
{needsInit ? <Init></Init> : null} {needsInit ? <Init></Init> : null}
{!setup && !needsInit ? {!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>
<CommandsNavigation eventKey="1" activePanel={activePanel} callback={setActivePanel} /> <CommandsNavigation eventKey="1" activePanel={activePanel} callback={setActivePanel} />
<Accordion.Collapse className='bg-light' eventKey="1"> <Accordion.Collapse className='bg-light' eventKey="1">
<> <>
<Commands></Commands> <Commands></Commands>
</> </>
</Accordion.Collapse> </Accordion.Collapse>
<hr></hr> <hr></hr>
<CommitsNavigation title={`COMMITS`} eventKey="3" activePanel={activePanel} callback={setActivePanel} showButtons={true} /> <CommitsNavigation title={`COMMITS`} eventKey="3" activePanel={activePanel} callback={setActivePanel} showButtons={true} />
<Accordion.Collapse className='bg-light' eventKey="3"> <Accordion.Collapse className='bg-light' eventKey="3">
<> <>
<Commits /> <Commits />
</> </>
</Accordion.Collapse> </Accordion.Collapse>
<hr></hr> <hr></hr>
<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} />
<Accordion.Collapse className='bg-light' eventKey="5"> <Accordion.Collapse className='bg-light' eventKey="5">
<> <>
<Remotes></Remotes> <Remotes></Remotes>
</> </>
</Accordion.Collapse> </Accordion.Collapse>
<hr></hr> <hr></hr>
<CloneNavigation eventKey="4" activePanel={activePanel} callback={setActivePanel} /> <CloneNavigation eventKey="4" activePanel={activePanel} callback={setActivePanel} />
<Accordion.Collapse className='bg-light' eventKey="4"> <Accordion.Collapse className='bg-light' eventKey="4">
<> <>
<Clone /></> <Clone /></>
</Accordion.Collapse> </Accordion.Collapse>
<hr></hr> <hr></hr>
<GitHubNavigation eventKey="7" activePanel={activePanel} callback={setActivePanel} /> <GitHubNavigation eventKey="7" activePanel={activePanel} callback={setActivePanel} />
<Accordion.Collapse className='bg-light' eventKey="7"> <Accordion.Collapse className='bg-light' eventKey="7">
<> <>
<GetDeviceCode></GetDeviceCode> <GetDeviceCode></GetDeviceCode>
<hr></hr> <hr></hr>
<GitHubCredentials></GitHubCredentials> <GitHubCredentials></GitHubCredentials>
</> </>
</Accordion.Collapse> </Accordion.Collapse>
<hr></hr> <hr></hr>
<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>
<Version/></> <Version/></>
: null} : null}
</pluginActionsContext.Provider> </pluginActionsContext.Provider>
</gitActionsContext.Provider> </gitActionsContext.Provider>

@ -1,10 +1,10 @@
import React, { useEffect, useState } from 'react' import React, { useEffect, useState } from 'react'
import { gitPluginContext } from '../gitui' import { gitPluginContext } from '../gitui'
export const Version = () => { export const Version = () => {
const context = React.useContext(gitPluginContext) const context = React.useContext(gitPluginContext)
return ( return (
<div> <div>
<p>{context.version.includes('version') ? context.version : `Git version: ${context.version}` }</p> <p>{context.version.includes('version') ? context.version : `Git version: ${context.version}` }</p>
</div> </div>
) )
} }

@ -6,216 +6,215 @@ import { Actions } from "./actions"
export const gitReducer = (state: gitState = defaultGitState, action: Actions): gitState => { export const gitReducer = (state: gitState = defaultGitState, action: Actions): gitState => {
switch (action.type) { switch (action.type) {
case 'FILE_STATUS': case 'FILE_STATUS':
return { return {
...state, ...state,
fileStatusResult: action.payload, fileStatusResult: action.payload,
staged: getFilesByStatus("staged", action.payload), staged: getFilesByStatus("staged", action.payload),
modified: getFilesByStatus("modified", action.payload), modified: getFilesByStatus("modified", action.payload),
untracked: getFilesByStatus("untracked", action.payload), untracked: getFilesByStatus("untracked", action.payload),
deleted: getFilesByStatus("deleted", action.payload), deleted: getFilesByStatus("deleted", action.payload),
allchangesnotstaged: allChangedButNotStagedFiles(action.payload) allchangesnotstaged: allChangedButNotStagedFiles(action.payload)
} }
case 'FILE_STATUS_MERGE': case 'FILE_STATUS_MERGE':
action.payload.map((fileStatusResult: fileStatusResult) => { action.payload.map((fileStatusResult: fileStatusResult) => {
const file = state.fileStatusResult.find(stateFile => { const file = state.fileStatusResult.find(stateFile => {
return stateFile.filename === fileStatusResult.filename return stateFile.filename === fileStatusResult.filename
})
if (file) {
file.status = fileStatusResult.status
file.statusNames = fileStatusResult.statusNames
}
})
return {
...state,
staged: getFilesByStatus("staged", state.fileStatusResult),
modified: getFilesByStatus("modified", state.fileStatusResult),
untracked: getFilesByStatus("untracked", state.fileStatusResult),
deleted: getFilesByStatus("deleted", state.fileStatusResult),
allchangesnotstaged: allChangedButNotStagedFiles(state.fileStatusResult)
}
case 'SET_COMMITS':
return {
...state,
commits: action.payload,
localCommitCount: action.payload.length
}
case 'SET_BRANCHES':
return {
...state,
branches: action.payload
}
case 'SET_CURRENT_BRANCH':
return {
...state,
currentBranch: action.payload
}
case 'SET_CURRENT_HEAD':
return {
...state,
currentHead: action.payload
}
case 'SET_CAN_USE_APP':
return {
...state,
canUseApp: action.payload
}
case 'SET_REPO_NAME':
return {
...state,
reponame: action.payload
}
case 'SET_LOADING':
return {
...state,
loading: action.payload
}
case 'SET_REPOS':
return {
...state,
repositories: action.payload
}
case 'SET_REMOTE_BRANCHES':
return {
...state,
remoteBranches: action.payload
}
case 'SET_CAN_COMMIT':
return {
...state,
canCommit: action.payload
}
case 'SET_REMOTES':
return {
...state,
remotes: action.payload
}
case 'SET_UPSTREAM':
return {
...state,
upstream: action.payload
}
case 'SET_COMMIT_CHANGES':
action.payload.forEach((change: commitChange) => {
state.commitChanges.find((c) => c.hashModified === change.hashModified && c.hashOriginal === change.hashOriginal && c.path === change.path) ? null : state.commitChanges.push(change)
}) })
if (file) {
return { file.status = fileStatusResult.status
...state, file.statusNames = fileStatusResult.statusNames
commitChanges: [...state.commitChanges] }
} })
case 'RESET_REMOTE_BRANCH_COMMITS': return {
if (state.remoteBranchCommits[action.payload.branch.name]) { ...state,
delete state.remoteBranchCommits[action.payload.branch.name] staged: getFilesByStatus("staged", state.fileStatusResult),
} modified: getFilesByStatus("modified", state.fileStatusResult),
return { untracked: getFilesByStatus("untracked", state.fileStatusResult),
...state, deleted: getFilesByStatus("deleted", state.fileStatusResult),
remoteBranchCommits: { ...state.remoteBranchCommits } allchangesnotstaged: allChangedButNotStagedFiles(state.fileStatusResult)
} }
case 'SET_REMOTE_BRANCH_COMMITS': case 'SET_COMMITS':
if (state.remoteBranchCommits[action.payload.branch.name]) { return {
state.remoteBranchCommits[action.payload.branch.name].push(...action.payload.commits) ...state,
} else { commits: action.payload,
state.remoteBranchCommits[action.payload.branch.name] = action.payload.commits localCommitCount: action.payload.length
} }
return {
...state, case 'SET_BRANCHES':
remoteBranchCommits: { ...state.remoteBranchCommits } return {
} ...state,
branches: action.payload
case 'SET_LOCAL_BRANCH_COMMITS': }
state.localBranchCommits[action.payload.branch.name] = action.payload.commits case 'SET_CURRENT_BRANCH':
return { return {
...state, ...state,
localBranchCommits: { ...state.localBranchCommits } currentBranch: action.payload
} }
case 'SET_BRANCH_DIFFERENCES': case 'SET_CURRENT_HEAD':
return {
state.branchDifferences[`${action.payload.remote.name}/${action.payload.branch.name}`] = action.payload.branchDifference ...state,
currentHead: action.payload
return { }
...state,
branchDifferences: { ...state.branchDifferences } case 'SET_CAN_USE_APP':
} return {
...state,
case 'SET_GITHUB_USER': canUseApp: action.payload
return { }
...state, case 'SET_REPO_NAME':
gitHubUser: action.payload return {
} ...state,
reponame: action.payload
case 'SET_GITHUB_ACCESS_TOKEN': }
return { case 'SET_LOADING':
...state, return {
gitHubAccessToken: action.payload ...state,
} loading: action.payload
}
case 'SET_SCOPES':
return { case 'SET_REPOS':
...state, return {
gitHubScopes: action.payload ...state,
} repositories: action.payload
}
case 'SET_USER_EMAILS':
return { case 'SET_REMOTE_BRANCHES':
...state, return {
userEmails: action.payload ...state,
} remoteBranches: action.payload
}
case 'SET_DEFAULT_REMOTE':
return { case 'SET_CAN_COMMIT':
...state, return {
defaultRemote: action.payload ...state,
} canCommit: action.payload
}
case 'SET_LOG':
if (state.log.length > 0 && state.log[[...state.log].length - 1].message === action.payload.message) { case 'SET_REMOTES':
return { return {
...state, ...state,
log: [...state.log] remotes: action.payload
} }
}
return { case 'SET_UPSTREAM':
...state, return {
log: [...state.log, action.payload] ...state,
} upstream: action.payload
}
case 'CLEAR_LOG':
return { case 'SET_COMMIT_CHANGES':
...state,
log: [] action.payload.forEach((change: commitChange) => {
} state.commitChanges.find((c) => c.hashModified === change.hashModified && c.hashOriginal === change.hashOriginal && c.path === change.path) ? null : state.commitChanges.push(change)
})
case 'DESKTOP_SET_WORKING_DIR':
return { return {
...state, ...state,
desktopWorkingDir: action.payload commitChanges: [...state.commitChanges]
} }
case 'RESET_REMOTE_BRANCH_COMMITS':
case 'SET_VERSION': if (state.remoteBranchCommits[action.payload.branch.name]) {
return { delete state.remoteBranchCommits[action.payload.branch.name]
...state, }
version: action.payload return {
} ...state,
remoteBranchCommits: { ...state.remoteBranchCommits }
}
case 'SET_REMOTE_BRANCH_COMMITS':
if (state.remoteBranchCommits[action.payload.branch.name]) {
state.remoteBranchCommits[action.payload.branch.name].push(...action.payload.commits)
} else {
state.remoteBranchCommits[action.payload.branch.name] = action.payload.commits
}
return {
...state,
remoteBranchCommits: { ...state.remoteBranchCommits }
}
case 'SET_LOCAL_BRANCH_COMMITS':
state.localBranchCommits[action.payload.branch.name] = action.payload.commits
return {
...state,
localBranchCommits: { ...state.localBranchCommits }
}
case 'SET_BRANCH_DIFFERENCES':
state.branchDifferences[`${action.payload.remote.name}/${action.payload.branch.name}`] = action.payload.branchDifference
return {
...state,
branchDifferences: { ...state.branchDifferences }
}
case 'SET_GITHUB_USER':
return {
...state,
gitHubUser: action.payload
}
case 'SET_GITHUB_ACCESS_TOKEN':
return {
...state,
gitHubAccessToken: action.payload
}
case 'SET_SCOPES':
return {
...state,
gitHubScopes: action.payload
}
case 'SET_USER_EMAILS':
return {
...state,
userEmails: action.payload
}
case 'SET_DEFAULT_REMOTE':
return {
...state,
defaultRemote: action.payload
}
case 'SET_LOG':
if (state.log.length > 0 && state.log[[...state.log].length - 1].message === action.payload.message) {
return {
...state,
log: [...state.log]
}
}
return {
...state,
log: [...state.log, action.payload]
}
case 'CLEAR_LOG':
return {
...state,
log: []
}
case 'DESKTOP_SET_WORKING_DIR':
return {
...state,
desktopWorkingDir: action.payload
}
case 'SET_VERSION':
return {
...state,
version: action.payload
}
} }
} }
Loading…
Cancel
Save