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()) editor.event.register('requiringToSaveCurrentfile', () => fileManager.saveCurrentFile())
// ----------------- fileManager servive ---------------------------- // ----------------- fileManager servive ----------------------------
const fileManager = new FileManager(editor) const fileManager = new FileManager(editor, appManager)
registry.put({api: fileManager, name: 'filemanager'}) registry.put({api: fileManager, name: 'filemanager'})
const blockchain = new Blockchain(registry.get('config').api) const blockchain = new Blockchain(registry.get('config').api)

@ -38,7 +38,7 @@ const createError = (err) => {
} }
class FileManager extends Plugin { class FileManager extends Plugin {
constructor (editor) { constructor (editor, appManager) {
super(profile) super(profile)
this.openedFiles = {} // list all opened files this.openedFiles = {} // list all opened files
this.events = new EventEmitter() this.events = new EventEmitter()
@ -46,6 +46,7 @@ class FileManager extends Plugin {
this._components = {} this._components = {}
this._components.compilerImport = new CompilerImport() this._components.compilerImport = new CompilerImport()
this._components.registry = globalRegistry this._components.registry = globalRegistry
this.appManager = appManager
this.init() this.init()
} }
@ -493,6 +494,36 @@ class FileManager extends Plugin {
return this._deps.filesProviders['browser'] 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 () { allPaths () {
const dirPaths = [] const dirPaths = []
@ -501,12 +532,12 @@ class FileManager extends Plugin {
if (this.isDirectory(path)) { if (this.isDirectory(path)) {
if (!dirPaths.includes(path)) { if (!dirPaths.includes(path)) {
dirPaths.push(path) dirPaths.push(path)
console.log('adding .. ', path)
} }
this.readdir(path).then((ls) => { this.readdir(path).then((ls) => {
const promises = Object.keys(ls).map((item, index) => { 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) { if (ls[item].isDirectory) {
return findPaths(curPath) return findPaths(curPath)
} else { } else {
@ -521,9 +552,10 @@ class FileManager extends Plugin {
}) })
} }
const br = findPaths('browser') const roots = []
const lh = findPaths('localhost') roots.push(findPaths('browser'))
return Promise.all([br, lh]) if (this.appManager.isActive('remixd')) roots.push(findPaths('localhost'))
return Promise.all(roots)
} }
saveCurrentFile () { 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>` return yo`<span class='text-info h6'>Progress: ${ready} finished (of ${this.runningTestsNumber})</span>`
} }
allPaths () { updateDirList (e) {
return this.testTabLogic.allPaths() 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 () { render () {
@ -505,18 +509,13 @@ module.exports = class TestTab extends ViewPlugin {
data-id="uiPathInput" data-id="uiPathInput"
name="utPath" name="utPath"
style="background-image: var(--primary);" style="background-image: var(--primary);"
onkeydown=${(e) => this.updateDirList(e)}
onchange=${(e) => this.updateCurrentPath(e)}/> onchange=${(e) => this.updateCurrentPath(e)}/>
${this.uiPathList} ${this.uiPathList}
</div> </div>
` `
this.allPaths().then((options) => { this.uiPathList.appendChild(yo`<option>browser</option>`)
console.log('options ', options, ' length is ', options.length) if (this.testTabLogic.isRemixDActive()) this.uiPathList.appendChild(yo`<option>localhost</option>`)
options.forEach((path) => {
console.log('option ', path)
this.uiPathList.appendChild(yo`<option>${path}</option>`)
})
})
this.testsExecutionStopped.hidden = true this.testsExecutionStopped.hidden = true
this.testsExecutionStoppedError.hidden = true this.testsExecutionStoppedError.hidden = true
this.resultStatistics = this.createResultLabel() this.resultStatistics = this.createResultLabel()

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

Loading…
Cancel
Save