From 277666772ccf3d3446bc127d5f7a4a93f54f4047 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 2 Oct 2018 09:33:37 +0200 Subject: [PATCH] addProvider / removeProvider --- src/app/plugin/plugin.md | 2 ++ src/app/plugin/pluginAPI.js | 8 ++++++++ src/app/tabs/run-tab.js | 17 +++++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/src/app/plugin/plugin.md b/src/app/plugin/plugin.md index c0db0ee6d3..67cb3cfa20 100644 --- a/src/app/plugin/plugin.md +++ b/src/app/plugin/plugin.md @@ -26,6 +26,8 @@ plugin api - getProviderEndpoint `@return {String} url` - updateTitle `@param {String} title` - detectNetWork `@return {Object} {name, id}` + - addProvider `@param {String} name, @param {String} url` + - removeProvider `@return {String} name` ### config diff --git a/src/app/plugin/pluginAPI.js b/src/app/plugin/pluginAPI.js index e83b6c618b..1d9310154c 100644 --- a/src/app/plugin/pluginAPI.js +++ b/src/app/plugin/pluginAPI.js @@ -26,6 +26,14 @@ module.exports = (pluginManager, fileProviders, fileManager, compiler, udapp) => executionContext.detectNetwork((error, network) => { cb(error, network) }) + }, + addProvider: (mod, name, url, cb) => { + executionContext.addProvider({ name, url }) + cb() + }, + removeProvider: (mod, name, cb) => { + executionContext.removeProvider(name) + cb() } }, config: { diff --git a/src/app/tabs/run-tab.js b/src/app/tabs/run-tab.js index d722ecfbc7..41c285f45c 100644 --- a/src/app/tabs/run-tab.js +++ b/src/app/tabs/run-tab.js @@ -22,6 +22,7 @@ var css = require('./styles/run-tab-styles') var MultiParamManager = require('../../multiParamManager') var modalDialog = require('../ui/modaldialog') var CompilerAbstract = require('../compiler/compiler-abstract') +var tootip = require('../ui/tooltip') function runTab (opts, localRegistry) { /* ------------------------- @@ -639,6 +640,22 @@ function settings (container, self) { instanceContainer.appendChild(self._view.noInstancesText) }) + executionContext.event.register('addProvider', (network) => { + selectExEnv.appendChild(yo``) + tootip(`${network.name} [${network.url}] added`) + }) + + executionContext.event.register('removeProvider', (name) => { + var env = selectExEnv.querySelector(`option[value="${name}"]`) + if (env) { + selectExEnv.removeChild(env) + tootip(`${name} removed`) + } + }) + selectExEnv.addEventListener('change', function (event) { let context = selectExEnv.options[selectExEnv.selectedIndex].value executionContext.executionContextChange(context, null, () => {