diff --git a/src/app/panels/righthand-panel.js b/src/app/panels/righthand-panel.js index 77f389f278..aca26f259b 100644 --- a/src/app/panels/righthand-panel.js +++ b/src/app/panels/righthand-panel.js @@ -16,7 +16,9 @@ const PluginTab = require('../tabs/plugin-tab') const TestTab = require('../tabs/test-tab') const RunTab = require('../tabs/run-tab') const PluginAPI = require('../plugin/pluginAPI') +const plugins = require('../plugin/plugins') +var toolTip = require('../ui/tooltip') const EventManager = remixLib.EventManager const styles = styleguide.chooser() @@ -73,11 +75,24 @@ module.exports = class RighthandPanel { self.loadPlugin(json) }) + self.event.register('plugin-name-loadRequest', name => { + if (plugins[name]) { + self.loadPlugin(plugins[name]) + } else { + toolTip('unknown plugin ' + name) + } + }) + self.loadPlugin = function (json) { - var tab = new PluginTab(json) - var content = tab.render() - self._components.tabbedMenu.addTab(json.title, json.title + ' plugin', content) - self._components.pluginManager.register(json, content) + if (self._components.pluginManager.plugins[json.title]) { + self._components.tabbedMenu.removeTabByTitle(json.title) + self._components.pluginManager.unregister(json) + } else { + var tab = new PluginTab(json) + var content = tab.render() + self._components.tabbedMenu.addTab(json.title, json.title + ' plugin', content) + self._components.pluginManager.register(json, content) + } } self._view.dragbar = yo`
` diff --git a/src/app/plugin/pluginManager.js b/src/app/plugin/pluginManager.js index 5492581284..0ea91f1781 100644 --- a/src/app/plugin/pluginManager.js +++ b/src/app/plugin/pluginManager.js @@ -161,6 +161,11 @@ module.exports = class PluginManager { // } }, false) } + unregister (desc) { + const self = this + delete self.plugins[desc.title] + delete self.origins[desc.url] + } register (desc, content) { const self = this self.plugins[desc.title] = {content, origin: desc.url} diff --git a/src/app/plugin/plugins.js b/src/app/plugin/plugins.js new file mode 100644 index 0000000000..68cdb2e31e --- /dev/null +++ b/src/app/plugin/plugins.js @@ -0,0 +1,8 @@ +'use strict' + +module.exports = { + 'oraclize': { + url: 'https://remix-plugin.oraclize.it', + title: 'Oraclize' + } +} diff --git a/src/app/tabs/settings-tab.js b/src/app/tabs/settings-tab.js index ba2d3b0fd5..6b406f86ed 100644 --- a/src/app/tabs/settings-tab.js +++ b/src/app/tabs/settings-tab.js @@ -26,7 +26,8 @@ module.exports = class SettingsTab { compiler: self._components.registry.get('compiler').api, config: self._components.registry.get('config').api, editorPanel: self._components.registry.get('editorpanel').api, - editor: self._components.registry.get('editor').api + editor: self._components.registry.get('editor').api, + righthandpanel: self._components.registry.get('righthandpanel').api } self._view = { /* eslint-disable */ el: null, @@ -155,8 +156,9 @@ module.exports = class SettingsTab {