Commit cf81deee authored by GrandSchtroumpf's avatar GrandSchtroumpf

Create plugin for TabProxy

parent 62bd8fca
...@@ -314,7 +314,10 @@ Please make a backup of your contracts and start using http://remix.ethereum.org ...@@ -314,7 +314,10 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
const mainview = new MainView(contextualListener, editor, appPanel, fileManager, appManager, terminal) const mainview = new MainView(contextualListener, editor, appPanel, fileManager, appManager, terminal)
registry.put({ api: mainview, name: 'mainview' }) registry.put({ api: mainview, name: 'mainview' })
engine.register(appPanel) engine.register([
appPanel,
mainview.tabProxy
])
// those views depend on app_manager // those views depend on app_manager
const menuicons = new VerticalIcons(appManager) const menuicons = new VerticalIcons(appManager)
......
...@@ -225,7 +225,10 @@ export class VerticalIcons extends Plugin { ...@@ -225,7 +225,10 @@ export class VerticalIcons extends Plugin {
const home = yo` const home = yo`
<div <div
class="${css.homeIcon}" class="${css.homeIcon}"
onclick="${(e) => this.appManager.activatePlugin('home')}" onclick="${async () => {
await this.appManager.activatePlugin('home')
this.call('tabs', 'focus', 'home')
}}"
plugin="home" title="Home" plugin="home" title="Home"
data-id="verticalIconsHomeIcon" data-id="verticalIconsHomeIcon"
> >
......
...@@ -17,6 +17,7 @@ var css = csjs` ...@@ -17,6 +17,7 @@ var css = csjs`
} }
` `
// @todo(#650) Extract this into two classes: MainPanel (TabsProxy + Iframe/Editor) & BottomPanel (Terminal)
export class MainView { export class MainView {
constructor (contextualListener, editor, mainPanel, fileManager, appManager, terminal) { constructor (contextualListener, editor, mainPanel, fileManager, appManager, terminal) {
var self = this var self = this
......
...@@ -3,7 +3,7 @@ var $ = require('jquery') ...@@ -3,7 +3,7 @@ var $ = require('jquery')
const EventEmitter = require('events') const EventEmitter = require('events')
const globalRegistry = require('../../global/registry') const globalRegistry = require('../../global/registry')
const csjs = require('csjs-inject') const csjs = require('csjs-inject')
import { Plugin } from '@remixproject/engine'
require('remix-tabs') require('remix-tabs')
const css = csjs` const css = csjs`
...@@ -12,8 +12,15 @@ const css = csjs` ...@@ -12,8 +12,15 @@ const css = csjs`
} }
` `
export class TabProxy { const profile = {
name: 'tabs',
methods: ['focus'],
}
// @todo(#650) Merge this with MainPanel into one plugin
export class TabProxy extends Plugin {
constructor (fileManager, editor, appManager) { constructor (fileManager, editor, appManager) {
super(profile)
this.event = new EventEmitter() this.event = new EventEmitter()
this.fileManager = fileManager this.fileManager = fileManager
this.appManager = appManager this.appManager = appManager
...@@ -85,22 +92,25 @@ export class TabProxy { ...@@ -85,22 +92,25 @@ export class TabProxy {
this.removeTab(profile.name) this.removeTab(profile.name)
}) })
appManager.event.on('ensureActivated', (name) => { // appManager.event.on('pluginActivated', ({name}) => {
if (name === 'home') { // if (name === 'home') {
// if someone force activation of home, we switch to it // // if someone force activation of home, we switch to it
this.event.emit('switchApp', name) // this.event.emit('switchApp', name)
this._view.filetabs.activateTab(name) // this._view.filetabs.activateTab(name)
} // }
}) // })
}
focus (name) {
this.event.emit('switchApp', name)
this._view.filetabs.activateTab(name)
} }
updateImgStyles () { updateImgStyles () {
const images = this._view.filetabs.getElementsByClassName('iconImage') const images = this._view.filetabs.getElementsByClassName('iconImage')
if (images.length !== 0) { for (const element of images) {
for (const element of images) { globalRegistry.get('themeModule').api.fixInvert(element)
globalRegistry.get('themeModule').api.fixInvert(element) };
};
}
} }
switchTab (tabName) { switchTab (tabName) {
...@@ -205,6 +215,7 @@ export class TabProxy { ...@@ -205,6 +215,7 @@ export class TabProxy {
delete this._handlers[name] delete this._handlers[name]
this.switchToActiveTab() this.switchToActiveTab()
this.loadedTabs = this.loadedTabs.filter(tab => tab.name !== name) this.loadedTabs = this.loadedTabs.filter(tab => tab.name !== name)
this.updateImgStyles()
} }
addHandler (type, fn) { addHandler (type, fn) {
......
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