Merge pull request #2514 from ethereum/loadPluginsFromParameters

Load plugins from parameters
pull/1/head
yann300 5 years ago committed by GitHub
commit 47cfb63413
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      src/app.js
  2. 52
      src/remixAppManager.js
  3. 16
      test-browser/helpers/init.js
  4. 17
      test-browser/tests/workspace.js

@ -1,4 +1,3 @@
/* global localStorage */
'use strict'
var isElectron = require('is-electron')
@ -208,7 +207,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
// APP_MANAGER
const appManager = new RemixAppManager({})
const workspace = JSON.parse(localStorage.getItem('workspace'))
const workspace = appManager.pluginLoader.get()
// SERVICES
// ----------------- import content servive ----------------------------

@ -2,6 +2,7 @@
import { PluginEngine, IframePlugin } from '@remixproject/engine'
import { EventEmitter } from 'events'
import { PermissionHandler } from './app/ui/persmission-handler'
import QueryParams from './lib/query-params'
const requiredModules = [ // services + layout views + system views
'compilerArtefacts', 'compilerMetadata', 'contextualListener', 'editor', 'offsetToLineColumnConverter', 'network', 'theme', 'fileManager', 'contentImport',
@ -19,15 +20,13 @@ export class RemixAppManager extends PluginEngine {
constructor (plugins) {
super(plugins, settings)
this.event = new EventEmitter()
this.donotAutoReload = ['remixd'] // that would be a bad practice to force loading some plugins at page load.
this.registered = {}
this.pluginsDirectory = 'https://raw.githubusercontent.com/ethereum/remix-plugins-directory/master/build/profile.json'
this.pluginLoader = new PluginLoader()
}
onActivated (plugin) {
if (!this.donotAutoReload.includes(plugin.name)) {
localStorage.setItem('workspace', JSON.stringify(this.actives))
}
this.pluginLoader.set(plugin, this.actives)
this.event.emit('activate', plugin.name)
}
@ -46,7 +45,7 @@ export class RemixAppManager extends PluginEngine {
}
onDeactivated (plugin) {
localStorage.setItem('workspace', JSON.stringify(this.actives))
this.pluginLoader.set(plugin, this.actives)
this.event.emit('deactivate', plugin.name)
}
@ -232,3 +231,46 @@ export class RemixAppManager extends PluginEngine {
]
}
}
/** @class Reference loaders.
* A loader is a get,set based object which load a workspace from a defined sources.
* (localStorage, queryParams)
**/
class PluginLoader {
get currentLoader () {
return this.loaders[this.current]
}
constructor () {
const queryParams = new QueryParams()
this.donotAutoReload = ['remixd'] // that would be a bad practice to force loading some plugins at page load.
this.loaders = {}
this.loaders['localStorage'] = {
set: (plugin, actives) => {
if (!this.donotAutoReload.includes(plugin.name)) {
localStorage.setItem('workspace', JSON.stringify(actives))
}
},
get: () => { return JSON.parse(localStorage.getItem('workspace')) }
}
this.loaders['queryParams'] = {
set: () => {},
get: () => {
const { plugins } = queryParams.get()
if (!plugins) return []
return plugins.split(',')
}
}
this.current = queryParams.get()['plugins'] ? 'queryParams' : 'localStorage'
}
set (plugin, actives) {
this.currentLoader.set(plugin, actives)
}
get () {
return this.currentLoader.get()
}
}

@ -1,14 +1,16 @@
module.exports = function (browser, callback) {
module.exports = function (browser, callback, url, preloadPlugins = true) {
browser
.url('http://127.0.0.1:8080')
.url(url || 'http://127.0.0.1:8080')
.injectScript('test-browser/helpers/applytestmode.js', function () {
browser.resizeWindow(2560, 1440, () => {
initModules(browser, () => {
browser.clickLaunchIcon('solidity').click('#autoCompile')
.perform(function () {
callback()
if (preloadPlugins) {
initModules(browser, () => {
browser.clickLaunchIcon('solidity').click('#autoCompile')
.perform(function () {
callback()
})
})
})
} else callback()
})
})
}

@ -0,0 +1,17 @@
'use strict'
const init = require('../helpers/init')
const sauce = require('./sauce')
module.exports = {
before: function (browser, done) {
init(browser, done, 'http://127.0.0.1:8080?plugins=solidity,udapp', false)
},
'CheckSolidityActivatedAndUDapp': function (browser) {
browser
.waitForElementVisible('#icon-panel', 10000)
.clickLaunchIcon('solidity')
.clickLaunchIcon('udapp')
.end()
},
tearDown: sauce
}
Loading…
Cancel
Save