diff --git a/src/core/Core.js b/src/core/Core.js index 016e31be1..ad85d13a9 100644 --- a/src/core/Core.js +++ b/src/core/Core.js @@ -240,7 +240,7 @@ export default class Core { use (Plugin, opts) { // Instantiate const plugin = new Plugin(this, opts) - const pluginName = Utils.getFnName(plugin.constructor) + const pluginName = plugin.id this.plugins[plugin.type] = this.plugins[plugin.type] || [] if (!pluginName) { @@ -254,7 +254,7 @@ export default class Core { let existsPluginAlready = this.getPlugin(pluginName) if (existsPluginAlready) { let msg = `Already found a plugin named '${existsPluginAlready.name}'. - Tried to use: '${plugin.constructor.name}'. + Tried to use: '${pluginName}'. Uppy is currently limited to running one of every plugin. Share your use case with us over at https://github.com/transloadit/uppy/issues/ @@ -275,7 +275,7 @@ export default class Core { getPlugin (name) { let foundPlugin = false this.iteratePlugins((plugin) => { - const pluginName = Utils.getFnName(plugin.constructor) + const pluginName = plugin.id if (pluginName === name) { foundPlugin = plugin return false diff --git a/src/plugins/Dummy.js b/src/plugins/Dummy.js index 8355bc853..c0c7a7c48 100644 --- a/src/plugins/Dummy.js +++ b/src/plugins/Dummy.js @@ -26,7 +26,6 @@ export default class Dummy extends Plugin { return yo`
- I am a dummy plugin, look at me, I was rendered in a modal! That’s crazy, I know. ${this.strange} ${bla}
@@ -40,6 +39,6 @@ export default class Dummy extends Plugin { install () { this.el = this.render() - this.target = this.getTarget(this.opts.target, this, this.el, this.render.bind(this)) + this.target = this.getTarget(this.opts.target, this, this.el, this.render) } } diff --git a/src/plugins/Modal.js b/src/plugins/Modal.js index 964e19d53..b35c89a63 100644 --- a/src/plugins/Modal.js +++ b/src/plugins/Modal.js @@ -32,7 +32,7 @@ export default class Modal extends Plugin { addTarget (callerPlugin, render) { const callerPluginId = callerPlugin.constructor.name - const callerPluginName = callerPlugin.name || callerPluginId + const callerPluginName = callerPlugin.title || callerPluginId const callerPluginIcon = callerPlugin.icon || this.opts.defaultTabIcon const callerPluginType = callerPlugin.type diff --git a/src/plugins/Plugin.js b/src/plugins/Plugin.js index b03bbf2e5..a1bea2e68 100644 --- a/src/plugins/Plugin.js +++ b/src/plugins/Plugin.js @@ -1,5 +1,4 @@ import yo from 'yo-yo' -import Utils from '../core/Utils' /** * Boilerplate that all Plugins share - and should not be used @@ -37,7 +36,7 @@ export default class Plugin { * */ getTarget (target, caller, el, render) { - const callerPluginName = Utils.getFnName(caller.constructor) + const callerPluginName = caller.id if (typeof target === 'string') { this.core.log(`Installing ${callerPluginName} to ${target}`) @@ -50,7 +49,9 @@ export default class Plugin { return target } else { - const targetPluginName = Utils.getFnName(target) + // TODO: is this the way to roll just to get the plugin name? + const Target = target + const targetPluginName = new Target().id this.core.log(`Installing ${callerPluginName} to ${targetPluginName}`) let targetPlugin = this.core.getPlugin(targetPluginName) let selectorTarget = targetPlugin.addTarget(caller, render)