pull/4791/head
filip mertens 6 months ago
parent 5964cfd619
commit 91aaf32ab8
  1. 9
      libs/remix-ui/git/src/components/buttons/commitmessage.tsx
  2. 10
      libs/remix-ui/git/src/components/gitui.tsx
  3. 2
      libs/remix-ui/git/src/components/panels/branches.tsx
  4. 6
      libs/remix-ui/git/src/components/panels/branches/branchdifferences.tsx
  5. 1
      libs/remix-ui/git/src/components/panels/commits.tsx
  6. 2
      libs/remix-ui/git/src/components/panels/commits/commitsummary.tsx
  7. 1
      libs/remix-ui/git/src/components/panels/githubcredentials.tsx
  8. 3
      libs/remix-ui/git/src/components/panels/setup.tsx
  9. 8
      libs/remix-ui/git/src/components/panels/sourcecontrol/sourcontrolitembuttons.tsx
  10. 8
      libs/remix-ui/git/src/lib/gitactions.ts
  11. 49
      libs/remix-ui/git/src/lib/listeners.ts
  12. 1
      libs/remix-ui/git/src/state/gitreducer.tsx
  13. 1
      libs/remix-ui/git/src/types/index.ts
  14. 13
      libs/remix-ui/workspace/src/lib/actions/workspace.ts

