pull/4791/head
Your Name 5 months ago
parent 36a16b812a
commit ef2014c3e6
  1. 43
      apps/remix-ide-e2e/src/tests/dgit_local.test.ts
  2. 2
      libs/remix-ui/git/src/components/navigation/sourcecontrolgroup.tsx
  3. 4
      libs/remix-ui/git/src/components/panels/sourcecontrol/sourcecontrolitem.tsx
  4. 41
      libs/remix-ui/git/src/components/panels/sourcecontrol/sourcontrolitembuttons.tsx
  5. 14
      libs/remix-ui/git/src/lib/gitactions.ts

@ -8,6 +8,7 @@ let gitserver: ChildProcess
/ uses the git-http-backend package to create a git server ( if needed kill the server: kill -9 $(sudo lsof -t -i:6868) ) / uses the git-http-backend package to create a git server ( if needed kill the server: kill -9 $(sudo lsof -t -i:6868) )
/ GROUP 1: file operations PUSH PULL COMMIT SYNC FETCH CLONE ADD / GROUP 1: file operations PUSH PULL COMMIT SYNC FETCH CLONE ADD
/ GROUP 2: branch operations CREATE & PUBLISH / GROUP 2: branch operations CREATE & PUBLISH
/ GROUP 3: file operations rename delete
*/ */
module.exports = { module.exports = {
@ -23,14 +24,14 @@ module.exports = {
}) })
}, },
'run server #group1 #group2': function (browser: NightwatchBrowser) { 'run server #group1 #group2 #group3': function (browser: NightwatchBrowser) {
browser.perform(async (done) => { browser.perform(async (done) => {
gitserver = await spawnGitServer('/tmp/') gitserver = await spawnGitServer('/tmp/')
console.log('working directory', process.cwd()) console.log('working directory', process.cwd())
done() done()
}) })
}, },
'Update settings for git #group1 #group2': function (browser: NightwatchBrowser) { 'Update settings for git #group1 #group2 #group3': function (browser: NightwatchBrowser) {
browser. browser.
clickLaunchIcon('dgit') clickLaunchIcon('dgit')
.waitForElementVisible('*[data-id="initgit-btn"]') .waitForElementVisible('*[data-id="initgit-btn"]')
@ -41,7 +42,7 @@ module.exports = {
.modalFooterOKClick('github-credentials-error') .modalFooterOKClick('github-credentials-error')
.pause(2000) .pause(2000)
}, },
'clone a repo #group1 #group2': function (browser: NightwatchBrowser) { 'clone a repo #group1 #group2 #group3': function (browser: NightwatchBrowser) {
browser browser
.waitForElementVisible('*[data-id="clone-panel"]') .waitForElementVisible('*[data-id="clone-panel"]')
.click('*[data-id="clone-panel"]') .click('*[data-id="clone-panel"]')
@ -55,7 +56,7 @@ module.exports = {
// GROUP 1 // GROUP 1
'check file added #group1': function (browser: NightwatchBrowser) { 'check file added #group1 #group3': function (browser: NightwatchBrowser) {
browser. browser.
addFile('test.txt', { content: 'hello world' }, 'README.md') addFile('test.txt', { content: 'hello world' }, 'README.md')
.clickLaunchIcon('dgit') .clickLaunchIcon('dgit')
@ -172,6 +173,40 @@ module.exports = {
.clickLaunchIcon('filePanel') .clickLaunchIcon('filePanel')
.waitForElementVisible('*[data-id="treeViewLitreeViewItemtest2.txt"]') .waitForElementVisible('*[data-id="treeViewLitreeViewItemtest2.txt"]')
}, },
// group 3
'rename a file #group3': function (browser: NightwatchBrowser) {
browser
.clickLaunchIcon('filePanel')
.waitForElementVisible('*[data-id="treeViewLitreeViewItemtest.txt"]')
.click('*[data-id="treeViewLitreeViewItemtest.txt"]')
.renamePath('test.txt', 'test_rename', 'test_rename.txt')
.waitForElementVisible('*[data-id="treeViewLitreeViewItemtest_rename.txt"]')
.pause(1000)
},
'stage renamed file #group3': function (browser: NightwatchBrowser) {
browser
.clickLaunchIcon('dgit')
.waitForElementVisible({
selector: "//*[@data-status='deleted-unstaged' and @data-file='/test.txt']",
locateStrategy: 'xpath'
})
.waitForElementVisible('*[data-id="addToGitChangestest.txt"]')
.waitForElementVisible({
selector: "//*[@data-status='new-untracked' and @data-file='/test_rename.txt']",
locateStrategy: 'xpath'
})
.click('*[data-id="sourcecontrol-add-all"]')
.waitForElementVisible({
selector: "//*[@data-status='deleted-staged' and @data-file='/test.txt']",
locateStrategy: 'xpath'
})
.waitForElementVisible({
selector: "//*[@data-status='added-staged' and @data-file='/test_rename.txt']",
locateStrategy: 'xpath'
})
},
// GROUP 2 // GROUP 2
'create a branch #group2': function (browser: NightwatchBrowser) { 'create a branch #group2': function (browser: NightwatchBrowser) {
browser browser

@ -41,7 +41,7 @@ export const SourceControlGroupNavigation = (props: SourceControlGroupNavigation
<span className='d-flex justify-content-end align-items-center w-25'> <span className='d-flex justify-content-end align-items-center w-25'>
{group.name === 'Changes' ? {group.name === 'Changes' ?
<CustomTooltip tooltipText={<FormattedMessage id="git.stageall" />}> <CustomTooltip tooltipText={<FormattedMessage id="git.stageall" />}>
<button onClick={async () => { await actions.addall(context.allchangesnotstaged) }} className='btn btn-sm'><FontAwesomeIcon icon={faPlus} className="" /></button> <button data-id='sourcecontrol-add-all' onClick={async () => { await actions.addall(context.allchangesnotstaged) }} className='btn btn-sm'><FontAwesomeIcon icon={faPlus} className="" /></button>
</CustomTooltip>: null} </CustomTooltip>: null}
</span> : null </span> : null

@ -46,8 +46,10 @@ export const SourceControlItem = (props: SourceControlItemProps) => {
{status && status.indexOf("added") === -1 ? <></> : <span>A</span>} {status && status.indexOf("added") === -1 ? <></> : <span>A</span>}
{status && status.indexOf("untracked") === -1 ? <></> : <span>U</span>} {status && status.indexOf("untracked") === -1 ? <></> : <span>U</span>}
</>) </>)
} }
if(!file.statusNames || file.statusNames.length === 0) return null
return (<> return (<>
<div data-status={file.statusNames.join('-')} data-file={file.filename} className="d-flex w-100 d-flex flex-row align-items-center"> <div data-status={file.statusNames.join('-')} data-file={file.filename} className="d-flex w-100 d-flex flex-row align-items-center">
<div className='pointer gitfile long-and-truncated' onClick={async () => await fileClick(file)}> <div className='pointer gitfile long-and-truncated' onClick={async () => await fileClick(file)}>

@ -21,19 +21,46 @@ export const SourceControlItemButtons = (props: SourceControlItemButtonsProps) =
if (group.name === 'Staged') { if (group.name === 'Staged') {
return <> return <>
{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("modified") === -1 ? <></> :
{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>} <button onClick={async () => await actions.checkoutfile(file.filename)} className='btn btn-sm btn-secondary mr-1 '>
{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>} <FontAwesomeIcon icon={faUndo} className="" /></button>
}
{status && status.indexOf("deleted") === -1 ? <></> :
<button onClick={async () => {
await actions.checkoutfile(file.filename)
await actions.add({ filepath: 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>
}
</> </>
} }
if (group.name === 'Changes') { if (group.name === 'Changes') {
return <> 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 ? <></> :
{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>} <><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 '>
{(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>} <FontAwesomeIcon icon={faUndo} className="" />
{(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> : <></>} </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> :
<></>
}
</> </>
} }
return <></> return <></>

@ -8,6 +8,7 @@ import { ModalTypes } from "@remix-ui/app";
import { setFileDecorators } from "./pluginActions"; import { setFileDecorators } from "./pluginActions";
import { Plugin } from "@remixproject/engine"; import { Plugin } from "@remixproject/engine";
import { CustomRemixApi } from "@remix-api"; import { CustomRemixApi } from "@remix-api";
import { file } from "jszip";
export const fileStatuses = [ export const fileStatuses = [
["new,untracked", 0, 2, 0], // new, untracked ["new,untracked", 0, 2, 0], // new, untracked
@ -202,7 +203,12 @@ export const commit = async (message: string = "") => {
export const addall = async (files: fileStatusResult[]) => { export const addall = async (files: fileStatusResult[]) => {
try { try {
const filesToAdd = files.map(f => removeSlash(f.filename)) const filesToAdd = files
.filter(f => !f.statusNames.includes('deleted'))
.map(f => removeSlash(f.filename))
const filesToRemove = files
.filter(f => f.statusNames.includes('deleted'))
.map(f => removeSlash(f.filename))
try { try {
add({ filepath: filesToAdd }) add({ filepath: filesToAdd })
} catch (e) { } } catch (e) { }
@ -211,6 +217,10 @@ export const addall = async (files: fileStatusResult[]) => {
message: `Added all files to git` message: `Added all files to git`
}) })
try {
filesToRemove.map(f => rm({ filepath: f }))
} catch (e) { }
} catch (e) { } catch (e) {
plugin.call('notification', 'toast', `${e}`) plugin.call('notification', 'toast', `${e}`)
} }
@ -632,7 +642,7 @@ export const loadGitHubUserFromToken = async () => {
} }
export const statusMatrix = async (filepaths: string[]) => { 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) => { const result = (matrix || []).map((x) => {
return { return {
filename: `/${x.shift()}`, filename: `/${x.shift()}`,

Loading…
Cancel
Save