Close all tabs when workspace changes (#1105)

fix https://github.com/ethereum/remix-project/issues/989
pull/1072/head
yann300 4 years ago committed by GitHub
parent c592798c4c
commit bd07c52526
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      apps/remix-ide/src/app.js
  2. 9
      apps/remix-ide/src/app/files/fileManager.js
  3. 2
      apps/remix-ide/src/app/panels/file-panel.js
  4. 5
      apps/remix-ide/src/app/panels/tab-proxy.js
  5. 6
      libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx

@ -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 {
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 {
/** 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 {
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) => {
} }
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) => {
} }
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 }

Loading…
Cancel
Save