diff --git a/apps/remix-ide/src/app/components/plugin-manager-component.js b/apps/remix-ide/src/app/components/plugin-manager-component.js index b7055a1f55..8305ebc802 100644 --- a/apps/remix-ide/src/app/components/plugin-manager-component.js +++ b/apps/remix-ide/src/app/components/plugin-manager-component.js @@ -98,19 +98,36 @@ class PluginManagerComponent extends ViewPlugin { this.htmlElement = document.createElement('div') this.htmlElement.setAttribute('id', 'pluginManager') this.props = {} - // this.views = { - // root: null, - // items: {} - // } + this.views = { + root: null, + items: {} + } this.localPlugin = new LocalPlugin() this.filter = '' this.activePlugins = [] this.inactivePlugins = [] - this.activePlugins = this.appManager.actives + this.activePluginNames = this.appManager.actives // this.appManager.event.on('activate', () => { this.reRender() }) // this.appManager.event.on('deactivate', () => { this.reRender() }) // this.engine.event.on('onRegistration', () => { this.reRender() }) // const { actives, inactives } = this.getAllPlugins() + console.log('views property contents', this.views) + } + + isActive (name) { + this.appManager.actives.includes(name) + } + + activateP (name) { + // console.log(this.appManager) + this.appManager.turnPluginOn(name) + _paq.push(['trackEvent', 'manager', 'activate', name]) + } + + deactivateP (name) { + // console.log(this.appManager) + this.call('manager', 'deactivatePlugin', name) + _paq.push(['trackEvent', 'manager', 'deactivate', name]) } onActivation () { @@ -124,27 +141,16 @@ class PluginManagerComponent extends ViewPlugin { appManager={this.appManager} engine={this.engine} localPlugin={this.localPlugin} - activePlugins={this.activePlugins} + activePluginNames={this.activePluginsNames} actives={this.activePlugins} inactives={this.inactivePlugins} + activatePlugin={this.activateP} + deActivatePlugin={this.deactivateP} + _paq={_paq} />, document.getElementById('pluginManager')) } - isActive (name) { - return this.appManager.actives.includes(name) - } - - // activateP (name) { - // this.appManager.activatePlugin(name) - // _paq.push(['trackEvent', 'manager', 'activate', name]) - // } - - // deactivateP (name) { - // this.call('manager', 'deactivatePlugin', name) - // _paq.push(['trackEvent', 'manager', 'deactivate', name]) - // } - /*************** * SUB-COMPONENT */ diff --git a/apps/remix-ide/src/remixAppManager.js b/apps/remix-ide/src/remixAppManager.js index 45bc5a7421..fb1ef54a80 100644 --- a/apps/remix-ide/src/remixAppManager.js +++ b/apps/remix-ide/src/remixAppManager.js @@ -75,6 +75,14 @@ export class RemixAppManager extends PluginManager { return await this.permissionHandler.askPermission(this.profiles[from], this.profiles[to], method, message) } + async turnPluginOn (name) { + await this.activatePlugin(name) + } + + async turnPluginOff (name) { + await this.deactivatePlugin(name) + } + onPluginActivated (plugin) { this.pluginLoader.set(plugin, this.actives) this.event.emit('activate', plugin) diff --git a/libs/remix-ui/plugin-manager/src/lib/components/button.tsx b/libs/remix-ui/plugin-manager/src/lib/components/button.tsx index 3986c860d7..0bb723b729 100644 --- a/libs/remix-ui/plugin-manager/src/lib/components/button.tsx +++ b/libs/remix-ui/plugin-manager/src/lib/components/button.tsx @@ -3,17 +3,25 @@ import { PluginManagerContext } from '../contexts/pluginmanagercontext' interface ButtonProps { buttonText: 'Activate' | 'Deactivate' - + pluginName: string } -function Button ({ buttonText }: ButtonProps) { - const { profile, deActivatePlugin, activatePlugin } = useContext(PluginManagerContext) - const dataId = `pluginManagerComponentDeactivateButton${profile.name}` +function Button ({ buttonText, pluginName }: ButtonProps) { + const { appManager, _paq } = useContext(PluginManagerContext) + const dataId = `pluginManagerComponentDeactivateButton${pluginName}` const [needToDeactivate] = useState('btn btn-secondary btn-sm') const [needToActivate] = useState('btn btn-success btn-sm') return (