Unverified Commit bd07c525 authored by yann300's avatar yann300 Committed by GitHub

Close all tabs when workspace changes (#1105)

parent c592798c
...@@ -450,7 +450,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org ...@@ -450,7 +450,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
} }
await appManager.activatePlugin(['contentImport', 'theme', 'editor', 'fileManager', 'compilerMetadata', 'compilerArtefacts', 'network', 'web3Provider', 'offsetToLineColumnConverter']) await appManager.activatePlugin(['contentImport', 'theme', 'editor', 'fileManager', 'compilerMetadata', 'compilerArtefacts', 'network', 'web3Provider', 'offsetToLineColumnConverter'])
await appManager.activatePlugin(['mainPanel', 'menuicons']) await appManager.activatePlugin(['mainPanel', 'menuicons', 'tabs'])
await appManager.activatePlugin(['sidePanel']) // activating host plugin separately await appManager.activatePlugin(['sidePanel']) // activating host plugin separately
await appManager.activatePlugin(['home']) await appManager.activatePlugin(['home'])
await appManager.activatePlugin(['hiddenPanel', 'pluginManager', 'fileExplorers', 'settings', 'contextualListener', 'terminal', 'fetchAndCompile']) await appManager.activatePlugin(['hiddenPanel', 'pluginManager', 'fileExplorers', 'settings', 'contextualListener', 'terminal', 'fetchAndCompile'])
......
...@@ -398,6 +398,15 @@ class FileManager extends Plugin { ...@@ -398,6 +398,15 @@ class FileManager extends Plugin {
return this._deps.config.get('currentFile') return this._deps.config.get('currentFile')
} }
closeAllFiles () {
// TODO: Only keep `this.emit` (issue#2210)
this.emit('filesAllClosed')
this.events.emit('filesAllClosed')
for (const file in this.openedFiles) {
this.closeFile(file)
}
}
closeFile (name) { closeFile (name) {
delete this.openedFiles[name] delete this.openedFiles[name]
if (!Object.keys(this.openedFiles).length) { if (!Object.keys(this.openedFiles).length) {
......
...@@ -225,7 +225,7 @@ module.exports = class Filepanel extends ViewPlugin { ...@@ -225,7 +225,7 @@ module.exports = class Filepanel extends ViewPlugin {
/** these are called by the react component, action is already finished whent it's called */ /** these are called by the react component, action is already finished whent it's called */
async setWorkspace (workspace) { async setWorkspace (workspace) {
this._deps.fileManager.removeTabsOf(this._deps.fileProviders.workspace) this._deps.fileManager.closeAllFiles()
if (workspace.isLocalhost) { if (workspace.isLocalhost) {
this.call('manager', 'activatePlugin', 'remixd') this.call('manager', 'activatePlugin', 'remixd')
} else if (await this.call('manager', 'isActive', 'remixd')) { } else if (await this.call('manager', 'isActive', 'remixd')) {
......
...@@ -37,6 +37,11 @@ export class TabProxy extends Plugin { ...@@ -37,6 +37,11 @@ export class TabProxy extends Plugin {
this.updateImgStyles() this.updateImgStyles()
}) })
fileManager.events.on('filesAllClosed', () => {
this.call('manager', 'activatePlugin', 'home')
this._view.filetabs.active = 'home'
})
fileManager.events.on('fileRemoved', (name) => { fileManager.events.on('fileRemoved', (name) => {
const workspace = this.fileManager.currentWorkspace() const workspace = this.fileManager.currentWorkspace()
......
...@@ -223,7 +223,7 @@ export const Workspace = (props: WorkspaceProps) => { ...@@ -223,7 +223,7 @@ export const Workspace = (props: WorkspaceProps) => {
} }
const setWorkspace = async (name) => { const setWorkspace = async (name) => {
props.setWorkspace({ name, isLocalhost: name === LOCALHOST }) await props.setWorkspace({ name, isLocalhost: name === LOCALHOST })
if (name === LOCALHOST) { if (name === LOCALHOST) {
props.workspace.clearWorkspace() props.workspace.clearWorkspace()
} else if (name === NO_WORKSPACE) { } else if (name === NO_WORKSPACE) {
...@@ -238,8 +238,8 @@ export const Workspace = (props: WorkspaceProps) => { ...@@ -238,8 +238,8 @@ export const Workspace = (props: WorkspaceProps) => {
} }
const remixdExplorer = { const remixdExplorer = {
hide: () => { hide: async () => {
if (state.currentWorkspace === LOCALHOST) setWorkspace(NO_WORKSPACE) await setWorkspace(NO_WORKSPACE)
props.fileManager.setMode('browser') props.fileManager.setMode('browser')
setState(prevState => { setState(prevState => {
return { ...prevState, hideRemixdExplorer: true, loadingLocalhost: false } return { ...prevState, hideRemixdExplorer: true, loadingLocalhost: false }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment