Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(dashboard): reload the plugin catalog after an upload or uninstall

Yudhi Armyndharis33aae669b41a
diff --git a/dashboard/src/pages/Plugins.test.ts b/dashboard/src/pages/Plugins.test.ts
index a45349be3..4cd4e3a26 100644
--- a/dashboard/src/pages/Plugins.test.ts
+++ b/dashboard/src/pages/Plugins.test.ts
@@ -205,3 +205,18 @@ test('a catalog prefetch that fails after the Catalog tab opened shows the error
assert.ok(rtl.within(message).getByRole('button', { name: 'Refresh' }));
assert.equal(screen.queryByText('No plugins in the catalog.'), null);
});
+
+test('uninstalling a plugin reloads the catalog, whose installed flags it changed', async () => {
+ const { screen, fireEvent, waitFor } = rtl;
+ const realConfirm = window.confirm;
+ window.confirm = () => true;
+ try {
+ renderPlugins();
+ await waitFor(() => assert.equal(catalogReads, 1));
+ fireEvent.click(await screen.findByTitle('Uninstall'));
+ await screen.findByText('Plugin uninstalled');
+ await waitFor(() => assert.equal(catalogReads, 2));
+ } finally {
+ window.confirm = realConfirm;
+ }
+});
diff --git a/dashboard/src/pages/Plugins.tsx b/dashboard/src/pages/Plugins.tsx
index 983fdd379..8c8860ff0 100644
--- a/dashboard/src/pages/Plugins.tsx
+++ b/dashboard/src/pages/Plugins.tsx
@@ -725,6 +725,8 @@ export default function Plugins() {
try {
const installed = await pluginsApi.install(installFile);
refetchAll();
+ // The catalog's installed and update flags are computed per request, so they changed too.
+ void loadCatalog();
toast.success(t('plugins.toasts.installed', 'Plugin installed'), installed.name);
setShowInstallModal(false);
setInstallFile(null);
@@ -821,6 +823,7 @@ export default function Plugins() {
try {
await pluginsApi.uninstall(plugin.id);
refetchAll();
+ void loadCatalog();
toast.success(t('plugins.toasts.uninstalled', 'Plugin uninstalled'), localizePlugin(plugin, i18n.language).name);
} catch (err) {
toast.error(t('plugins.toasts.uninstallFailed', 'Uninstall failed'), err instanceof Error ? err.message : '');