From 215db3a87917d8223dbddba68451c985e2d716b0 Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 1 Oct 2018 12:08:04 +0200 Subject: [PATCH 1/9] test tab: check path & provider value --- src/app/tabs/test-tab.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/app/tabs/test-tab.js b/src/app/tabs/test-tab.js index d94e469209..737ef6ef34 100644 --- a/src/app/tabs/test-tab.js +++ b/src/app/tabs/test-tab.js @@ -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) From 2cc774b2303b1cc2e43a3a4c8752d81c7fbaae6f Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 1 Oct 2018 12:09:22 +0200 Subject: [PATCH 2/9] abstract relmixd from filemanager --- src/app/files/fileManager.js | 3 +++ src/app/files/shared-folder.js | 7 +++++++ src/app/panels/file-panel.js | 8 ++++---- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/app/files/fileManager.js b/src/app/files/fileManager.js index 3bcdf045f3..46755b2de3 100644 --- a/src/app/files/fileManager.js +++ b/src/app/files/fileManager.js @@ -40,6 +40,9 @@ 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) { diff --git a/src/app/files/shared-folder.js b/src/app/files/shared-folder.js index bc3c57fb6a..43bcce4bc1 100644 --- a/src/app/files/shared-folder.js +++ b/src/app/files/shared-folder.js @@ -14,6 +14,13 @@ module.exports = class SharedFolder { 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') { diff --git a/src/app/panels/file-panel.js b/src/app/panels/file-panel.js index 51e8caff67..b6f38b763c 100644 --- a/src/app/panels/file-panel.js +++ b/src/app/panels/file-panel.js @@ -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() From e17a8d110b52688744171c67e70dc9b0d27aa46a Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 1 Oct 2018 12:09:42 +0200 Subject: [PATCH 3/9] fix bad reference --- src/app/panels/editor-panel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/panels/editor-panel.js b/src/app/panels/editor-panel.js index 57ac7ad288..70e8bbfae0 100644 --- a/src/app/panels/editor-panel.js +++ b/src/app/panels/editor-panel.js @@ -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 From 3605cdb404dd11dcc931dd3f7d9ccffa514af8ca Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 1 Oct 2018 12:10:43 +0200 Subject: [PATCH 4/9] init localhost provider with read only mode --- src/app/files/shared-folder.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/app/files/shared-folder.js b/src/app/files/shared-folder.js index 43bcce4bc1..98b833a67c 100644 --- a/src/app/files/shared-folder.js +++ b/src/app/files/shared-folder.js @@ -11,6 +11,7 @@ module.exports = class SharedFolder { this.error = { 'EEXIST': 'File already exists' } this._isReady = false this._readOnlyFiles = {} + this._readOnlyMode = false this.filesContent = {} this.files = {} @@ -58,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) + }) }) } @@ -110,7 +115,7 @@ module.exports = class SharedFolder { } isReadOnly (path) { - return this._readOnlyFiles[path] === 1 + return this._readOnlyMode || this._readOnlyFiles[path] === 1 } remove (path) { From a55b93017f4f03e773de4e6c6968e0ee21f067f3 Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 1 Oct 2018 12:11:23 +0200 Subject: [PATCH 5/9] fix discard file for editor --- src/app/editor/editor.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/app/editor/editor.js b/src/app/editor/editor.js index 8dcf48c6c9..c18e1d9efb 100644 --- a/src/app/editor/editor.js +++ b/src/app/editor/editor.js @@ -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) { From 570c2d0631de86b6111bec1f7043481cda4e636a Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 1 Oct 2018 12:11:53 +0200 Subject: [PATCH 6/9] auto replace content if readonly is true --- src/app/files/file-explorer.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/app/files/file-explorer.js b/src/app/files/file-explorer.js index 8b1eafc30d..730797076c 100644 --- a/src/app/files/file-explorer.js +++ b/src/app/files/file-explorer.js @@ -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', From f98941119d1a699d4e1d8182212db47e47b8b021 Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 1 Oct 2018 12:13:54 +0200 Subject: [PATCH 7/9] add remove tabs of provider --- src/app/files/fileManager.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/app/files/fileManager.js b/src/app/files/fileManager.js index 46755b2de3..c37f3f30b9 100644 --- a/src/app/files/fileManager.js +++ b/src/app/files/fileManager.js @@ -95,12 +95,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() From b2908dd3afb745d6455221ddaca00c87cb14d215 Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 1 Oct 2018 15:29:11 +0200 Subject: [PATCH 8/9] set remix ide web app url --- ci/browser_tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/browser_tests.sh b/ci/browser_tests.sh index abae1828e9..aa7c886022 100755 --- a/ci/browser_tests.sh +++ b/ci/browser_tests.sh @@ -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 .. } From 7bc716df3505193dde8c59f990d372b99b5a65d8 Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 8 Oct 2018 11:28:40 +0200 Subject: [PATCH 9/9] standard --- src/app/files/fileManager.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/app/files/fileManager.js b/src/app/files/fileManager.js index c37f3f30b9..5fe8f15846 100644 --- a/src/app/files/fileManager.js +++ b/src/app/files/fileManager.js @@ -40,7 +40,6 @@ 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) }) }