sending info about folder content

pull/1392/head
lianahus 3 years ago
parent 5ba2e3f6c5
commit b5f9f912ef
  1. 17
      apps/remix-ide/src/app/files/fileManager.js
  2. 3
      apps/remix-ide/src/app/files/fileProvider.js
  3. 1
      apps/remix-ide/src/app/files/remixDProvider.js
  4. 2
      apps/remix-ide/src/app/panels/tab-proxy.js
  5. 1
      libs/remix-ui/solidity-compiler/src/lib/css/style.css
  6. 30
      libs/remixd/src/services/remixdClient.ts

@ -360,11 +360,8 @@ class FileManager extends Plugin {
async remove (path) { async remove (path) {
try { try {
path = this.limitPluginScope(path) path = this.limitPluginScope(path)
console.log('remove fileManager,js ', path)
await this._handleExists(path, `Cannot remove file or directory ${path}`) await this._handleExists(path, `Cannot remove file or directory ${path}`)
const provider = this.fileProviderOf(path) const provider = this.fileProviderOf(path)
// this.emit('folderRemoved', path)
return await provider.remove(path) return await provider.remove(path)
} catch (e) { } catch (e) {
throw new Error(e) throw new Error(e)
@ -385,7 +382,6 @@ class FileManager extends Plugin {
this._deps.browserExplorer.event.on('fileRemoved', (path) => { this.fileRemovedEvent(path) }) this._deps.browserExplorer.event.on('fileRemoved', (path) => { this.fileRemovedEvent(path) })
this._deps.browserExplorer.event.on('fileAdded', (path) => { this.fileAddedEvent(path) }) this._deps.browserExplorer.event.on('fileAdded', (path) => { this.fileAddedEvent(path) })
this._deps.localhostExplorer.event.on('fileRemoved', (path) => { this.fileRemovedEvent(path) }) this._deps.localhostExplorer.event.on('fileRemoved', (path) => { this.fileRemovedEvent(path) })
this._deps.localhostExplorer.event.on('folderRemoved', (path) => { this.removeTabsOfPath(path) })
this._deps.localhostExplorer.event.on('errored', (event) => { this.removeTabsOf(this._deps.localhostExplorer) }) this._deps.localhostExplorer.event.on('errored', (event) => { this.removeTabsOf(this._deps.localhostExplorer) })
this._deps.localhostExplorer.event.on('closed', (event) => { this.removeTabsOf(this._deps.localhostExplorer) }) this._deps.localhostExplorer.event.on('closed', (event) => { this.removeTabsOf(this._deps.localhostExplorer) })
this._deps.workspaceExplorer.event.on('fileChanged', (path) => { this.fileChangedEvent(path) }) this._deps.workspaceExplorer.event.on('fileChanged', (path) => { this.fileChangedEvent(path) })
@ -550,19 +546,6 @@ class FileManager extends Plugin {
} }
} }
removeTabsOfPath (path) {
for (const tab in this.openedFiles) {
if (tab.substring(0, path.length) === path) {
console.log('removeTabsOfPath ', path)
if (path === this._deps.config.get('currentFile')) {
this._deps.config.set('currentFile', '')
}
this.editor.discard(path)
delete this.openedFiles[path]
}
}
}
fileRemovedEvent (path) { fileRemovedEvent (path) {
if (path === this._deps.config.get('currentFile')) { if (path === this._deps.config.get('currentFile')) {
this._deps.config.set('currentFile', '') this._deps.config.set('currentFile', '')

@ -185,7 +185,6 @@ class FileProvider {
window.remixFileSystem.rmdirSync(path, console.log) window.remixFileSystem.rmdirSync(path, console.log)
} }
this.event.emit('fileRemoved', this._normalizePath(path)) this.event.emit('fileRemoved', this._normalizePath(path))
console.log('file provider remove remove ', path)
} }
} catch (e) { } catch (e) {
console.log(e) console.log(e)
@ -251,8 +250,6 @@ class FileProvider {
if (window.remixFileSystem.existsSync(path) && !window.remixFileSystem.statSync(path).isDirectory()) { if (window.remixFileSystem.existsSync(path) && !window.remixFileSystem.statSync(path).isDirectory()) {
window.remixFileSystem.unlinkSync(path, console.log) window.remixFileSystem.unlinkSync(path, console.log)
this.event.emit('fileRemoved', this._normalizePath(path)) this.event.emit('fileRemoved', this._normalizePath(path))
console.log('file provider removefile remove ', path)
return true return true
} else return false } else return false
} }

@ -35,7 +35,6 @@ module.exports = class RemixDProvider extends FileProvider {
this._appManager.on('remixd', 'fileRemoved', (path) => { this._appManager.on('remixd', 'fileRemoved', (path) => {
this.event.emit('fileRemoved', path) this.event.emit('fileRemoved', path)
console.log('remixd appmanager listener remove ', path)
}) })
this._appManager.on('remixd', 'fileRenamed', (oldPath, newPath) => { this._appManager.on('remixd', 'fileRenamed', (oldPath, newPath) => {

@ -44,8 +44,6 @@ export class TabProxy extends Plugin {
fileManager.events.on('fileRemoved', (name) => { fileManager.events.on('fileRemoved', (name) => {
const workspace = this.fileManager.currentWorkspace() const workspace = this.fileManager.currentWorkspace()
console.log('wotk= ', workspace)
console.log('mode= ', this.fileManager.mode)
workspace ? this.removeTab(workspace + '/' + name) : this.removeTab(this.fileManager.mode + '/' + name) workspace ? this.removeTab(workspace + '/' + name) : this.removeTab(this.fileManager.mode + '/' + name)
}) })

@ -103,7 +103,6 @@
} }
.remixui_container { .remixui_container {
margin: 0; margin: 0;
margin-bottom: 2%;
} }
.remixui_optimizeContainer { .remixui_optimizeContainer {
display: flex; display: flex;

@ -180,19 +180,34 @@ export class RemixdClient extends PluginClient {
if (!fs.existsSync(path)) return reject(new Error('File not found ' + path)) if (!fs.existsSync(path)) return reject(new Error('File not found ' + path))
if (!isRealPath(path)) return if (!isRealPath(path)) return
// Saving the content of the item{folder} before removing it
if (this._isFile(path)) { const ls = []
this.emit('fileRemoved', path) try {
console.log('isfile ', path) const resolveList = (path) => {
} else { if (!this._isFile(path)) {
this.emit('folderRemoved', path) const list = utils.resolveDirectory(path, this.currentSharedFolder)
console.log('isFolder ', path) Object.keys(list).forEach(itemPath => {
if (list[itemPath].isDirectory) {
resolveList(`${this.currentSharedFolder}${itemPath}`)
}
ls.push(itemPath)
})
}
}
resolveList(path)
ls.push(args.path)
} catch (e) {
throw new Error(e)
} }
return fs.remove(path, (error: Error) => { return fs.remove(path, (error: Error) => {
if (error) { if (error) {
console.log(error) console.log(error)
return reject(new Error('Failed to remove file/directory: ' + error)) return reject(new Error('Failed to remove file/directory: ' + error))
} }
for (const file in ls) {
this.emit('fileRemoved', ls[file])
}
resolve(true) resolve(true)
}) })
}) })
@ -203,7 +218,6 @@ export class RemixdClient extends PluginClient {
_isFile (path: string): boolean { _isFile (path: string): boolean {
try { try {
console.log('isfile inside ', path)
return fs.statSync(path).isFile() return fs.statSync(path).isFile()
} catch (error) { } catch (error) {
throw new Error(error) throw new Error(error)

Loading…
Cancel
Save