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} * @returns {void}
*/ */
async rename (oldPath, newPath) { 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 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 }) .addFile('renameFile.js', { content: executeRename })
.executeScript(`remix.exeCurrent()`) .executeScript(`remix.exeCurrent()`)
.pause(2000) .pause(2000)
.pause(100000) .waitForElementPresent('[data-id="treeViewLibrowser/old_contract.sol"]')
// .journalLastChildIncludes('pragma solidity >=0.2.0 <0.7.0;') .end()
// .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 tearDown: sauce
} }
@ -136,7 +144,7 @@ const executeRename = `
const run = async () => { const run = async () => {
const result = await remix.call('fileManager', 'rename', 'browser/new_contract.sol', 'browser/old_contract.sol') const result = await remix.call('fileManager', 'rename', 'browser/new_contract.sol', 'browser/old_contract.sol')
console.log(result) console.log('result: ', result)
} }
run() run()

Loading…
Cancel
Save