From d7cdc6942f5b59fc65359bda6e7d8c670b962ce8 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Mon, 15 Mar 2021 13:25:05 +0100 Subject: [PATCH 1/9] Add workspace name to tabs --- apps/remix-ide/src/app/files/fileManager.js | 7 +++ apps/remix-ide/src/app/panels/tab-proxy.js | 57 ++++++++++++++++++--- 2 files changed, 56 insertions(+), 8 deletions(-) diff --git a/apps/remix-ide/src/app/files/fileManager.js b/apps/remix-ide/src/app/files/fileManager.js index 0ffe4f714b..c1f86ea11c 100644 --- a/apps/remix-ide/src/app/files/fileManager.js +++ b/apps/remix-ide/src/app/files/fileManager.js @@ -610,6 +610,13 @@ class FileManager extends Plugin { if (callback) callback(error) }) } + + getCurrentWorkspace () { + const file = this.currentFile() || '' + const provider = this.fileProviderOf(file) + + return provider.workspace + } } module.exports = FileManager diff --git a/apps/remix-ide/src/app/panels/tab-proxy.js b/apps/remix-ide/src/app/panels/tab-proxy.js index bc4970b266..4215333ac3 100644 --- a/apps/remix-ide/src/app/panels/tab-proxy.js +++ b/apps/remix-ide/src/app/panels/tab-proxy.js @@ -38,19 +38,43 @@ export class TabProxy extends Plugin { }) fileManager.events.on('fileRemoved', (name) => { - this.removeTab(name) + const workspace = this.fileManager.getCurrentWorkspace() + + workspace ? this.removeTab(workspace + '/' + name) : this.removeTab(this.fileManager.mode + '/' + name) }) fileManager.events.on('fileClosed', (name) => { - this.removeTab(name) + const workspace = this.fileManager.getCurrentWorkspace() + + workspace ? this.removeTab(workspace + '/' + name) : this.removeTab(this.fileManager.mode + '/' + name) }) fileManager.events.on('currentFileChanged', (file) => { - if (this._handlers[file]) { - this._view.filetabs.activateTab(file) + const workspace = this.fileManager.getCurrentWorkspace() + + if (workspace) { + const workspacePath = workspace + '/' + file + + if (this._handlers[workspacePath]) { + this._view.filetabs.activateTab(workspacePath) + return + } + this.addTab(workspacePath, '', () => { + this.fileManager.open(file) + this.event.emit('openFile', file) + }, + () => { + this.fileManager.closeFile(file) + this.event.emit('closeFile', file) + }) + } else { + const path = this.fileManager.mode + '/' + file + + if (this._handlers[path]) { + this._view.filetabs.activateTab(path) return } - this.addTab(file, '', () => { + this.addTab(path, '', () => { this.fileManager.open(file) this.event.emit('openFile', file) }, @@ -58,20 +82,37 @@ export class TabProxy extends Plugin { this.fileManager.closeFile(file) this.event.emit('closeFile', file) }) + } }) fileManager.events.on('fileRenamed', (oldName, newName, isFolder) => { + const workspace = this.fileManager.getCurrentWorkspace() + + if (workspace) { if (isFolder) { for (const tab of this.loadedTabs) { - if (tab.name.indexOf(oldName + '/') === 0) { - const newTabName = newName + tab.name.slice(oldName.length, tab.name.length) + if (tab.name.indexOf(workspace + '/' + oldName + '/') === 0) { + const newTabName = workspace + '/' + newName + tab.name.slice(workspace + '/' + oldName.length, tab.name.length) + this.renameTab(tab.name, newTabName) + } + } + return + } + // should change the tab title too + this.renameTab(workspace + '/' + oldName, workspace + '/' + newName) + } else { + if (isFolder) { + for (const tab of this.loadedTabs) { + if (tab.name.indexOf(this.fileManager.mode + '/' + oldName + '/') === 0) { + const newTabName = this.fileManager.mode + '/' + newName + tab.name.slice(this.fileManager.mode + '/' + oldName.length, tab.name.length) this.renameTab(tab.name, newTabName) } } return } // should change the tab title too - this.renameTab(oldName, newName) + this.renameTab(this.fileManager.mode + '/' + oldName, workspace + '/' + newName) + } }) appManager.event.on('activate', ({ name, location, displayName, icon }) => { From 14a337118fa183f07063a85d34a28f787e8bddd4 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Mon, 15 Mar 2021 13:56:01 +0100 Subject: [PATCH 2/9] Fixed linting --- apps/remix-ide/src/app/panels/tab-proxy.js | 30 +++++++++++----------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/apps/remix-ide/src/app/panels/tab-proxy.js b/apps/remix-ide/src/app/panels/tab-proxy.js index 4215333ac3..5af0c13dd9 100644 --- a/apps/remix-ide/src/app/panels/tab-proxy.js +++ b/apps/remix-ide/src/app/panels/tab-proxy.js @@ -72,16 +72,16 @@ export class TabProxy extends Plugin { if (this._handlers[path]) { this._view.filetabs.activateTab(path) - return - } + return + } this.addTab(path, '', () => { - this.fileManager.open(file) - this.event.emit('openFile', file) - }, - () => { - this.fileManager.closeFile(file) - this.event.emit('closeFile', file) - }) + this.fileManager.open(file) + this.event.emit('openFile', file) + }, + () => { + this.fileManager.closeFile(file) + this.event.emit('closeFile', file) + }) } }) @@ -89,8 +89,8 @@ export class TabProxy extends Plugin { const workspace = this.fileManager.getCurrentWorkspace() if (workspace) { - if (isFolder) { - for (const tab of this.loadedTabs) { + if (isFolder) { + for (const tab of this.loadedTabs) { if (tab.name.indexOf(workspace + '/' + oldName + '/') === 0) { const newTabName = workspace + '/' + newName + tab.name.slice(workspace + '/' + oldName.length, tab.name.length) this.renameTab(tab.name, newTabName) @@ -105,12 +105,12 @@ export class TabProxy extends Plugin { for (const tab of this.loadedTabs) { if (tab.name.indexOf(this.fileManager.mode + '/' + oldName + '/') === 0) { const newTabName = this.fileManager.mode + '/' + newName + tab.name.slice(this.fileManager.mode + '/' + oldName.length, tab.name.length) - this.renameTab(tab.name, newTabName) + this.renameTab(tab.name, newTabName) + } } + return } - return - } - // should change the tab title too + // should change the tab title too this.renameTab(this.fileManager.mode + '/' + oldName, workspace + '/' + newName) } }) From f9db0d9f103adcdbaeb10431fc5eb1a4d9df67ce Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Mon, 15 Mar 2021 16:00:05 +0100 Subject: [PATCH 3/9] Update gist test --- apps/remix-ide-e2e/src/tests/gist.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/gist.test.ts b/apps/remix-ide-e2e/src/tests/gist.test.ts index f832379e1f..cefe41a2ad 100644 --- a/apps/remix-ide-e2e/src/tests/gist.test.ts +++ b/apps/remix-ide-e2e/src/tests/gist.test.ts @@ -120,8 +120,8 @@ module.exports = { .setValue('*[data-id="modalDialogCustomPromptText"]', testData.validGistId) .modalFooterOKClick() .openFile(`${testData.validGistId}/ApplicationRegistry`) - .waitForElementVisible(`div[title='${testData.validGistId}/ApplicationRegistry']`) - .assert.containsText(`div[title='${testData.validGistId}/ApplicationRegistry'] > span`, 'ApplicationRegistry') + .waitForElementVisible(`div[title='default_workspace/${testData.validGistId}/ApplicationRegistry']`) + .assert.containsText(`div[title='default_workspace/${testData.validGistId}/ApplicationRegistry'] > span`, 'ApplicationRegistry') .end() }, From a9bc4c1f97f9ef40ae2f886123f0cd9fa34db680 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Mon, 15 Mar 2021 16:22:16 +0100 Subject: [PATCH 4/9] Updated default layout test --- apps/remix-ide-e2e/src/tests/defaultLayout.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/remix-ide-e2e/src/tests/defaultLayout.test.ts b/apps/remix-ide-e2e/src/tests/defaultLayout.test.ts index f095438b88..b4a13c43dd 100644 --- a/apps/remix-ide-e2e/src/tests/defaultLayout.test.ts +++ b/apps/remix-ide-e2e/src/tests/defaultLayout.test.ts @@ -63,7 +63,7 @@ module.exports = { .waitForElementVisible('div[data-id="filePanelFileExplorerTree"]') .click('[data-id="treeViewLitreeViewItemcontracts"]') .openFile('contracts/3_Ballot.sol') - .assert.containsText('div[title="contracts/3_Ballot.sol"]', '3_Ballot.sol') + .assert.containsText('div[title="default_workspace/contracts/3_Ballot.sol"]', '3_Ballot.sol') .click('span[class^=dropdownCaret]') .click('#homeItem') .assert.containsText('div[title="home"]', 'Home') From 8b4452373fb0c04c2a8d392b56daad6d4fd5f718 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Mon, 15 Mar 2021 17:13:57 +0100 Subject: [PATCH 5/9] Rename function from getCurrentWorkspace to currentWorkspace in fileManager --- apps/remix-ide/src/app/files/fileManager.js | 2 +- apps/remix-ide/src/app/panels/tab-proxy.js | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/remix-ide/src/app/files/fileManager.js b/apps/remix-ide/src/app/files/fileManager.js index c1f86ea11c..932828538d 100644 --- a/apps/remix-ide/src/app/files/fileManager.js +++ b/apps/remix-ide/src/app/files/fileManager.js @@ -611,7 +611,7 @@ class FileManager extends Plugin { }) } - getCurrentWorkspace () { + currentWorkspace () { const file = this.currentFile() || '' const provider = this.fileProviderOf(file) diff --git a/apps/remix-ide/src/app/panels/tab-proxy.js b/apps/remix-ide/src/app/panels/tab-proxy.js index 5af0c13dd9..0bdef0c2ec 100644 --- a/apps/remix-ide/src/app/panels/tab-proxy.js +++ b/apps/remix-ide/src/app/panels/tab-proxy.js @@ -38,19 +38,19 @@ export class TabProxy extends Plugin { }) fileManager.events.on('fileRemoved', (name) => { - const workspace = this.fileManager.getCurrentWorkspace() + const workspace = this.fileManager.currentWorkspace() workspace ? this.removeTab(workspace + '/' + name) : this.removeTab(this.fileManager.mode + '/' + name) }) fileManager.events.on('fileClosed', (name) => { - const workspace = this.fileManager.getCurrentWorkspace() + const workspace = this.fileManager.currentWorkspace() workspace ? this.removeTab(workspace + '/' + name) : this.removeTab(this.fileManager.mode + '/' + name) }) fileManager.events.on('currentFileChanged', (file) => { - const workspace = this.fileManager.getCurrentWorkspace() + const workspace = this.fileManager.currentWorkspace() if (workspace) { const workspacePath = workspace + '/' + file @@ -86,7 +86,7 @@ export class TabProxy extends Plugin { }) fileManager.events.on('fileRenamed', (oldName, newName, isFolder) => { - const workspace = this.fileManager.getCurrentWorkspace() + const workspace = this.fileManager.currentWorkspace() if (workspace) { if (isFolder) { From 8b19c1fc757e179af6fba1ba027444c3b3903208 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Mon, 15 Mar 2021 19:47:17 +0100 Subject: [PATCH 6/9] Update currentWorkspace logic --- apps/remix-ide/src/app/files/fileManager.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apps/remix-ide/src/app/files/fileManager.js b/apps/remix-ide/src/app/files/fileManager.js index 932828538d..f2f9760150 100644 --- a/apps/remix-ide/src/app/files/fileManager.js +++ b/apps/remix-ide/src/app/files/fileManager.js @@ -612,8 +612,7 @@ class FileManager extends Plugin { } currentWorkspace () { - const file = this.currentFile() || '' - const provider = this.fileProviderOf(file) + const provider = self._deps.filesProviders.workspace return provider.workspace } From 469c3fe343f552704225dc9d7a84d60471db0c8f Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Tue, 16 Mar 2021 10:08:23 +0100 Subject: [PATCH 7/9] Catch undefined exception of filesProviders --- apps/remix-ide/src/app/files/fileManager.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/remix-ide/src/app/files/fileManager.js b/apps/remix-ide/src/app/files/fileManager.js index f2f9760150..c6a8543208 100644 --- a/apps/remix-ide/src/app/files/fileManager.js +++ b/apps/remix-ide/src/app/files/fileManager.js @@ -612,9 +612,11 @@ class FileManager extends Plugin { } currentWorkspace () { - const provider = self._deps.filesProviders.workspace + if (self._deps) { + const provider = self._deps.filesProviders.workspace - return provider.workspace + return provider.workspace + } } } From 4fbb0bd82bc2b236673a2c0de93015a4d0989395 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Tue, 16 Mar 2021 11:47:18 +0100 Subject: [PATCH 8/9] Get file provider from file --- apps/remix-ide/src/app/files/fileManager.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/apps/remix-ide/src/app/files/fileManager.js b/apps/remix-ide/src/app/files/fileManager.js index c6a8543208..932828538d 100644 --- a/apps/remix-ide/src/app/files/fileManager.js +++ b/apps/remix-ide/src/app/files/fileManager.js @@ -612,11 +612,10 @@ class FileManager extends Plugin { } currentWorkspace () { - if (self._deps) { - const provider = self._deps.filesProviders.workspace + const file = this.currentFile() || '' + const provider = this.fileProviderOf(file) - return provider.workspace - } + return provider.workspace } } From 5dadc598f8b1486579a1c1749ba5d62b05f88385 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Tue, 16 Mar 2021 11:51:38 +0100 Subject: [PATCH 9/9] Check for localhost before return --- apps/remix-ide/src/app/files/fileManager.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/remix-ide/src/app/files/fileManager.js b/apps/remix-ide/src/app/files/fileManager.js index 932828538d..2efd5322b0 100644 --- a/apps/remix-ide/src/app/files/fileManager.js +++ b/apps/remix-ide/src/app/files/fileManager.js @@ -612,10 +612,12 @@ class FileManager extends Plugin { } currentWorkspace () { - const file = this.currentFile() || '' - const provider = this.fileProviderOf(file) + if (this.mode !== 'localhost') { + const file = this.currentFile() || '' + const provider = this.fileProviderOf(file) - return provider.workspace + return provider.workspace + } } }