@ -93,19 +93,19 @@ export const CommitMessage = () => {
const setButtonStateValues = () => {
console.log('setButtonStateValues', context)
if(!commitNotAllowed() || context.allchangesnotstaged.length > 0 || context.staged.length > 0){
if(context.allchangesnotstaged.length == 0 && context.staged.length == 0 && message.value === "" && publishEnabled()){
if (!commitNotAllowed() || context.allchangesnotstaged.length > 0 || context.staged.length > 0){
if (context.allchangesnotstaged.length == 0 && context.staged.length == 0 && message.value === "" && publishEnabled()){
setButtonState(buttonStateValues.PublishBranch)
return
}
setButtonState(buttonStateValues.Commit)
return
}
if(syncEnabled()){
if (syncEnabled()){
setButtonState(buttonStateValues.Sync)
return
}
if(publishEnabled()){
if (publishEnabled()){
setButtonState(buttonStateValues.PublishBranch)
return
}
@ -116,7 +116,6 @@ export const CommitMessage = () => {
setButtonStateValues()
},[context.canCommit, context.staged, context.allchangesnotstaged, context.currentBranch, syncState.commitsAhead, syncState.commitsBehind, message.value])
return (
<>
<div className="form-group">

@ -50,7 +50,6 @@ export const GitUI = (props: IGitUi) => {
const [needsInit, setNeedsInit] = useState<boolean>(true)
const [appLoaded, setAppLoaded] = useState<boolean>(false)
useEffect(() => {
plugin.emit('statusChanged', {
key:'loading',
@ -63,7 +62,7 @@ export const GitUI = (props: IGitUi) => {
},[])
useEffect(() => {
if(!appLoaded) return
if (!appLoaded) return
setCallBacks(plugin, gitDispatch, loaderDispatch)
setPlugin(plugin, gitDispatch, loaderDispatch)
loaderDispatch({ type: 'plugin', payload: true })
@ -71,7 +70,7 @@ export const GitUI = (props: IGitUi) => {
}, [appLoaded])
useEffect(() => {
if(!appLoaded) return
if (!appLoaded) return
async function checkconfig() {
const username = await plugin.call('settings', 'get', 'settings/github-user-name')
@ -84,7 +83,7 @@ export const GitUI = (props: IGitUi) => {
}, [gitState.gitHubAccessToken, gitState.gitHubUser, gitState.userEmails])
useEffect(() => {
if(!appLoaded) return
if (!appLoaded) return
async function setDecorators(gitState: gitState) {
await plugin.call('fileDecorator', 'clearFileDecorators')
await setModifiedDecorator(gitState.modified)
@ -98,7 +97,7 @@ export const GitUI = (props: IGitUi) => {
}, [gitState.fileStatusResult])
useEffect(() => {
if(!appLoaded) return
if (!appLoaded) return
async function updatestate() {
console.log('updatestate', gitState)
if (gitState.currentBranch && gitState.currentBranch.remote && gitState.currentBranch.remote.url) {
@ -113,7 +112,6 @@ export const GitUI = (props: IGitUi) => {
}, [gitState.gitHubUser, gitState.currentBranch, gitState.remotes, gitState.gitHubAccessToken])
const gitActionsProviderValue = {
commit,
addall,

@ -24,12 +24,10 @@ export const Branches = () => {
}
};
useEffect(() => {
console.log("branches", context.branches)
}, [context.branches])
return (
<>
<div className="pt-1">

@ -26,16 +26,16 @@ export const BranchDifferences = (props: BrancheDetailsProps) => {
}, [context.branchDifferences])
const commitsAhead = (remote: remote) => {
if(!remote) return [];
if (!remote) return [];
return context.branchDifferences[`${remote.name}/${branch.name}`]?.uniqueHeadCommits || [];
}
const commitsBehind = (remote: remote) => {
if(!remote) return [];
if (!remote) return [];
return context.branchDifferences[`${remote.name}/${branch.name}`]?.uniqueRemoteCommits || [];
}
if(!getRemote()) return null;
if (!getRemote()) return null;
return (

@ -40,7 +40,6 @@ export const Commits = () => {
return context.upstream ? context.upstream : context.defaultRemote ? context.defaultRemote : null
}
const getCommitChanges = async (commit: ReadCommitResult) => {
await actions.getCommitChanges(commit.oid, commit.commit.parent[0],null, getRemote())
}

@ -50,7 +50,7 @@ export const CommitSummary = (props: CommitSummaryProps) => {
}
const openRemote = () => {
if(getRemote())
if (getRemote())
window.open(`${getRemote().url}/commit/${commit.oid}`, '_blank');
}

@ -6,7 +6,6 @@ import { CustomTooltip } from "@remix-ui/helper";
import { useIntl, FormattedMessage } from "react-intl";
import { CopyToClipboard } from "@remix-ui/clipboard";
export const GitHubCredentials = () => {
const context = React.useContext(gitPluginContext)
const pluginactions = React.useContext(pluginActionsContext)

@ -6,7 +6,6 @@ export const Setup = () => {
const [screen, setScreen] = useState(0)
if (screen === 0) {
return (
<>
@ -22,7 +21,7 @@ export const Setup = () => {
</div>
</>
)
}else if (screen === 1) {
} else if (screen === 1) {
return (
<>
<h5>SETUP</h5>

@ -23,17 +23,17 @@ export const SourceControlItemButtons = (props: SourceControlItemButtonsProps) =
{status && status.indexOf("modified") === -1 ? <></> : <button onClick={async () => await actions.checkoutfile(file.filename)} className='btn btn-sm btn-secondary mr-1 '><FontAwesomeIcon icon={faUndo} className="" /></button>}
{status && status.indexOf("deleted") === -1 ? <></> : <button onClick={async () => await actions.checkoutfile(file.filename)} className='btn btn-sm btn-secondary mr-1 '><FontAwesomeIcon icon={faUndo} className="" /></button>}
{status && status.indexOf("deleted") !== -1 ? <></> : <button data-id={`unStage${group.name}${path.basename(file.filename)}`} onClick={async () => await actions.rm({filepath:file.filename})} className='btn btn-sm btn-secondary mr-1 '><FontAwesomeIcon icon={faMinus} className="" /></button>}
{status && status.indexOf("deleted") !== -1 ? <></> : <button data-id={`unStage${group.name}${path.basename(file.filename)}`} onClick={async () => await actions.rm({ filepath:file.filename })} className='btn btn-sm btn-secondary mr-1 '><FontAwesomeIcon icon={faMinus} className="" /></button>}
</>
}
if (group.name === 'Changes') {
return <>
{status && status.indexOf("deleted") === -1 ? <></> : <><button onClick={async () => await actions.checkoutfile(file.filename)} data-id={`undo${group.name}${path.basename(file.filename)}`} className='btn btn-sm btn-secondary mr-1 '><FontAwesomeIcon icon={faUndo} className="" /></button><button data-id={`addToGit${group.name}${path.basename(file.filename)}`} onClick={async () => await actions.rm({filepath:file.filename})} className='btn btn-sm btn-secondary mr-1 '><FontAwesomeIcon icon={faPlus} className="" /></button></>}
{status && status.indexOf("deleted") === -1 ? <></> : <><button onClick={async () => await actions.checkoutfile(file.filename)} data-id={`undo${group.name}${path.basename(file.filename)}`} className='btn btn-sm btn-secondary mr-1 '><FontAwesomeIcon icon={faUndo} className="" /></button><button data-id={`addToGit${group.name}${path.basename(file.filename)}`} onClick={async () => await actions.rm({ filepath:file.filename })} className='btn btn-sm btn-secondary mr-1 '><FontAwesomeIcon icon={faPlus} className="" /></button></>}
{status && status.indexOf("modified") === -1 ? <></> : <button onClick={async () => await actions.checkoutfile(file.filename)} data-id={`undo${group.name}${path.basename(file.filename)}`} className='btn btn-sm btn-secondary mr-1 '><FontAwesomeIcon icon={faUndo} className="" /></button>}
{(status && status.indexOf("unstaged") !== -1 || status && status.indexOf("deleted") !== -1) ? <></> : <button data-id={`addToGit${group.name}${path.basename(file.filename)}`} onClick={async () => await actions.add({filepath:file.filename})} className='btn btn-sm btn-secondary mr-1 '><FontAwesomeIcon icon={faPlus} className="" /></button>}
{(status && status.indexOf("unstaged") !== -1 && status && status.indexOf("modified") !== -1) ? <button data-id={`addToGit${group.name}${path.basename(file.filename)}`} onClick={async () => await actions.add({filepath:file.filename})} className='btn btn-sm btn-secondary mr-1 '><FontAwesomeIcon icon={faPlus} className="" /></button> : <></>}
{(status && status.indexOf("unstaged") !== -1 || status && status.indexOf("deleted") !== -1) ? <></> : <button data-id={`addToGit${group.name}${path.basename(file.filename)}`} onClick={async () => await actions.add({ filepath:file.filename })} className='btn btn-sm btn-secondary mr-1 '><FontAwesomeIcon icon={faPlus} className="" /></button>}
{(status && status.indexOf("unstaged") !== -1 && status && status.indexOf("modified") !== -1) ? <button data-id={`addToGit${group.name}${path.basename(file.filename)}`} onClick={async () => await actions.add({ filepath:file.filename })} className='btn btn-sm btn-secondary mr-1 '><FontAwesomeIcon icon={faPlus} className="" /></button> : <></>}
</>
}
return <></>

@ -128,7 +128,7 @@ export const showCurrentBranch = async () => {
}
export const currentBranch = async () => {
try {
const branch: branch =
(await plugin.call('dgitApi', "currentbranch")) || {
name: "",
@ -138,9 +138,7 @@ export const currentBranch = async () => {
},
};
return branch;
} catch (e) {
throw e;
}
}
export const createBranch = async (name: string = "") => {
@ -595,7 +593,7 @@ export const loadGitHubUserFromToken = async () => {
}
export const statusMatrix = async (filepaths: string[]) => {
const matrix = await plugin.call('dgitApi', 'status', { ref: "HEAD", filepaths: filepaths || ['.'] });
const matrix = await plugin.call('dgitApi', 'status', { ref: "HEAD", filepaths: filepaths || ['.']});
const result = (matrix || []).map((x) => {
return {
filename: `/${x.shift()}`,

@ -25,7 +25,7 @@ class AsyncDebouncedQueue {
clearTimeout(this.queues.get(callback)!.timer);
}
let timer = setTimeout(async () => {
const timer = setTimeout(async () => {
await callback();
this.queues.delete(callback);
}, customDelay || this.delay);
@ -34,8 +34,6 @@ class AsyncDebouncedQueue {
}
}
export const setCallBacks = (viewPlugin: Plugin, gitDispatcher: React.Dispatch<gitActionDispatch>, loaderDispatcher: React.Dispatch<any>) => {
plugin = viewPlugin
gitDispatch = gitDispatcher
@ -172,42 +170,13 @@ export const getGitConfig = async () => {
}
const syncFromWorkspace = async (callback: Function, isLocalhost = false) => {
//gitDispatch(setLoading(true));
await disableCallBacks();
if (isLocalhost) {
gitDispatch(setCanUseApp(false));
gitDispatch(setLoading(false));
await enableCallBacks();
return;
}
try {
const workspace = await plugin.call(
"filePanel",
"getCurrentWorkspace"
);
if (workspace.isLocalhost) {
gitDispatch(setCanUseApp(false));
await enableCallBacks();
return
}
gitDispatch(setRepoName(workspace.name));
gitDispatch(setCanUseApp(true));
} catch (e) {
gitDispatch(setCanUseApp(false));
}
await callback();
await enableCallBacks();
}
export const loadFiles = async (filepaths: string[] = null) => {
try {
const branch = await plugin.call('dgitApi', "currentbranch")
console.log('load files', branch)
if(branch) {
if (branch) {
await getFileStatusMatrix(filepaths);
}else{
} else {
await plugin.call('fileDecorator', 'clearFileDecorators')
statusChanged(0)
}
@ -217,18 +186,6 @@ export const loadFiles = async (filepaths: string[] = null) => {
}
}
const getStorageUsed = async () => {
try {
const storageUsed = await plugin.call("storage" as any, "getStorage" as any);
} catch (e) {
const storage: string = await plugin.call('dgitApi', "localStorageUsed" as any);
const storageUsed = {
usage: parseFloat(storage) * 1000,
quota: 10000000,
};
}
}
export const disableCallBacks = async () => {
callBackEnabled = false;
}

@ -182,7 +182,6 @@ export const gitReducer = (state: gitState = defaultGitState, action: Actions):
userEmails: action.payload
}
case 'SET_DEFAULT_REMOTE':
return {
...state,

@ -146,7 +146,6 @@ export const dGitProfile: LibraryProfile<IGitApi> = {
methods: ['clone', 'branches', 'remotes', 'getCommitChanges', 'log', 'remotecommits'],
}
export interface customGitApi extends IRemixApi {
dgit: IGitApi
}

@ -204,11 +204,7 @@ export const createWorkspace = async (
}, 5000)
} else if (!isEmpty && !(isGitRepo && createCommit)) await loadWorkspacePreset(workspaceTemplateName, opts)
cb && cb(null, workspaceName)
if (isGitRepo && false) {
await checkGit()
const isActive = await plugin.call('manager', 'isActive', 'dgit')
if (!isActive) await plugin.call('manager', 'activatePlugin', 'dgit')
}
if (workspaceTemplateName === 'semaphore' || workspaceTemplateName === 'hashchecker' || workspaceTemplateName === 'rln') {
const isCircomActive = await plugin.call('manager', 'isActive', 'circuit-compiler')
if (!isCircomActive) await plugin.call('manager', 'activatePlugin', 'circuit-compiler')
@ -513,10 +509,7 @@ export const switchToWorkspace = async (name: string) => {
await plugin.fileProviders.workspace.setWorkspace(name)
await plugin.setWorkspace({ name, isLocalhost: false })
const isGitRepo = await plugin.fileManager.isGitRepo()
if (isGitRepo && false) {
const isActive = await plugin.call('manager', 'isActive', 'dgit')
if (!isActive) await plugin.call('manager', 'activatePlugin', 'dgit')
}
dispatch(setMode('browser'))
dispatch(setCurrentWorkspace({ name, isGitRepo }))
dispatch(setReadOnlyMode(false))
@ -669,7 +662,7 @@ export const cloneRepository = async (url: string) => {
const repoName = await getRepositoryTitle(url)
await createWorkspace(repoName, 'blank', null, true, null, true, false)
const promise = dgitPlugin.call('dgitApi', 'clone', {...repoConfig, workspaceExists: true, workspaceName: repoName})
const promise = dgitPlugin.call('dgitApi', 'clone', { ...repoConfig, workspaceExists: true, workspaceName: repoName })
dispatch(cloneRepositoryRequest())
promise

Loading…
Cancel
Save