From 6a3214993c1ff86709b2a22c6fa25474708d7e76 Mon Sep 17 00:00:00 2001 From: Rob Stupay Date: Tue, 14 May 2019 11:48:53 +0200 Subject: [PATCH 1/2] location radio set from local storage --- src/app/components/local-plugin.js | 37 +++++++++++++++++++----------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/src/app/components/local-plugin.js b/src/app/components/local-plugin.js index 1159413102..a5106387e2 100644 --- a/src/app/components/local-plugin.js +++ b/src/app/components/local-plugin.js @@ -34,11 +34,13 @@ module.exports = class LocalPlugin { */ create () { const profile = { - ...this.profile, icon: 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPHN2ZyB3aWR0aD0iMTc5MiIgaGVpZ2h0PSIxNzkyIiB2aWV3Qm94PSIwIDAgMTc5MiAxNzkyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxwYXRoIGQ9Ik0xMjYyIDEwNzVxLTM3IDEyMS0xMzggMTk1dC0yMjggNzQtMjI4LTc0LTEzOC0xOTVxLTgtMjUgNC00OC41dDM4LTMxLjVxMjUtOCA0OC41IDR0MzEuNSAzOHEyNSA4MCA5Mi41IDEyOS41dDE1MS41IDQ5LjUgMTUxLjUtNDkuNSA5Mi41LTEyOS41cTgtMjYgMzItMzh0NDktNCAzNyAzMS41IDQgNDguNXptLTQ5NC00MzVxMCA1My0zNy41IDkwLjV0LTkwLjUgMzcuNS05MC41LTM3LjUtMzcuNS05MC41IDM3LjUtOTAuNSA5MC41LTM3LjUgOTAuNSAzNy41IDM3LjUgOTAuNXptNTEyIDBxMCA1My0zNy41IDkwLjV0LTkwLjUgMzcuNS05MC41LTM3LjUtMzcuNS05MC41IDM3LjUtOTAuNSA5MC41LTM3LjUgOTAuNSAzNy41IDM3LjUgOTAuNXptMjU2IDI1NnEwLTEzMC01MS0yNDguNXQtMTM2LjUtMjA0LTIwNC0xMzYuNS0yNDguNS01MS0yNDguNSA1MS0yMDQgMTM2LjUtMTM2LjUgMjA0LTUxIDI0OC41IDUxIDI0OC41IDEzNi41IDIwNCAyMDQgMTM2LjUgMjQ4LjUgNTEgMjQ4LjUtNTEgMjA0LTEzNi41IDEzNi41LTIwNCA1MS0yNDguNXptMTI4IDBxMCAyMDktMTAzIDM4NS41dC0yNzkuNSAyNzkuNS0zODUuNSAxMDMtMzg1LjUtMTAzLTI3OS41LTI3OS41LTEwMy0zODUuNSAxMDMtMzg1LjUgMjc5LjUtMjc5LjUgMzg1LjUtMTAzIDM4NS41IDEwMyAyNzkuNSAyNzkuNSAxMDMgMzg1LjV6Ii8+PC9zdmc+', methods: [], + location: 'swapPanel', + ...this.profile, hash: `local-${this.profile.name}` } + profile.events = profile.events || [] profile.events = profile.events.filter((item) => { return item !== '' }) if (!profile.location) throw new Error('Plugin should have a location') @@ -95,11 +97,11 @@ module.exports = class LocalPlugin { notificationCheckbox (plugin, event) { const notifications = this.profile.notifications || {} const checkbox = notifications[plugin] && notifications[plugin].includes(event) - ? yo`` - : yo`` + ? yo`` + : yo`` return yo`
${checkbox} - +
` } @@ -120,6 +122,20 @@ module.exports = class LocalPlugin { return yo`` })}` } + const radioLocations = (label, displayN) => { + const radioButton = (this.profile.location === label) + ? yo`
+ +
` + : yo`
+ +
` + return yo`
+ ${radioButton} +
` + } const eventsEl = eventsForm(this.profile.events || []) const pushEvent = () => { if (!this.profile.events) this.profile.events = [] @@ -156,16 +172,9 @@ module.exports = class LocalPlugin {
Location in remix (required)
- -
- -
-
- -
-
- -
+ ${radioLocations('swapPanel', 'Swap Panel')} + ${radioLocations('mainPanel', 'Main Panel')} + ${radioLocations('none', 'None')} ` } } From 3f3eb07df215acf5f58c47688736fa7c0ee68b61 Mon Sep 17 00:00:00 2001 From: Rob Stupay Date: Tue, 14 May 2019 16:19:18 +0200 Subject: [PATCH 2/2] check if plugin name has been used --- src/app/components/local-plugin.js | 3 +-- src/app/components/plugin-manager-component.js | 5 +++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/app/components/local-plugin.js b/src/app/components/local-plugin.js index a5106387e2..5dc71f8e2c 100644 --- a/src/app/components/local-plugin.js +++ b/src/app/components/local-plugin.js @@ -40,8 +40,7 @@ module.exports = class LocalPlugin { ...this.profile, hash: `local-${this.profile.name}` } - profile.events = profile.events || [] - profile.events = profile.events.filter((item) => { return item !== '' }) + profile.events = (profile.events || []).filter(item => item !== '') if (!profile.location) throw new Error('Plugin should have a location') if (!profile.name) throw new Error('Plugin should have a name') diff --git a/src/app/components/plugin-manager-component.js b/src/app/components/plugin-manager-component.js index b904aa1b2e..1c56a81961 100644 --- a/src/app/components/plugin-manager-component.js +++ b/src/app/components/plugin-manager-component.js @@ -4,6 +4,7 @@ const EventEmitter = require('events') const LocalPlugin = require('./local-plugin') import { Plugin, BaseApi } from 'remix-plugin' import { PluginManagerSettings } from './plugin-manager-settings' +const addToolTip = require('../ui/tooltip') const css = csjs` .pluginSearch { @@ -109,11 +110,15 @@ class PluginManagerComponent extends BaseApi { try { const profile = await this.localPlugin.open(this.store.getAll()) if (!profile) return + if (this.store.ids.includes(profile.name)) { + throw new Error('This name has already been used') + } this.appManager.registerOne(new Plugin(profile)) this.appManager.activateOne(profile.name) } catch (err) { // TODO : Use an alert to handle this error instead of a console.log console.log(`Cannot create Plugin : ${err.message}`) + addToolTip(`Cannot create Plugin : ${err.message}`) } }