canActivate option (#714)

I've added an option so that plugins can activate other plugins by adding an extra optional line to the profiles
canActivate: ['plugin1', 'plugin2', ... ]
This will allow that plugin to activate other plugins. But we can curate this when the profiles are made.
This optional. If the other plugin does not exist or the caller doesn't have canActivate in its profile it gets caught.
pull/753/head^2
bunsenstraat 4 years ago committed by GitHub
parent 01c0a22b4b
commit 06fde893b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 18
      apps/remix-ide/src/remixAppManager.js

@ -15,8 +15,20 @@ export function isNative (name) {
return nativePlugins.includes(name) || requiredModules.includes(name)
}
export function canActivate (name) {
return ['ethdoc'].includes(name) || isNative(name)
/**
* Checks if plugin caller 'from' is allowed to activate plugin 'to'
* The caller can have 'canActivate' as a optional property in the plugin profile.
* This is an array containing the 'name' property of the plugin it wants to call.
* canActivate = ['plugin1-to-call','plugin2-to-call',....]
* or the plugin is allowed by default because it is native
*
* @param {any, any}
* @returns {boolean}
*/
export function canActivate (from, to) {
return ['ethdoc'].includes(from.name) ||
isNative(from.name) ||
(to && from && from.canActivate && from.canActivate.includes[to.name])
}
export class RemixAppManager extends PluginManager {
@ -29,7 +41,7 @@ export class RemixAppManager extends PluginManager {
}
async canActivatePlugin (from, to) {
return canActivate(from.name)
return canActivate(from, to)
}
async canDeactivatePlugin (from, to) {

Loading…
Cancel
Save