Unverified Commit 5546bbc1 authored by François's avatar François Committed by GitHub

Merge pull request #651 from ethereum/remove-ensure-activated

Remove ensure activated
parents ff235b5a ca7dc705
...@@ -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)
...@@ -429,8 +432,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org ...@@ -429,8 +432,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
}).catch(console.error) }).catch(console.error)
} else { } else {
// activate solidity plugin // activate solidity plugin
appManager.ensureActivated('solidity') appManager.activatePlugin(['solidity', 'udapp'])
appManager.ensureActivated('udapp')
} }
// Load and start the service who manager layout and frame // Load and start the service who manager layout and frame
......
...@@ -225,8 +225,9 @@ export class VerticalIcons extends Plugin { ...@@ -225,8 +225,9 @@ export class VerticalIcons extends Plugin {
const home = yo` const home = yo`
<div <div
class="${css.homeIcon}" class="${css.homeIcon}"
onclick="${(e) => { onclick="${async () => {
this.appManager.ensureActivated('home') 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
......
var yo = require('yo-yo') import { Plugin } from '@remixproject/engine'
var $ = require('jquery') const yo = require('yo-yo')
const $ = 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')
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
...@@ -84,24 +91,19 @@ export class TabProxy { ...@@ -84,24 +91,19 @@ export class TabProxy {
appManager.event.on('deactivate', (profile) => { appManager.event.on('deactivate', (profile) => {
this.removeTab(profile.name) this.removeTab(profile.name)
}) })
}
appManager.event.on('ensureActivated', (name) => { focus (name) {
if (name === 'home') {
// 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)
} }
})
}
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) {
if (this._handlers[tabName]) { if (this._handlers[tabName]) {
...@@ -205,6 +207,7 @@ export class TabProxy { ...@@ -205,6 +207,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) {
......
...@@ -240,44 +240,27 @@ export class LandingPage extends ViewPlugin { ...@@ -240,44 +240,27 @@ export class LandingPage extends ViewPlugin {
}) })
} }
const startSolidity = () => { const startSolidity = async () => {
this.appManager.ensureActivated('solidity') await this.appManager.activatePlugin(['solidity', 'udapp', 'solidityStaticAnalysis', 'solidityUnitTesting'])
this.appManager.ensureActivated('udapp')
this.appManager.ensureActivated('solidityStaticAnalysis')
this.appManager.ensureActivated('solidityUnitTesting')
this.verticalIcons.select('solidity') this.verticalIcons.select('solidity')
} }
/*
const startWorkshop = () => {
this.appManager.ensureActivated('box')
this.appManager.ensureActivated('solidity')
this.appManager.ensureActivated('solidityUnitTesting')
this.appManager.ensureActivated('workshops')
this.verticalIcons.select('workshops')
}
*/
const startPipeline = () => { const startPipeline = () => {
this.appManager.ensureActivated('solidity') this.appManager.activatePlugin(['solidity', 'pipeline', 'udapp'])
this.appManager.ensureActivated('pipeline')
this.appManager.ensureActivated('udapp')
} }
const startDebugger = () => { const startDebugger = async () => {
this.appManager.ensureActivated('debugger') await this.appManager.activatePlugin('debugger')
this.verticalIcons.select('debugger') this.verticalIcons.select('debugger')
} }
const startMythX = () => { const startMythX = async () => {
this.appManager.ensureActivated('solidity') await this.appManager.activatePlugin(['solidity', 'mythx'])
this.appManager.ensureActivated('mythx')
this.verticalIcons.select('mythx') this.verticalIcons.select('mythx')
} }
const startSourceVerify = () => { const startSourceVerify = async () => {
this.appManager.ensureActivated('solidity') await this.appManager.activatePlugin(['solidity', 'source-verification'])
this.appManager.ensureActivated('source-verification')
this.verticalIcons.select('source-verification') this.verticalIcons.select('source-verification')
} }
const startPluginManager = () => { const startPluginManager = async () => {
this.appManager.ensureActivated('pluginManager') await this.appManager.activatePlugin('pluginManager')
this.verticalIcons.select('pluginManager') this.verticalIcons.select('pluginManager')
} }
...@@ -286,7 +269,7 @@ export class LandingPage extends ViewPlugin { ...@@ -286,7 +269,7 @@ export class LandingPage extends ViewPlugin {
fileExplorer.createNewFile() fileExplorer.createNewFile()
} }
const connectToLocalhost = () => { const connectToLocalhost = () => {
this.appManager.ensureActivated('remixd') this.appManager.activatePlugin('remixd')
} }
const importFromGist = () => { const importFromGist = () => {
this.gistHandler.loadFromGist({ gist: '' }, globalRegistry.get('filemanager').api) this.gistHandler.loadFromGist({ gist: '' }, globalRegistry.get('filemanager').api)
......
export class Workspace {
constructor (title, description, isMain, activate, deactivate) {
this.title = title
this.description = description
this.isMain = isMain
this.activate = activate
this.deactivate = deactivate
}
}
export const defaultWorkspaces = (appManager) => {
return [
new Workspace(
'Solidity',
'Writing smart contracts. It is used for implementing smart contracts on various blockchain platforms',
true,
() => {
appManager.ensureActivated('solidity')
appManager.ensureActivated('udapp')
appManager.ensureActivated('solidityStaticAnalysis')
appManager.ensureActivated('solidityUnitTesting')
}, () => {}),
new Workspace(
'Vyper',
'Vyper is a contract-oriented, pythonic programming language that targets the Ethereum Virtual Machine (EVM)',
true,
() => {
appManager.ensureActivated('vyper')
appManager.ensureActivated('udapp')
}, () => {}),
new Workspace(
'Lexon',
'Lexon is a language modelling legal contracts that compiles down to ethereum smart contracts',
true,
() => {
appManager.ensureActivated('lexon')
appManager.ensureActivated('udapp')
}, () => {}),
new Workspace('Debugger', 'Debug transactions with remix', false, () => {
appManager.ensureActivated('debugger')
}, () => {}),
new Workspace('Pipeline', '', false, () => {
appManager.ensureActivated('solidity')
appManager.ensureActivated('pipeline')
appManager.ensureActivated('udapp')
})
]
}
...@@ -70,13 +70,6 @@ export class RemixAppManager extends PluginManager { ...@@ -70,13 +70,6 @@ export class RemixAppManager extends PluginManager {
this.event.emit('deactivate', plugin) this.event.emit('deactivate', plugin)
} }
onRegistration () {}
async ensureActivated (apiName) {
await this.activatePlugin(apiName)
this.event.emit('ensureActivated', apiName)
}
async ensureDeactivated (apiName) { async ensureDeactivated (apiName) {
await this.deactivatePlugin(apiName) await this.deactivatePlugin(apiName)
this.event.emit('ensureDeactivated', apiName) this.event.emit('ensureDeactivated', apiName)
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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