Barazo default frontend barazo.forum
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat(plugins): add toast notifications for plugin actions (#198)

* fix(plugins): defensive null checks for settingsSchema and dependents

The API may not return settingsSchema or dependents fields. Use
optional chaining and nullish coalescing to prevent Object.keys()
and .length crashes on undefined values.

* feat(plugins): add toast notifications for plugin actions

Show toast confirmations when enabling, disabling, saving settings,
or uninstalling plugins. Uses existing useToast hook matching the
pattern from admin pages.

authored by

Guido X Jansen and committed by
GitHub
fb93d320 6cb673ba

+6
+6
src/hooks/admin/use-plugin-management.ts
··· 9 9 import { getPlugins, togglePlugin, updatePluginSettings, uninstallPlugin } from '@/lib/api/client' 10 10 import type { Plugin } from '@/lib/api/types' 11 11 import { useAuth } from '@/hooks/use-auth' 12 + import { useToast } from '@/hooks/use-toast' 12 13 import { useSaveState } from '@/hooks/use-save-state' 13 14 14 15 interface DependencyWarning { ··· 18 19 19 20 export function usePluginManagement() { 20 21 const { getAccessToken } = useAuth() 22 + const { toast } = useToast() 21 23 const settingsSave = useSaveState() 22 24 const [plugins, setPlugins] = useState<Plugin[]>([]) 23 25 const [loading, setLoading] = useState(true) ··· 62 64 setPlugins((prev) => 63 65 prev.map((p) => (p.id === plugin.id ? { ...p, enabled: !p.enabled } : p)) 64 66 ) 67 + toast({ title: `${plugin.displayName} ${plugin.enabled ? 'disabled' : 'enabled'}` }) 65 68 } catch { 66 69 setActionError(`Failed to ${plugin.enabled ? 'disable' : 'enable'} plugin. Please try again.`) 67 70 } ··· 75 78 setPlugins((prev) => 76 79 prev.map((p) => (p.id === dependencyWarning.plugin.id ? { ...p, enabled: false } : p)) 77 80 ) 81 + toast({ title: `${dependencyWarning.plugin.displayName} disabled` }) 78 82 } catch { 79 83 setActionError('Failed to disable plugin. Please try again.') 80 84 } ··· 89 93 await updatePluginSettings(settingsPlugin.id, settings, getAccessToken() ?? '') 90 94 setPlugins((prev) => prev.map((p) => (p.id === settingsPlugin.id ? { ...p, settings } : p))) 91 95 settingsSave.reset() 96 + toast({ title: `${settingsPlugin.displayName} settings saved` }) 92 97 } catch { 93 98 settingsSave.reset() 94 99 setActionError('Failed to save plugin settings. Please try again.') ··· 101 106 try { 102 107 await uninstallPlugin(plugin.id, getAccessToken() ?? '') 103 108 setPlugins((prev) => prev.filter((p) => p.id !== plugin.id)) 109 + toast({ title: `${plugin.displayName} uninstalled` }) 104 110 } catch { 105 111 setActionError('Failed to uninstall plugin. Please try again.') 106 112 }