check if plugin name has been used

pull/1/head
Rob Stupay 6 years ago
parent 58cfe7c7cb
commit 3f3eb07df2
  1. 3
      src/app/components/local-plugin.js
  2. 5
      src/app/components/plugin-manager-component.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')

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

Loading…
Cancel
Save