fix emitting and registering to pluginActivated and pluginDeactivated

pull/1/head
yann300 5 years ago committed by LianaHus
parent 9280d2c800
commit fc1be58243
  1. 17
      src/app/panels/tab-proxy.js
  2. 8
      src/app/tabs/test-tab.js
  3. 7
      src/app/ui/auto-complete-popup.js
  4. 18
      src/remixAppManager.js

@ -49,25 +49,24 @@ export class TabProxy {
}) })
}) })
appManager.event.on('activate', (name) => { appManager.event.on('activate', (profile) => {
const { profile } = appManager.getPlugin(name)
if (profile.location === 'mainPanel') { if (profile.location === 'mainPanel') {
this.addTab( this.addTab(
name, profile.name,
profile.displayName, profile.displayName,
() => this.event.emit('switchApp', name), () => this.event.emit('switchApp', profile.name),
() => { () => {
this.event.emit('closeApp', name) this.event.emit('closeApp', profile.name)
this.appManager.deactivatePlugin(name) this.appManager.deactivatePlugin(profile.name)
}, },
profile.icon profile.icon
) )
this.switchTab(name) this.switchTab(profile.name)
} }
}) })
appManager.event.on('deactivate', (name) => { appManager.event.on('deactivate', (profile) => {
this.removeTab(name) this.removeTab(profile.name)
}) })
appManager.event.on('ensureActivated', (name) => { appManager.event.on('ensureActivated', (name) => {

@ -30,11 +30,11 @@ module.exports = class TestTab extends ViewPlugin {
this.appManager = appManager this.appManager = appManager
this.renderer = renderer this.renderer = renderer
this.baseurl = 'https://solc-bin.ethereum.org/bin' this.baseurl = 'https://solc-bin.ethereum.org/bin'
appManager.event.on('activate', (name) => { appManager.event.on('activate', (profile) => {
if (name === 'solidity') this.updateRunAction(fileManager.currentFile()) if (profile.name === 'solidity') this.updateRunAction(fileManager.currentFile())
}) })
appManager.event.on('deactivate', (name) => { appManager.event.on('deactivate', (profile) => {
if (name === 'solidity') this.updateRunAction(fileManager.currentFile()) if (profile.name === 'solidity') this.updateRunAction(fileManager.currentFile())
}) })
} }

@ -189,13 +189,12 @@ class AutoCompletePopup {
extendAutocompletion () { extendAutocompletion () {
// TODO: this is not using the appManager interface. Terminal should be put as module // TODO: this is not using the appManager interface. Terminal should be put as module
this.opts.appManager.event.on('activate', async (id) => { this.opts.appManager.event.on('activate', async (profile) => {
const profile = await this.opts.appManager.getProfile(id)
if (!profile.methods) return if (!profile.methods) return
profile.methods.forEach((method) => { profile.methods.forEach((method) => {
const key = `remix.call({name: '${id}', key:'${method}', payload: []}).then((result) => { console.log(result) }).catch((error) => { console.log(error) })` const key = `remix.call({name: '${profile.name}', key:'${method}', payload: []}).then((result) => { console.log(result) }).catch((error) => { console.log(error) })`
const keyValue = {} const keyValue = {}
keyValue[key] = `call ${id} - ${method}` keyValue[key] = `call ${profile.name} - ${method}`
if (this.extraCommands.includes(keyValue)) return if (this.extraCommands.includes(keyValue)) return
this.extraCommands.push(keyValue) this.extraCommands.push(keyValue)
}) })

@ -36,9 +36,9 @@ export class RemixAppManager extends PluginManager {
return true return true
} }
onActivated (plugin) { onPluginActivated (plugin) {
this.pluginLoader.set(plugin, this.actives) this.pluginLoader.set(plugin, this.actives)
this.event.emit('activate', plugin.name) this.event.emit('activate', plugin)
} }
getAll () { getAll () {
@ -51,9 +51,9 @@ export class RemixAppManager extends PluginManager {
return Object.keys(this.registered) return Object.keys(this.registered)
} }
onDeactivated (plugin) { onPluginDeactivated (plugin) {
this.pluginLoader.set(plugin, this.actives) this.pluginLoader.set(plugin, this.actives)
this.event.emit('deactivate', plugin.name) this.event.emit('deactivate', plugin)
} }
onRegistration (plugin) { onRegistration (plugin) {
@ -62,6 +62,16 @@ export class RemixAppManager extends PluginManager {
this.event.emit('added', plugin.name) this.event.emit('added', plugin.name)
} }
ensureActivated (apiName) {
if (!this.isActive(apiName)) this.activateOne(apiName)
this.event.emit('ensureActivated', apiName)
}
ensureDeactivated (apiName) {
if (this.isActive(apiName)) this.deactivateOne(apiName)
this.event.emit('ensureDeactivated', apiName)
}
deactivatePlugin (name) { deactivatePlugin (name) {
if (requiredModules.includes(name)) return if (requiredModules.includes(name)) return
super.deactivatePlugin(name) super.deactivatePlugin(name)

Loading…
Cancel
Save