diff --git a/packages/client/src/helpers/plugins/components/Plugin.js b/packages/client/src/helpers/plugins/components/Plugin.js index 391df5d697..30e8dfc4fa 100644 --- a/packages/client/src/helpers/plugins/components/Plugin.js +++ b/packages/client/src/helpers/plugins/components/Plugin.js @@ -80,7 +80,7 @@ const Plugin = ({ pluginSettings.type === PluginSettingsType.settingsPage); const showModalPluginSettings = - withSettings && pluginSettings && !showPluginSettingsPage; + withSettings && pluginSettings?.type && !showPluginSettingsPage; return ( diff --git a/packages/client/src/helpers/plugins/components/PluginInfo.js b/packages/client/src/helpers/plugins/components/PluginInfo.js index 699623088c..3c554b2ef9 100644 --- a/packages/client/src/helpers/plugins/components/PluginInfo.js +++ b/packages/client/src/helpers/plugins/components/PluginInfo.js @@ -66,7 +66,7 @@ const PluginInfo = ({ return ( - + {image ? :
}
Version {version} diff --git a/packages/client/src/store/PluginStore.js b/packages/client/src/store/PluginStore.js index 87cae6b4ca..3b9e6f284a 100644 --- a/packages/client/src/store/PluginStore.js +++ b/packages/client/src/store/PluginStore.js @@ -107,7 +107,9 @@ class PluginStore { this.plugins = []; - const plugins = await api.plugins.getPlugins(!isAdmin && !isOwner); + const plugins = await api.plugins.getPlugins( + !isAdmin && !isOwner ? true : null + ); plugins.forEach((plugin) => this.initPlugin(plugin)); }; @@ -157,7 +159,7 @@ class PluginStore { this.plugins.push(plugin); } - if (plugin.enabled) { + if (plugin.enabled && plugin.onLoadCallback) { plugin.onLoadCallback(); } @@ -165,13 +167,23 @@ class PluginStore { plugin.setAPI(origin, proxy, prefix); } - if (plugin && plugin.contextMenuItems && plugin.enabled) { + if ( + plugin && + plugin.scopes.includes(PluginScopes.ContextMenu) && + plugin.contextMenuItems && + plugin.enabled + ) { Array.from(plugin.contextMenuItems).map(([key, value]) => { this.contextMenuItems.set(key, value); }); } - if (plugin && plugin.infoPanelItems && plugin.enabled) { + if ( + plugin && + plugin.scopes.includes(PluginScopes.InfoPanel) && + plugin.infoPanelItems && + plugin.enabled + ) { Array.from(plugin.infoPanelItems).map(([key, value]) => { this.infoPanelItems.set(key, value); }); @@ -191,13 +203,21 @@ class PluginStore { plugin.enabled = false; - if (plugin && plugin.contextMenuItems) { + if ( + plugin && + plugin.scopes.includes(PluginScopes.ContextMenu) && + plugin.contextMenuItems + ) { Array.from(plugin.contextMenuItems).map(([key, value]) => { this.contextMenuItems.delete(key); }); } - if (plugin && plugin.infoPanelItems) { + if ( + plugin && + plugin.scopes.includes(PluginScopes.InfoPanel) && + plugin.infoPanelItems + ) { Array.from(plugin.infoPanelItems).map(([key, value]) => { this.infoPanelItems.delete(key); }); diff --git a/packages/common/api/plugins/index.js b/packages/common/api/plugins/index.js index 09a27c0def..c93467d9d0 100644 --- a/packages/common/api/plugins/index.js +++ b/packages/common/api/plugins/index.js @@ -1,9 +1,13 @@ import { request } from "../client"; export const getPlugins = async (enabled) => { + const url = enabled + ? `/settings/webplugins?enabled=${enabled}` + : `/settings/webplugins`; + return request({ method: "GET", - url: `/settings/webplugins?enabled=${enabled}`, + url, }); };