Commit 3f3eb07d authored by Rob Stupay's avatar Rob Stupay

check if plugin name has been used

parent 58cfe7c7
...@@ -40,8 +40,7 @@ module.exports = class LocalPlugin { ...@@ -40,8 +40,7 @@ module.exports = class LocalPlugin {
...this.profile, ...this.profile,
hash: `local-${this.profile.name}` hash: `local-${this.profile.name}`
} }
profile.events = profile.events || [] profile.events = (profile.events || []).filter(item => item !== '')
profile.events = profile.events.filter((item) => { return item !== '' })
if (!profile.location) throw new Error('Plugin should have a location') if (!profile.location) throw new Error('Plugin should have a location')
if (!profile.name) throw new Error('Plugin should have a name') if (!profile.name) throw new Error('Plugin should have a name')
......
...@@ -4,6 +4,7 @@ const EventEmitter = require('events') ...@@ -4,6 +4,7 @@ const EventEmitter = require('events')
const LocalPlugin = require('./local-plugin') const LocalPlugin = require('./local-plugin')
import { Plugin, BaseApi } from 'remix-plugin' import { Plugin, BaseApi } from 'remix-plugin'
import { PluginManagerSettings } from './plugin-manager-settings' import { PluginManagerSettings } from './plugin-manager-settings'
const addToolTip = require('../ui/tooltip')
const css = csjs` const css = csjs`
.pluginSearch { .pluginSearch {
...@@ -109,11 +110,15 @@ class PluginManagerComponent extends BaseApi { ...@@ -109,11 +110,15 @@ class PluginManagerComponent extends BaseApi {
try { try {
const profile = await this.localPlugin.open(this.store.getAll()) const profile = await this.localPlugin.open(this.store.getAll())
if (!profile) return 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.registerOne(new Plugin(profile))
this.appManager.activateOne(profile.name) this.appManager.activateOne(profile.name)
} catch (err) { } catch (err) {
// TODO : Use an alert to handle this error instead of a console.log // TODO : Use an alert to handle this error instead of a console.log
console.log(`Cannot create Plugin : ${err.message}`) console.log(`Cannot create Plugin : ${err.message}`)
addToolTip(`Cannot create Plugin : ${err.message}`)
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment