This is an automated email from the ASF dual-hosted git repository. robin0716 pushed a commit to branch dev in repository https://gitbox.apache.org/repos/asf/incubator-answer.git
commit ad4771364140679dde67670602db6d735544b879 Author: robin <[email protected]> AuthorDate: Fri Oct 11 11:21:29 2024 +0800 refactor(ui): update pluginKit refresh method --- ui/src/pages/Admin/Plugins/Installed/index.tsx | 2 +- ui/src/utils/pluginKit/index.ts | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/ui/src/pages/Admin/Plugins/Installed/index.tsx b/ui/src/pages/Admin/Plugins/Installed/index.tsx index 82e0618b..868b827a 100644 --- a/ui/src/pages/Admin/Plugins/Installed/index.tsx +++ b/ui/src/pages/Admin/Plugins/Installed/index.tsx @@ -66,7 +66,7 @@ const Users: FC = () => { plugin_slug_name: plugin.slug_name, }).then(() => { updatePlugins(); - PluginKit.changePluginActiveStatus(plugin.slug_name, !plugin.enabled); + PluginKit.refresh(); if (plugin.have_config) { emitPluginChange('refreshConfigurablePlugins'); } diff --git a/ui/src/utils/pluginKit/index.ts b/ui/src/utils/pluginKit/index.ts index 8e19d881..f53fdb4c 100644 --- a/ui/src/utils/pluginKit/index.ts +++ b/ui/src/utils/pluginKit/index.ts @@ -48,6 +48,10 @@ class Plugins { registeredPlugins: Type.ActivatedPlugin[] = []; constructor() { + this.init(); + } + + init() { this.registerBuiltin(); getPluginsStatus().then((plugins) => { @@ -56,6 +60,11 @@ class Plugins { }); } + refresh() { + this.plugins = []; + this.init(); + } + validate(plugin: Plugin) { if (!plugin) { return false; @@ -123,13 +132,6 @@ class Plugins { }); } - changePluginActiveStatus(slug_name: string, active: boolean) { - const plugin = this.getPlugin(slug_name); - if (plugin) { - plugin.activated = active; - } - } - getPlugin(slug_name: string) { return this.plugins.find((p) => p.info.slug_name === slug_name); }
