From 7f4048073d93fc12e63d62a15a8b55a3eb52ffd8 Mon Sep 17 00:00:00 2001 From: Grandschtroumpf Date: Mon, 13 May 2019 16:19:43 +0200 Subject: [PATCH 1/4] Remove settings from swapPanel --- src/app/components/swap-panel.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/app/components/swap-panel.js b/src/app/components/swap-panel.js index 215805c56c..b58738f093 100644 --- a/src/app/components/swap-panel.js +++ b/src/app/components/swap-panel.js @@ -54,19 +54,13 @@ export class SwapPanel extends AbstractPanel { /** The header of the swap panel */ renderHeader () { let name = ' - ' - let hasSettings = false if (this.active) { const { profile } = this.store.getOne(this.active) name = profile.displayName ? profile.displayName : profile.name - hasSettings = profile.settings || false } return yo`
${name}
-
- ${hasSettings - ? yo`` - : yo``}
` } From 331d3e1e2eec904c4c677efcd14d8df216bc458e Mon Sep 17 00:00:00 2001 From: Grandschtroumpf Date: Mon, 13 May 2019 16:19:54 +0200 Subject: [PATCH 2/4] 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` +
+ +
` + } + +} From 1e8fb2e5bf7ec024591f859820acf7c828c0b048 Mon Sep 17 00:00:00 2001 From: Grandschtroumpf Date: Mon, 13 May 2019 16:20:19 +0200 Subject: [PATCH 3/4] implement settings in plugin manager --- src/app/components/plugin-manager-component.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/app/components/plugin-manager-component.js b/src/app/components/plugin-manager-component.js index e0bb2f3f8c..b904aa1b2e 100644 --- a/src/app/components/plugin-manager-component.js +++ b/src/app/components/plugin-manager-component.js @@ -3,6 +3,7 @@ const csjs = require('csjs-inject') const EventEmitter = require('events') const LocalPlugin = require('./local-plugin') import { Plugin, BaseApi } from 'remix-plugin' +import { PluginManagerSettings } from './plugin-manager-settings' const css = csjs` .pluginSearch { @@ -152,14 +153,16 @@ class PluginManagerComponent extends BaseApi { ` : '' + const settings = new PluginManagerSettings().render() + const rootView = yo`
-
+
-
+
${activeTile}
@@ -170,6 +173,7 @@ class PluginManagerComponent extends BaseApi { ${inactives.map(name => this.renderItem(name))}
+ ${settings}
` if (!this.views.root) this.views.root = rootView From 0e67d43d93c6bdc5b54c03cc7b99064122cc89b2 Mon Sep 17 00:00:00 2001 From: Grandschtroumpf Date: Mon, 13 May 2019 16:47:19 +0200 Subject: [PATCH 4/4] Add title if no permission exist --- src/app/components/plugin-manager-settings.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/app/components/plugin-manager-settings.js b/src/app/components/plugin-manager-settings.js index f63ff2e9d1..017cf53cf2 100644 --- a/src/app/components/plugin-manager-settings.js +++ b/src/app/components/plugin-manager-settings.js @@ -17,6 +17,7 @@ const css = csjs` } .permissionForm h4 { font-size: 1.3rem; + text-align: center; } .permissionForm h6 { font-size: 1.1rem; @@ -36,7 +37,8 @@ const css = csjs` export class PluginManagerSettings { openDialog () { - this.permissions = JSON.parse(window.localStorage.getItem('plugins/permissions')) + const fromLocal = window.localStorage.getItem('plugins/permissions') + this.permissions = JSON.parse(fromLocal || '{}') modalDialog('Plugin Manager Settings', this.settings(), { fn: () => this.onValidation() }, ) @@ -64,22 +66,27 @@ export class PluginManagerSettings { ` } - const byPlugin = Object + const byModule = Object .keys(permission) .map(name => permissionByPlugin(name, permission[name])) return yo`
${key} :
- ${byPlugin} + ${byModule}
` } const permissions = Object .keys(this.permissions) .map(key => permissionByModule(key, this.permissions[key])) + + const title = permissions.length === 0 + ? yo`

No Permission requested yet.

` + : yo`

Current Permission settings

` + return yo`
-

Current Permission settings

+ ${title}
${permissions}
`