read dear on '/' down

pull/11/head
LianaHus 5 years ago committed by ioedeveloper
parent c9916460cb
commit bf40a9e5d8
  1. 2
      apps/remix-ide/src/app.js
  2. 44
      apps/remix-ide/src/app/files/fileManager.js
  3. 19
      apps/remix-ide/src/app/tabs/test-tab.js
  4. 8
      apps/remix-ide/src/app/tabs/testTab/testTab.js

@ -257,7 +257,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
editor.event.register('requiringToSaveCurrentfile', () => fileManager.saveCurrentFile())
// ----------------- fileManager servive ----------------------------
const fileManager = new FileManager(editor)
const fileManager = new FileManager(editor, appManager)
registry.put({api: fileManager, name: 'filemanager'})
const blockchain = new Blockchain(registry.get('config').api)

@ -38,7 +38,7 @@ const createError = (err) => {
}
class FileManager extends Plugin {
constructor (editor) {
constructor (editor, appManager) {
super(profile)
this.openedFiles = {} // list all opened files
this.events = new EventEmitter()
@ -46,6 +46,7 @@ class FileManager extends Plugin {
this._components = {}
this._components.compilerImport = new CompilerImport()
this._components.registry = globalRegistry
this.appManager = appManager
this.init()
}
@ -493,6 +494,36 @@ class FileManager extends Plugin {
return this._deps.filesProviders['browser']
}
// returns the list of directories inside path
dirList (path) {
const dirPaths = []
const collectList = (path) => {
return new Promise((resolve, reject) => {
if (this.isDirectory(path)) {
this.readdir(path).then((ls) => {
const promises = Object.keys(ls).map((item, index) => {
const root = (path.indexOf('/') === -1) ? path : path.substr(0, path.indexOf('/'))
const curPath = `${root}/${item}` // adding 'browser' or 'localhost'
if (ls[item].isDirectory && !dirPaths.includes(curPath)) {
dirPaths.push(curPath)
resolve(dirPaths)
}
return new Promise((resolve, reject) => { resolve() })
})
Promise.all(promises).then(() => { resolve(dirPaths) })
})
} else {
resolve(dirPaths)
}
})
}
return collectList(path)
}
isRemixDActive () {
return this.appManager.isActive('remixd')
}
allPaths () {
const dirPaths = []
@ -501,12 +532,12 @@ class FileManager extends Plugin {
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}`
const root = (path.indexOf('/') === -1) ? path : path.substr(0, path.indexOf('/'))
const curPath = `${root}/${item}` // adding 'browser' or 'localhost'
if (ls[item].isDirectory) {
return findPaths(curPath)
} else {
@ -521,9 +552,10 @@ class FileManager extends Plugin {
})
}
const br = findPaths('browser')
const lh = findPaths('localhost')
return Promise.all([br, lh])
const roots = []
roots.push(findPaths('browser'))
if (this.appManager.isActive('remixd')) roots.push(findPaths('localhost'))
return Promise.all(roots)
}
saveCurrentFile () {

@ -485,8 +485,12 @@ module.exports = class TestTab extends ViewPlugin {
return yo`<span class='text-info h6'>Progress: ${ready} finished (of ${this.runningTestsNumber})</span>`
}
allPaths () {
return this.testTabLogic.allPaths()
updateDirList (e) {
if (e.keyCode === 191) {
this.testTabLogic.dirList(this._view.el.getElementsByClassName('custom-select')[0].value).then((options) => {
options.forEach((path) => this.uiPathList.appendChild(yo`<option>${path}</option>`))
})
}
}
render () {
@ -505,18 +509,13 @@ module.exports = class TestTab extends ViewPlugin {
data-id="uiPathInput"
name="utPath"
style="background-image: var(--primary);"
onkeydown=${(e) => this.updateDirList(e)}
onchange=${(e) => this.updateCurrentPath(e)}/>
${this.uiPathList}
</div>
`
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.uiPathList.appendChild(yo`<option>browser</option>`)
if (this.testTabLogic.isRemixDActive()) this.uiPathList.appendChild(yo`<option>localhost</option>`)
this.testsExecutionStopped.hidden = true
this.testsExecutionStoppedError.hidden = true
this.resultStatistics = this.createResultLabel()

@ -32,8 +32,12 @@ class TestTabLogic {
})
}
allPaths () {
return this.fileManager.allPaths()
dirList (path) {
return this.fileManager.dirList(path)
}
isRemixDActive () {
return this.fileManager.isRemixDActive()
}
async getTests (cb) {

Loading…
Cancel
Save