Fixed rename api in file manager

pull/11/head
ioedeveloper 4 years ago
parent beb5c13a93
commit 25795e90c1
  1. 18
      apps/remix-ide/src/app/files/fileManager.js
  2. 16
      test-browser/tests/fileManager_api.test.js

@ -194,10 +194,24 @@ class FileManager extends Plugin {
* @returns {void}
*/
async rename (oldPath, newPath) {
await this.__handleExists(oldPath, `Cannot rename ${oldPath}`)
await this._handleExists(oldPath, `Cannot rename ${oldPath}`)
const isFile = await this.isFile(oldPath)
const newPathExists = await this.exists(newPath)
const provider = this.fileProviderOf(oldPath)
this.fileRenamedEvent(oldPath, newPath, !isFile)
if (isFile) {
if (newPathExists) {
modalDialogCustom.alert('File already exists.')
return
}
return provider.rename(oldPath, newPath, false)
} else {
if (newPathExists) {
modalDialogCustom.alert('Folder already exists.')
return
}
return provider.rename(oldPath, newPath, true)
}
}
/**

@ -62,11 +62,19 @@ module.exports = {
.addFile('renameFile.js', { content: executeRename })
.executeScript(`remix.exeCurrent()`)
.pause(2000)
.pause(100000)
// .journalLastChildIncludes('pragma solidity >=0.2.0 <0.7.0;')
// .end()
.waitForElementPresent('[data-id="treeViewLibrowser/old_contract.sol"]')
.end()
},
// 'Should execute `rename` api from file manager external api': function (browser) {
// browser
// .addFile('renameFile.js', { content: executeRename })
// .executeScript(`remix.exeCurrent()`)
// .pause(2000)
// .waitForElementPresent('[data-id="treeViewLibrowser/new_contract.sol"]')
// .end()
// },
tearDown: sauce
}
@ -136,7 +144,7 @@ const executeRename = `
const run = async () => {
const result = await remix.call('fileManager', 'rename', 'browser/new_contract.sol', 'browser/old_contract.sol')
console.log(result)
console.log('result: ', result)
}
run()

Loading…
Cancel
Save