From 2bfdd76180be7da60d90461d503d6d347dd1fda0 Mon Sep 17 00:00:00 2001 From: oplik0 Date: Sat, 15 Apr 2023 01:17:11 +0200 Subject: [PATCH] feat: show even uninstalled active plugins if set via config --- src/controllers/admin/plugins.js | 4 ++-- src/plugins/index.js | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/controllers/admin/plugins.js b/src/controllers/admin/plugins.js index a0b7457f01..62743e00a3 100644 --- a/src/controllers/admin/plugins.js +++ b/src/controllers/admin/plugins.js @@ -15,8 +15,8 @@ pluginsController.get = async function (req, res) { ]); const compatiblePkgNames = compatible.map(pkgData => pkgData.name); - const installedPlugins = compatible.filter(plugin => plugin && plugin.installed); - const activePlugins = all.filter(plugin => plugin && plugin.installed && plugin.active); + const installedPlugins = compatible.filter(plugin => plugin && (plugin.installed || (nconf.get('plugins:active') && plugin.active))); + const activePlugins = all.filter(plugin => plugin && (plugin.installed || nconf.get('plugins:active')) && plugin.active); const trendingScores = trending.reduce((memo, cur) => { memo[cur.label] = cur.value; diff --git a/src/plugins/index.js b/src/plugins/index.js index 3587dc091c..f573202450 100644 --- a/src/plugins/index.js +++ b/src/plugins/index.js @@ -234,6 +234,13 @@ Plugins.normalise = async function (apiReturn) { pluginMap[plugin.id].outdated = semver.gt(pluginMap[plugin.id].latest, pluginMap[plugin.id].version); }); + if (nconf.get('plugins:active')) { + nconf.get('plugins:active').forEach((id) => { + pluginMap[id] = pluginMap[id] || {}; + pluginMap[id].active = true; + }); + } + const pluginArray = Object.values(pluginMap); pluginArray.sort((a, b) => {