Merge pull request #974 from ethereum/blank-tabs

Add workspace name to tabs
pull/980/head
David Disu 4 years ago committed by GitHub
commit 0245336e82
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      apps/remix-ide-e2e/src/tests/defaultLayout.test.ts
  2. 4
      apps/remix-ide-e2e/src/tests/gist.test.ts
  3. 9
      apps/remix-ide/src/app/files/fileManager.js
  4. 57
      apps/remix-ide/src/app/panels/tab-proxy.js

@ -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')

@ -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()
},

@ -610,6 +610,15 @@ class FileManager extends Plugin {
if (callback) callback(error)
})
}
currentWorkspace () {
if (this.mode !== 'localhost') {
const file = this.currentFile() || ''
const provider = this.fileProviderOf(file)
return provider.workspace
}
}
}
module.exports = FileManager

@ -38,19 +38,28 @@ export class TabProxy extends Plugin {
})
fileManager.events.on('fileRemoved', (name) => {
this.removeTab(name)
const workspace = this.fileManager.currentWorkspace()
workspace ? this.removeTab(workspace + '/' + name) : this.removeTab(this.fileManager.mode + '/' + name)
})
fileManager.events.on('fileClosed', (name) => {
this.removeTab(name)
const workspace = this.fileManager.currentWorkspace()
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.currentWorkspace()
if (workspace) {
const workspacePath = workspace + '/' + file
if (this._handlers[workspacePath]) {
this._view.filetabs.activateTab(workspacePath)
return
}
this.addTab(file, '', () => {
this.addTab(workspacePath, '', () => {
this.fileManager.open(file)
this.event.emit('openFile', file)
},
@ -58,20 +67,52 @@ export class TabProxy extends Plugin {
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(path, '', () => {
this.fileManager.open(file)
this.event.emit('openFile', file)
},
() => {
this.fileManager.closeFile(file)
this.event.emit('closeFile', file)
})
}
})
fileManager.events.on('fileRenamed', (oldName, newName, isFolder) => {
const workspace = this.fileManager.currentWorkspace()
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(oldName, newName)
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(this.fileManager.mode + '/' + oldName, workspace + '/' + newName)
}
})
appManager.event.on('activate', ({ name, location, displayName, icon }) => {

Loading…
Cancel
Save