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}`) } }