generate the list of paths

pull/11/head
LianaHus 5 years ago committed by ioedeveloper
parent 0c3271e170
commit c9916460cb
  1. 33
      apps/remix-ide/src/app/files/fileManager.js
  2. 2
      apps/remix-ide/src/app/files/fileProvider.js
  3. 14
      apps/remix-ide/src/app/tabs/test-tab.js
  4. 5
      apps/remix-ide/src/app/tabs/testTab/testTab.js

@ -493,6 +493,39 @@ class FileManager extends Plugin {
return this._deps.filesProviders['browser']
}
allPaths () {
const dirPaths = []
const findPaths = (path) => {
return new Promise((resolve, reject) => {
if (this.isDirectory(path)) {
if (!dirPaths.includes(path)) {
dirPaths.push(path)
console.log('adding .. ', path)
}
this.readdir(path).then((ls) => {
const promises = Object.keys(ls).map((item, index) => {
const curPath = `browser/${item}`
if (ls[item].isDirectory) {
return findPaths(curPath)
} else {
return new Promise((resolve, reject) => { resolve() })
}
})
Promise.all(promises).then(() => { resolve(dirPaths) })
})
} else {
resolve(dirPaths)
}
})
}
const br = findPaths('browser')
const lh = findPaths('localhost')
return Promise.all([br, lh])
}
saveCurrentFile () {
var currentFile = this._deps.config.get('currentFile')
if (currentFile && this.editor.current()) {

@ -226,7 +226,7 @@ class FileProvider {
if (files) {
files.forEach(element => {
const absPath = (path === '/' ? '' : path) + '/' + element
ret[absPath.indexOf('/') === 0 ? absPath.replace('/', '') : absPath] = { isDirectory: window.remixFileSystem.statSync(absPath).isDirectory() }
ret[absPath.indexOf('/') === 0 ? absPath.substr(1, absPath.length) : absPath] = { isDirectory: window.remixFileSystem.statSync(absPath).isDirectory() }
// ^ ret does not accept path starting with '/'
})
}

@ -486,8 +486,7 @@ module.exports = class TestTab extends ViewPlugin {
}
allPaths () {
const paths = ['browser', 'browser/test']
return paths
return this.testTabLogic.allPaths()
}
render () {
@ -510,9 +509,12 @@ module.exports = class TestTab extends ViewPlugin {
${this.uiPathList}
</div>
`
let options = ['browser', 'browser/test'] // this.allPaths()
options.forEach((path) => {
this.uiPathList.appendChild(yo`<option>${path}</option>`)
this.allPaths().then((options) => {
console.log('options ', options, ' length is ', options.length)
options.forEach((path) => {
console.log('option ', path)
this.uiPathList.appendChild(yo`<option>${path}</option>`)
})
})
this.testsExecutionStopped.hidden = true
@ -523,7 +525,7 @@ module.exports = class TestTab extends ViewPlugin {
<div class="${css.testTabView} px-2" id="testView">
<div class="${css.infoBox}">
<p class="text-lg"> Test your smart contract in Solidity.</p>
<p> Click on "Generate" to generate a sample test file in.</p>
<p> Click on "Generate" to generate a sample test file in a:</p>
${availablePaths}
</div>
<div class="${css.tests}">

@ -1,6 +1,7 @@
const helper = require('../../../lib/helper.js')
const modalDialogCustom = require('../../ui/modal-dialog-custom')
const remixPath = require('path')
class TestTabLogic {
constructor (fileManager) {
@ -31,6 +32,10 @@ class TestTabLogic {
})
}
allPaths () {
return this.fileManager.allPaths()
}
async getTests (cb) {
if (!this.currentPath) return cb(null, [])
const provider = this.fileManager.fileProviderOf(this.currentPath)

Loading…
Cancel
Save