diff --git a/panel/src/config/plugins.js b/panel/src/config/plugins.js index 220f4d3935..a8e72c04ef 100644 --- a/panel/src/config/plugins.js +++ b/panel/src/config/plugins.js @@ -1,72 +1,11 @@ -import store from "@/store/store.js"; -import section from "../mixins/section.js"; +import Plugins from "@/panel/plugins.js"; export default { install(app) { - const components = { ...app.options.components }; - - const mixins = { - section: section - }; - - /** - * Components - */ - for (const [name, options] of Object.entries( - window.panel.plugins.components - )) { - // make sure component has something to show - if (!options.template && !options.render && !options.extends) { - store.dispatch( - "notification/error", - `Neither template or render method provided nor extending a component when loading plugin component "${name}". The component has not been registered.` - ); - continue; - } - - // resolve extending via component name - if (typeof options?.extends === "string") { - // only extend if referenced component exists - if (components[options.extends]) { - options.extends = components[options.extends].extend({ - options, - components: { - ...components, - ...(options.components || {}) - } - }); - } else { - // if component doesn't exist, don't extend - window.console.warn( - `Problem with plugin trying to register component "${name}": cannot extend non-existent component "${options.extends}"` - ); - options.extends = null; - } - } - - if (options.template) { - options.render = null; - } - - if (options.mixins) { - options.mixins = options.mixins.map((mixin) => - typeof mixin === "string" ? mixins[mixin] : mixin - ); - } - - if (components[name]) { - window.console.warn(`Plugin is replacing "${name}"`); - } - - app.component(name, options); - components[name] = app.options.components[name]; - } - /** - * `Vue.use` + * Temporary polyfill until this is all + * bundled under window.panel */ - for (const plugin of window.panel.plugins.use) { - app.use(plugin); - } + window.panel.plugins = Plugins(app, window.panel.plugins); } }; diff --git a/panel/src/panel/plugins.js b/panel/src/panel/plugins.js index 8ecac9018b..5990bb8c94 100644 --- a/panel/src/panel/plugins.js +++ b/panel/src/panel/plugins.js @@ -144,6 +144,11 @@ export const installPlugins = (app, plugins) => { return plugins; }; +/** + * The plugin module installs all + * given plugins and makes them accessible + * at window.panel.plugins + */ export default (app, plugins = {}) => { plugins = { components: {},