Phase 3: Plugin-UI-System (WordPress-Style)
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)
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
# Plugin Template
|
||||
|
||||
A minimal plugin template for LeoCRM. Copy this directory to `app/plugins/builtins/<your_plugin_name>/` and customize.
|
||||
|
||||
## Quick Start
|
||||
|
||||
1. **Copy the template:**
|
||||
```bash
|
||||
cp -r templates/plugin-template app/plugins/builtins/my_plugin
|
||||
```
|
||||
|
||||
2. **Rename the plugin class:**
|
||||
Edit `plugin.py` and rename `ExamplePlugin` to your plugin name.
|
||||
|
||||
3. **Update the manifest:**
|
||||
- Change `name`, `version`, `display_name`, `description`
|
||||
- Add your routes, events, migrations, permissions
|
||||
- Add UI contributions (menu items, page routes, etc.)
|
||||
|
||||
4. **Implement routes:**
|
||||
Edit `routes.py` with your API endpoints.
|
||||
|
||||
5. **Add database models:**
|
||||
Uncomment and customize `models.py`.
|
||||
|
||||
6. **Write migrations:**
|
||||
Add SQL migration files to `migrations/`.
|
||||
|
||||
7. **Write tests:**
|
||||
Add tests to `tests/test_plugin.py`.
|
||||
|
||||
## Directory Structure
|
||||
|
||||
```
|
||||
templates/plugin-template/
|
||||
├── __init__.py # Package init
|
||||
├── plugin.py # Plugin class with manifest (required)
|
||||
├── routes.py # FastAPI route definitions
|
||||
├── models.py # SQLAlchemy models (optional, commented out)
|
||||
├── schemas.py # Pydantic schemas (optional)
|
||||
├── services.py # Business logic (optional)
|
||||
├── migrations/ # SQL migration files
|
||||
│ └── 0001_initial.sql
|
||||
├── tests/ # Plugin tests
|
||||
│ ├── __init__.py
|
||||
│ └── test_plugin.py
|
||||
└── README.md # This file
|
||||
```
|
||||
|
||||
## Manifest Fields
|
||||
|
||||
See `docs/plugin-development-guide.md` for a complete reference of all manifest fields.
|
||||
|
||||
## Key Points
|
||||
|
||||
- All API routes must be secured with `require_permission`
|
||||
- Event handlers are named `on_<event_name>` with dots replaced by underscores
|
||||
- Migration files run in alphanumeric order
|
||||
- UI component paths use the `@/` alias (resolved to `src/` by Vite)
|
||||
- i18n keys should be prefixed with the plugin name
|
||||
Reference in New Issue
Block a user