From c2d7338aced56491f6c5e341e571f94ddc6b9428 Mon Sep 17 00:00:00 2001 From: LianaHus Date: Wed, 11 Mar 2020 20:16:31 +0100 Subject: [PATCH] Permission modal UI fixes --- src/app/components/plugin-manager-settings.js | 82 ++++++++++--------- src/remixAppManager.js | 2 +- 2 files changed, 46 insertions(+), 38 deletions(-) diff --git a/src/app/components/plugin-manager-settings.js b/src/app/components/plugin-manager-settings.js index 9185721387..9940f7b197 100644 --- a/src/app/components/plugin-manager-settings.js +++ b/src/app/components/plugin-manager-settings.js @@ -60,68 +60,76 @@ export class PluginManagerSettings { } /** Clear one permission from a plugin */ - clearPersmission (from, to) { - if (!this.permissions[from]) return - delete this.permissions[from][to] - if (Object.keys(this.permissions[from]).length === 0) { - delete this.permissions[from] + clearPersmission (from, to, method) { + if (this.permissions[to] && this.permissions[to][method]) { + delete this.permissions[to][method][from] + if (Object.keys(this.permissions[to][method]).length === 0) { + delete this.permissions[to][method] + } + if (Object.keys(this.permissions[to]).length === 0) { + delete this.permissions[to] + } + yo.update(this.currentSetting, this.settings()) } - yo.update(this.currentSetting, this.settings()) } /** Clear all persmissions from a plugin */ - clearAllPersmission (from) { - if (!this.permissions[from]) return - delete this.permissions[from] + clearAllPersmission (to) { + if (!this.permissions[to]) return + delete this.permissions[to] yo.update(this.currentSetting, this.settings()) } settings () { - const permissionByModule = (key, permission) => { - const permissionByPlugin = (name, plugin) => { - function updatePermission () { - plugin.allow = !plugin.allow + const permissionByToPlugin = (toPlugin, funcObj) => { + const permissionByFunctions = (funcName, fromPlugins) => { + function updatePermission (plugin) { + self.permissions[toPlugin][funcName][plugin].allow = !self.permissions[toPlugin][funcName][plugin].allow } - const checkbox = plugin.allow - ? yo`` - : yo`` - - return yo` -
-
- ${checkbox} - -
- -
` + let self = this + return Object.keys(fromPlugins).map(fromName => { + const fromPluginPermission = fromPlugins[fromName] + const checkbox = fromPluginPermission.allow + ? yo` updatePermission(fromName)} class="mr-2" type="checkbox" checked id="permission-checkbox-${toPlugin}-${funcName}-${toPlugin}" aria-describedby="module ${fromPluginPermission} ask permission for ${funcName}" />` + : yo` updatePermission(fromName)} class="mr-2" type="checkbox" id="permission-checkbox-${toPlugin}-${funcName}-${toPlugin}" aria-describedby="module ${fromPluginPermission} ask permission for ${funcName}" />` + return yo` +
+
+ ${checkbox} + +
+ +
+ ` + }) } - const byModule = Object - .keys(permission) - .map(name => permissionByPlugin(name, permission[name])) + const permissionsByFunctions = Object + .keys(funcObj) + .map(funcName => permissionByFunctions(funcName, funcObj[funcName])) return yo` -
-
-
${key} :
- +
+
+

${toPlugin} permissions:

+
- ${byModule} + ${permissionsByFunctions}
` } - const permissions = Object + const byToPlugin = Object .keys(this.permissions) - .map(key => permissionByModule(key, this.permissions[key])) + .map(toPlugin => permissionByToPlugin(toPlugin, this.permissions[toPlugin])) - const title = permissions.length === 0 + const title = byToPlugin.length === 0 ? yo`

No Permission requested yet.

` : yo`

Current Permission settings

` return yo`
${title}
- ${permissions} + ${byToPlugin}
` } diff --git a/src/remixAppManager.js b/src/remixAppManager.js index 4e98b0e030..383e43d126 100644 --- a/src/remixAppManager.js +++ b/src/remixAppManager.js @@ -10,7 +10,7 @@ const requiredModules = [ // services + layout views + system views 'terminal', 'settings', 'pluginManager'] export function isNative (name) { - const nativePlugins = ['workshops', 'ethdoc', 'etherscan'] + const nativePlugins = ['vyper', 'workshops', 'ethdoc', 'etherscan'] return nativePlugins.includes(name) || requiredModules.includes(name) }