From aa168c64b5df9e6957cb6eef3cdb31b73db61829 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 18 Dec 2018 13:29:34 +0100 Subject: [PATCH] move tabs instanciation to app.js --- src/app.js | 24 +++++++++++- src/app/panels/righthand-panel.js | 62 +++++-------------------------- src/app/tabs/settings-tab.js | 3 +- 3 files changed, 33 insertions(+), 56 deletions(-) diff --git a/src/app.js b/src/app.js index 6a51b697c2..5409f751cf 100644 --- a/src/app.js +++ b/src/app.js @@ -36,6 +36,16 @@ var NotPersistedExplorer = require('./app/files/NotPersistedExplorer') var toolTip = require('./app/ui/tooltip') var TransactionReceiptResolver = require('./transactionReceiptResolver') +const CompilerAbstract = require('./app/compiler/compiler-abstract') +const PluginManager = require('./app/plugin/pluginManager') +const CompileTab = require('./app/tabs/compile-tab') +const SettingsTab = require('./app/tabs/settings-tab') +const AnalysisTab = require('./app/tabs/analysis-tab') +const DebuggerTab = require('./app/tabs/debugger-tab') +const SupportTab = require('./app/tabs/support-tab') +const TestTab = require('./app/tabs/test-tab') +const RunTab = require('./app/tabs/run-tab') + var styleGuide = require('./app/ui/styles-guide/theme-chooser') var styles = styleGuide.chooser() @@ -389,8 +399,20 @@ Please make a backup of your contracts and start using http://remix.ethereum.org var renderer = new Renderer() registry.put({api: renderer, name: 'renderer'}) + // ---------------- Tabs ------------------------------- + let compileTab = new CompileTab(self._components.registry) + let tabs = { + compile: compileTab, + run: new RunTab(self._components.registry), + settings: new SettingsTab(self._components.registry), + analysis: new AnalysisTab(self._components.registry), + debug: new DebuggerTab(self._components.registry), + support: new SupportTab(self._components.registry), + test: new TestTab(self._components.registry, compileTab) + } + // ---------------- Righthand-panel -------------------- - self._components.righthandpanel = new RighthandPanel() + self._components.righthandpanel = new RighthandPanel({ tabs, pluginManager }) self._view.rightpanel.appendChild(self._components.righthandpanel.render()) self._components.righthandpanel.init() self._components.righthandpanel.event.register('resize', delta => self._adjustLayout('right', delta)) diff --git a/src/app/panels/righthand-panel.js b/src/app/panels/righthand-panel.js index e81f841108..6a2f8091f2 100644 --- a/src/app/panels/righthand-panel.js +++ b/src/app/panels/righthand-panel.js @@ -5,22 +5,14 @@ const EventManager = require('../../lib/events') var globalRegistry = require('../../global/registry') const styleguide = require('../ui/styles-guide/theme-chooser') -const PluginManager = require('../plugin/pluginManager') const TabbedMenu = require('../tabs/tabbed-menu') -const CompileTab = require('../tabs/compile-tab') -const SettingsTab = require('../tabs/settings-tab') -const AnalysisTab = require('../tabs/analysis-tab') -const DebuggerTab = require('../tabs/debugger-tab') -const SupportTab = require('../tabs/support-tab') const PluginTab = require('../tabs/plugin-tab') -const TestTab = require('../tabs/test-tab') -const RunTab = require('../tabs/run-tab') const DraggableContent = require('../ui/draggableContent') const styles = styleguide.chooser() module.exports = class RighthandPanel { - constructor (localRegistry) { + constructor ({pluginManager, tabs}, localRegistry) { const self = this self._components = {} self._components.registry = localRegistry || globalRegistry @@ -33,57 +25,25 @@ module.exports = class RighthandPanel { dragbar: null } - self._deps = { - fileProviders: self._components.registry.get('fileproviders').api, - fileManager: self._components.registry.get('filemanager').api, - compiler: self._components.registry.get('compiler').api, - udapp: self._components.registry.get('udapp').api, - app: self._components.registry.get('app').api, - txlistener: self._components.registry.get('txlistener').api - } - var tabbedMenu = new TabbedMenu(self._components.registry) - - var pluginManager = new PluginManager( - self._deps.app, - self._deps.compiler, - self._deps.txlistener, - self._deps.fileProviders, - self._deps.fileManager, - self._deps.udapp - ) - - self._components.registry.put({api: pluginManager, name: 'pluginmanager'}) - - var analysisTab = new AnalysisTab(self._components.registry) - analysisTab.event.register('newStaticAnaysisWarningMessage', (msg, settings) => { self._components.compile.addWarning(msg, settings) }) - - self._components.debuggerTab = new DebuggerTab(self._components.registry) - + self._components = { - pluginManager: pluginManager, tabbedMenu: tabbedMenu, - compile: new CompileTab(self._components.registry), - run: new RunTab(self._components.registry), - settings: new SettingsTab(self._components.registry), - analysis: analysisTab, - debug: self._components.debuggerTab, - support: new SupportTab(self._components.registry), - test: new TestTab(self._components.registry) + tabs } - self._components.settings.event.register('plugin-loadRequest', json => { + self._components.tabs.settings.event.register('plugin-loadRequest', json => { self.loadPlugin(json) }) self.loadPlugin = function (json) { var modal = new DraggableContent(() => { - self._components.pluginManager.unregister(json) + pluginManager.unregister(json) }) var tab = new PluginTab(json) var content = tab.render() document.querySelector('body').appendChild(modal.render(json.title, json.url, content)) - self._components.pluginManager.register(json, modal, content) + pluginManager.register(json, modal, content) } self._view.dragbar = yo`
` @@ -96,7 +56,7 @@ module.exports = class RighthandPanel { ` - const { compile, run, settings, analysis, debug, support, test } = self._components + const { compile, run, settings, analysis, debug, support, test } = tabs self._components.tabbedMenu.addTab('Compile', 'compileView', compile.render()) self._components.tabbedMenu.addTab('Run', 'runView', run.render()) self._components.tabbedMenu.addTab('Analysis', 'staticanalysisView', analysis.render()) @@ -106,11 +66,7 @@ module.exports = class RighthandPanel { self._components.tabbedMenu.addTab('Support', 'supportView', support.render()) self._components.tabbedMenu.selectTabByTitle('Compile') } - // showDebugger () { - // const self = this - // if (!self._components.tabbedMenu) return - // self._components.tabbedMenu.selectTab(self._view.el.querySelector('li.debugView')) - // } + render () { const self = this if (self._view.element) return self._view.element @@ -118,7 +74,7 @@ module.exports = class RighthandPanel { } debugger () { - return this._components.debug.debugger() + return this._components.tabs.debug.debugger() } focusOn (x) { diff --git a/src/app/tabs/settings-tab.js b/src/app/tabs/settings-tab.js index 3868e8d5ae..b8f38ed79c 100644 --- a/src/app/tabs/settings-tab.js +++ b/src/app/tabs/settings-tab.js @@ -20,8 +20,7 @@ module.exports = class SettingsTab { self._deps = { config: self._components.registry.get('config').api, editorPanel: self._components.registry.get('editorpanel').api, - editor: self._components.registry.get('editor').api, - righthandpanel: self._components.registry.get('righthandpanel').api + editor: self._components.registry.get('editor').api } self._view = { /* eslint-disable */ el: null,