fc96a2f86c
Backend: - PluginManifest um 5 neue UI-Felder erweitert: menu_items, page_routes, detail_tabs, settings_pages, dashboard_widgets (FrontendMenuItem, FrontendPageRoute, FrontendDetailTab, FrontendSettingsPage, FrontendDashboardWidget) - GET /api/v1/plugins/active-manifests Endpoint liefert UI-Manifeste aller aktiven Plugins - Registry.get_active_manifests() + PluginService.get_active_manifests() - 12 Built-in Plugins mit UI-Manifest-Daten gefuellt (menu_items, page_routes, detail_tabs, settings_pages) - Plugin-Install-System: POST /upload (ZIP), POST /install-url (URL) mit Validierung (Manifest, dangerous imports, SQL migrations) Frontend: - pluginStore.ts (Zustand) mit PluginUiManifest Typen + Selektoren - useActivePluginManifests() React Query Hook - PluginRegistry.tsx — fetcht Manifeste beim App-Start - PluginLoader.tsx — dynamisches React.lazy() mit ErrorBoundary - PluginRouteRenderer.tsx — Catch-all fuer Plugin-Routes - routes/index.tsx — Catch-all Routes fuer Plugin-Pages + Settings - Sidebar.tsx — dynamische Plugin Menu-Items mit Grouping + Icons - Settings.tsx — dynamische Plugin Settings-Pages - ContactDetail.tsx — dynamische Plugin Detail-Tabs mit Permissions - AppShell.tsx — PluginRegistry Provider eingebunden - SettingsPlugins.tsx — Install-UI (ZIP Upload + URL Install) - plugins.ts — useUploadPlugin() + useInstallPluginFromUrl() Hooks Docs & Templates: - docs/plugin-development-guide.md — komplette Entwickler-Doku - templates/plugin-template/ — Boilerplate mit allen Manifest-Feldern Tests: - 34 Vitest-Tests (PluginRegistry, PluginLoader, PluginRouteRenderer, pluginStore) — alle bestanden - TSC: keine neuen Errors (nur pre-existing Dms.tsx)
36 lines
1.0 KiB
TypeScript
36 lines
1.0 KiB
TypeScript
import { useEffect } from 'react';
|
|
import { useActivePluginManifests } from '@/api/pluginManifests';
|
|
import { usePluginStore } from '@/store/pluginStore';
|
|
|
|
/**
|
|
* PluginRegistry — invisible provider component that fetches active plugin
|
|
* UI manifests on mount and populates the plugin store.
|
|
*
|
|
* Must be placed inside AppShell or at the root of the protected route tree.
|
|
*/
|
|
export function PluginRegistry() {
|
|
const { data, isLoading, error } = useActivePluginManifests();
|
|
const setManifests = usePluginStore((s) => s.setManifests);
|
|
const setLoading = usePluginStore((s) => s.setLoading);
|
|
const setError = usePluginStore((s) => s.setError);
|
|
|
|
useEffect(() => {
|
|
setLoading(isLoading);
|
|
}, [isLoading, setLoading]);
|
|
|
|
useEffect(() => {
|
|
if (data?.plugins) {
|
|
setManifests(data.plugins);
|
|
}
|
|
}, [data, setManifests]);
|
|
|
|
useEffect(() => {
|
|
if (error) {
|
|
setError(error instanceof Error ? error.message : 'Failed to load plugin manifests');
|
|
}
|
|
}, [error, setError]);
|
|
|
|
// This component renders nothing visible
|
|
return null;
|
|
}
|