From 558951bcf1961ae9dfa8a40c80c327e9151b113e Mon Sep 17 00:00:00 2001 From: Grandschtroumpf Date: Mon, 13 May 2019 16:19:54 +0200 Subject: [PATCH] Create a plugin manager settings --- src/app/components/plugin-manager-settings.js | 95 +++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 src/app/components/plugin-manager-settings.js diff --git a/src/app/components/plugin-manager-settings.js b/src/app/components/plugin-manager-settings.js new file mode 100644 index 0000000000..f63ff2e9d1 --- /dev/null +++ b/src/app/components/plugin-manager-settings.js @@ -0,0 +1,95 @@ +const yo = require('yo-yo') +const csjs = require('csjs-inject') +const modalDialog = require('../ui/modaldialog') + +const css = csjs` +.permissions { + position: sticky; + bottom: 0; + display: flex; + justify-content: flex-end; + align-items: center; + padding: 5px 20px; +} +.permissions button { + padding: 2px 5px; + cursor: pointer; +} +.permissionForm h4 { + font-size: 1.3rem; +} +.permissionForm h6 { + font-size: 1.1rem; +} +.permissionForm hr { + width: 80%; +} +.checkbox { + display: flex; + align-items: center; +} +.checkbox label { + margin: 0; + font-size: 1rem; +}` + +export class PluginManagerSettings { + + openDialog () { + this.permissions = JSON.parse(window.localStorage.getItem('plugins/permissions')) + modalDialog('Plugin Manager Settings', this.settings(), + { fn: () => this.onValidation() }, + ) + } + + onValidation () { + const permissions = JSON.stringify(this.permissions) + window.localStorage.setItem('plugins/permissions', permissions) + } + + settings () { + const permissionByModule = (key, permission) => { + const permissionByPlugin = (name, plugin) => { + function updatePermission () { + plugin.allow = !plugin.allow + } + const checkbox = plugin.allow + ? yo`` + : yo`` + + return yo` +
+ ${checkbox} + +
` + } + + const byPlugin = Object + .keys(permission) + .map(name => permissionByPlugin(name, permission[name])) + + return yo` +
+
${key} :
+ ${byPlugin} +
` + } + + const permissions = Object + .keys(this.permissions) + .map(key => permissionByModule(key, this.permissions[key])) + return yo`
+

Current Permission settings

+
+ ${permissions} +
` + } + + render () { + return yo` + ` + } + +}