Fixed duplicate new file

pull/668/head
ioedeveloper 4 years ago
parent 861fcfa028
commit 5baa82c546
  1. 4
      .env
  2. 19
      apps/remix-ide-e2e/src/commands/addFile.ts
  3. 28
      libs/remix-ui/file-explorer/src/lib/file-explorer.tsx

@ -1,4 +1,4 @@
gist_token=ef5df4e3822bf121f1aee4616ea110309e2d49f5
account_passphrase=<passphrase>
account_password=<password>
account_passphrase=explain uniform adapt basic blue onion rebel pull rice erase volcano couple
account_password=remix_is_cool
NODE_OPTIONS=--max-old-space-size=2048

@ -15,20 +15,11 @@ class AddFile extends EventEmitter {
function addFile (browser: NightwatchBrowser, name: string, content: NightwatchContractContent, done: VoidFunction) {
browser.clickLaunchIcon('udapp').clickLaunchIcon('fileExplorers').click('.newFile')
.waitForElementVisible('#modal-dialog')
.perform((client, done) => {
browser.execute(function (fileName) {
if (fileName !== 'Untitled.sol') {
document.querySelector('#modal-dialog #prompt_text').setAttribute('value', fileName)
}
const elem = document.querySelector('#modal-footer-ok') as HTMLElement
elem.click()
}, [name], function (result) {
console.log(result)
done()
})
})
.pause(2000)
.keys(name)
.keys(browser.Keys.ENTER)
.pause(1000)
.click('[data-id="treeViewLitreeViewItembrowser/Greet.sol"]')
.setEditorValue(content.content)
.pause(1000)
.perform(function () {

@ -156,8 +156,8 @@ export const FileExplorer = (props: FileExplorerProps) => {
filesProvider.event.register('fileRenamed', fileRenamed)
}, [state.files])
const resolveDirectory = async (folderPath, dir: File[]): Promise<File[]> => {
if ((extractParentFromKey(state.focusEdit.element) === name) && (dir.findIndex(({ path }) => path === state.focusEdit.element) === -1)) {
const resolveDirectory = async (folderPath, dir: File[], isChild = false): Promise<File[]> => {
if (!isChild && (state.focusEdit.element === 'browser/blank') && state.focusEdit.isNew && (dir.findIndex(({ path }) => path === 'browser/blank') === -1)) {
dir = state.focusEdit.type === 'file' ? [...dir, {
path: state.focusEdit.element,
name: '',
@ -171,25 +171,21 @@ export const FileExplorer = (props: FileExplorerProps) => {
dir = await Promise.all(dir.map(async (file) => {
if (file.path === folderPath) {
if ((extractParentFromKey(state.focusEdit.element) === folderPath) && state.focusEdit.isNew) {
if (file.child && (file.child.findIndex(({ path }) => path === state.focusEdit.element) === -1)) {
file.child = state.focusEdit.type === 'file' ? [...await fetchDirectoryContent(folderPath), {
path: state.focusEdit.element,
name: '',
isDirectory: false
}] : [{
path: state.focusEdit.element,
name: '',
isDirectory: true
}, ...await fetchDirectoryContent(folderPath)]
} else {
file.child = await fetchDirectoryContent(folderPath)
}
file.child = state.focusEdit.type === 'file' ? [...await fetchDirectoryContent(folderPath), {
path: state.focusEdit.element,
name: '',
isDirectory: false
}] : [{
path: state.focusEdit.element,
name: '',
isDirectory: true
}, ...await fetchDirectoryContent(folderPath)]
} else {
file.child = await fetchDirectoryContent(folderPath)
}
return file
} else if (file.child) {
file.child = await resolveDirectory(folderPath, file.child)
file.child = await resolveDirectory(folderPath, file.child, true)
return file
} else {
return file

Loading…
Cancel
Save