Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

refactor(ui): update pluginKit refresh method

robinad4771364140
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);
}