Merge pull request #1538 from ethereum/remixdWithReadOnlyMode

Using remixd in read only mode
pull/1/head
yann300 6 years ago committed by GitHub
commit 73ee9443d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      ci/browser_tests.sh
  2. 5
      src/app/editor/editor.js
  3. 2
      src/app/files/file-explorer.js
  4. 13
      src/app/files/fileManager.js
  5. 16
      src/app/files/shared-folder.js
  6. 2
      src/app/panels/editor-panel.js
  7. 8
      src/app/panels/file-panel.js
  8. 2
      src/app/tabs/test-tab.js

@ -7,7 +7,7 @@ setupRemixd () {
cd contracts
echo 'sharing folder: '
echo $PWD
./../node_modules/remixd/bin/remixd -s $PWD &
./../node_modules/remixd/bin/remixd -s $PWD --remix-ide http://127.0.0.1:8080 &
cd ..
}

@ -225,9 +225,8 @@ function Editor (opts = {}, localRegistry) {
}
this.discard = function (path) {
if (currentSession !== path) {
delete sessions[path]
}
if (sessions[path]) delete sessions[path]
if (currentSession === path) currentSession = null
}
this.resize = function (useWrapMode) {

@ -39,6 +39,8 @@ function fileExplorer (localRegistry, files) {
this.files.event.register('fileExternallyChanged', (path, file) => {
if (self._deps.config.get('currentFile') === path && self._deps.editor.currentContent() && self._deps.editor.currentContent() !== file.content) {
if (this.files.isReadOnly(path)) return self._deps.editor.setText(file.content)
modalDialog(path + ' changed', remixdDialog(),
{
label: 'Keep the content displayed in Remix',

@ -40,6 +40,8 @@ class FileManager {
self._deps.localhostExplorer.event.register('fileRemoved', (path) => { this.fileRemovedEvent(path) })
self._deps.configExplorer.event.register('fileRemoved', (path) => { this.fileRemovedEvent(path) })
self._deps.gistExplorer.event.register('fileRemoved', (path) => { this.fileRemovedEvent(path) })
self._deps.localhostExplorer.event.register('errored', (event) => { this.removeTabsOf(self._deps.localhostExplorer) })
self._deps.localhostExplorer.event.register('closed', (event) => { this.removeTabsOf(self._deps.localhostExplorer) })
}
fileRenamedEvent (oldName, newName, isFolder) {
@ -92,12 +94,21 @@ class FileManager {
return path ? path[1] : null
}
removeTabsOf (provider) {
for (var tab in this.tabbedFiles) {
if (this.fileProviderOf(tab).type === provider.type) {
this.fileRemovedEvent(tab)
}
}
}
fileRemovedEvent (path) {
var self = this
if (!this.tabbedFiles[path]) return
if (path === self._deps.config.get('currentFile')) {
self._deps.config.set('currentFile', '')
}
self._deps.editor.discardCurrentSession()
self._deps.editor.discard(path)
delete this.tabbedFiles[path]
this.refreshTabs()
this.switchFile()

@ -11,9 +11,17 @@ module.exports = class SharedFolder {
this.error = { 'EEXIST': 'File already exists' }
this._isReady = false
this._readOnlyFiles = {}
this._readOnlyMode = false
this.filesContent = {}
this.files = {}
var remixdEvents = ['connecting', 'connected', 'errored', 'closed']
remixdEvents.forEach((value) => {
remixd.event.register(value, (event) => {
this.event.trigger(value, [event])
})
})
remixd.event.register('notified', (data) => {
if (data.scope === 'sharedfolder') {
if (data.name === 'created') {
@ -51,8 +59,12 @@ module.exports = class SharedFolder {
init (cb) {
this._remixd.ensureSocket((error) => {
if (error) return cb(error)
this._isReady = !error
cb(error)
this._remixd.call('sharedfolder', 'folderIsReadOnly', {}, (error, result) => {
this._readOnlyMode = result
cb(error)
})
})
}
@ -103,7 +115,7 @@ module.exports = class SharedFolder {
}
isReadOnly (path) {
return this._readOnlyFiles[path] === 1
return this._readOnlyMode || this._readOnlyFiles[path] === 1
}
remove (path) {

@ -205,7 +205,7 @@ class EditorPanel {
if (Object.keys(self._deps.fileManager.tabbedFiles).length) {
self._deps.fileManager.switchFile(Object.keys(self._deps.fileManager.tabbedFiles)[0])
} else {
self._deps.editor.displayEmptyReadOnlySession()
self._components.editor.displayEmptyReadOnlySession()
self._deps.config.set('currentFile', '')
}
return false

@ -143,24 +143,24 @@ function filepanel (localRegistry) {
fileExplorer.ensureRoot()
configExplorer.ensureRoot()
var websocketconn = element.querySelector('.websocketconn')
self._deps.fileProviders['localhost'].remixd.event.register('connecting', (event) => {
self._deps.fileProviders['localhost'].event.register('connecting', (event) => {
websocketconn.style.color = styles.colors.yellow
websocketconn.setAttribute('title', 'Connecting to localhost. ' + JSON.stringify(event))
})
self._deps.fileProviders['localhost'].remixd.event.register('connected', (event) => {
self._deps.fileProviders['localhost'].event.register('connected', (event) => {
websocketconn.style.color = styles.colors.green
websocketconn.setAttribute('title', 'Connected to localhost. ' + JSON.stringify(event))
fileSystemExplorer.show()
})
self._deps.fileProviders['localhost'].remixd.event.register('errored', (event) => {
self._deps.fileProviders['localhost'].event.register('errored', (event) => {
websocketconn.style.color = styles.colors.red
websocketconn.setAttribute('title', 'localhost connection errored. ' + JSON.stringify(event))
fileSystemExplorer.hide()
})
self._deps.fileProviders['localhost'].remixd.event.register('closed', (event) => {
self._deps.fileProviders['localhost'].event.register('closed', (event) => {
websocketconn.style.color = styles.colors.black
websocketconn.setAttribute('title', 'localhost connection closed. ' + JSON.stringify(event))
fileSystemExplorer.hide()

@ -83,7 +83,9 @@ module.exports = class TestTab {
function getTests (self, cb) {
var path = self._deps.fileManager.currentPath()
if (!path) return cb(null, [])
var provider = self._deps.fileManager.fileProviderOf(path)
if (!provider) return cb(null, [])
var tests = []
self._deps.fileManager.filesFromPath(path, (error, files) => {
if (error) return cb(error)

Loading…
Cancel
Save