fix emitting and registering to pluginActivated and pluginDeactivated

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

@ -127,7 +127,7 @@ export class SidePanel extends AbstractPanel {
}
}
const header = yo`
const header = yo`
<header class="${css.swapitHeader} px-3">
<h6 class="${css.swapitTitle}" data-id="sidePanelSwapitTitle">${name}</h6>
${docLink}

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

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

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

@ -8,7 +8,7 @@ const requiredModules = [ // services + layout views + system views
'mainPanel', 'hiddenPanel', 'sidePanel', 'menuicons', 'fileExplorers',
'terminal', 'settings', 'pluginManager']
export function isNative (name) {
export function isNative (name) {
const nativePlugins = ['vyper', 'workshops', 'ethdoc', 'etherscan']
return nativePlugins.includes(name) || requiredModules.includes(name)
}
@ -36,9 +36,9 @@ export class RemixAppManager extends PluginManager {
return true
}
onActivated (plugin) {
onPluginActivated (plugin) {
this.pluginLoader.set(plugin, this.actives)
this.event.emit('activate', plugin.name)
this.event.emit('activate', plugin)
}
getAll () {
@ -51,9 +51,9 @@ export class RemixAppManager extends PluginManager {
return Object.keys(this.registered)
}
onDeactivated (plugin) {
onPluginDeactivated (plugin) {
this.pluginLoader.set(plugin, this.actives)
this.event.emit('deactivate', plugin.name)
this.event.emit('deactivate', plugin)
}
onRegistration (plugin) {
@ -62,6 +62,16 @@ export class RemixAppManager extends PluginManager {
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) {
if (requiredModules.includes(name)) return
super.deactivatePlugin(name)

Loading…
Cancel
Save