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:
@@ -24,6 +24,74 @@ class FieldDefinition(BaseModel):
|
||||
sensitivity: str = Field(default="normal", description="normal|sensitive|critical")
|
||||
|
||||
|
||||
# ── Frontend UI definition models (Phase 3) ──────────────────────────────────
|
||||
|
||||
|
||||
class FrontendMenuItem(BaseModel):
|
||||
"""A sidebar navigation item contributed by a plugin."""
|
||||
|
||||
label_key: str = Field(..., description="i18n key for the menu label")
|
||||
label: str = Field(default="", description="Fallback label if i18n key is missing")
|
||||
path: str = Field(..., description="Frontend route path, e.g. /mail")
|
||||
icon: str = Field(default="FileText", description="lucide-react icon name")
|
||||
group: str = Field(default="", description="Optional group label_key for tree-style nesting")
|
||||
order: int = Field(default=100, description="Sort order within the sidebar")
|
||||
badge_key: str = Field(default="", description="Optional store key for badge count")
|
||||
|
||||
|
||||
class FrontendPageRoute(BaseModel):
|
||||
"""A frontend page route contributed by a plugin."""
|
||||
|
||||
path: str = Field(..., description="Frontend route path, e.g. /mail or /mail/settings")
|
||||
component: str = Field(
|
||||
..., description="Dotted path to the React component, e.g. @/pages/Mail"
|
||||
)
|
||||
parent: str = Field(
|
||||
default="",
|
||||
description="Parent route path for nested routes (e.g. /settings for a settings sub-page)",
|
||||
)
|
||||
protected: bool = Field(default=True, description="Whether the route requires authentication")
|
||||
order: int = Field(default=100, description="Sort order")
|
||||
|
||||
|
||||
class FrontendDetailTab(BaseModel):
|
||||
"""A detail tab contributed by a plugin for entity detail views."""
|
||||
|
||||
entity_type: str = Field(..., description="Entity type this tab applies to, e.g. 'contact'")
|
||||
label_key: str = Field(..., description="i18n key for the tab label")
|
||||
label: str = Field(default="", description="Fallback label")
|
||||
component: str = Field(..., description="Dotted path to the React component")
|
||||
icon: str = Field(default="FileText", description="lucide-react icon name")
|
||||
order: int = Field(default=100, description="Sort order within the detail view")
|
||||
permission: str = Field(default="", description="Optional permission required to see this tab")
|
||||
|
||||
|
||||
class FrontendSettingsPage(BaseModel):
|
||||
"""A settings sub-page contributed by a plugin."""
|
||||
|
||||
path: str = Field(..., description="Settings sub-route path, e.g. mail or notifications")
|
||||
label_key: str = Field(..., description="i18n key for the settings nav label")
|
||||
label: str = Field(default="", description="Fallback label")
|
||||
component: str = Field(..., description="Dotted path to the React component")
|
||||
icon: str = Field(default="Settings", description="lucide-react icon name")
|
||||
order: int = Field(default=100, description="Sort order within settings nav")
|
||||
permission: str = Field(default="", description="Optional permission required")
|
||||
|
||||
|
||||
class FrontendDashboardWidget(BaseModel):
|
||||
"""A dashboard widget contributed by a plugin."""
|
||||
|
||||
id: str = Field(..., description="Unique widget identifier")
|
||||
label_key: str = Field(..., description="i18n key for the widget title")
|
||||
label: str = Field(default="", description="Fallback label")
|
||||
component: str = Field(..., description="Dotted path to the React component")
|
||||
icon: str = Field(default="LayoutDashboard", description="lucide-react icon name")
|
||||
order: int = Field(default=100, description="Sort order on the dashboard")
|
||||
col_span: int = Field(default=1, description="Grid column span (1-4)")
|
||||
row_span: int = Field(default=1, description="Grid row span")
|
||||
permission: str = Field(default="", description="Optional permission required")
|
||||
|
||||
|
||||
class PluginManifest(BaseModel):
|
||||
"""Manifest describing a plugin's metadata, dependencies, and capabilities."""
|
||||
|
||||
@@ -58,6 +126,22 @@ class PluginManifest(BaseModel):
|
||||
default_factory=list,
|
||||
description="AI agent capabilities this plugin provides (e.g. 'contact_search', 'email_draft')",
|
||||
)
|
||||
# ── Frontend UI contributions (Phase 3) ──
|
||||
menu_items: list[FrontendMenuItem] = Field(
|
||||
default_factory=list, description="Sidebar navigation items contributed by this plugin"
|
||||
)
|
||||
page_routes: list[FrontendPageRoute] = Field(
|
||||
default_factory=list, description="Frontend page routes contributed by this plugin"
|
||||
)
|
||||
detail_tabs: list[FrontendDetailTab] = Field(
|
||||
default_factory=list, description="Entity detail tabs contributed by this plugin"
|
||||
)
|
||||
settings_pages: list[FrontendSettingsPage] = Field(
|
||||
default_factory=list, description="Settings sub-pages contributed by this plugin"
|
||||
)
|
||||
dashboard_widgets: list[FrontendDashboardWidget] = Field(
|
||||
default_factory=list, description="Dashboard widgets contributed by this plugin"
|
||||
)
|
||||
|
||||
@field_validator("name")
|
||||
@classmethod
|
||||
@@ -120,6 +204,31 @@ MANIFEST_SCHEMA_DOC = ManifestSchemaResponse(
|
||||
"required": "false",
|
||||
"description": "Required permissions",
|
||||
},
|
||||
"menu_items": {
|
||||
"type": "list[FrontendMenuItem]",
|
||||
"required": "false",
|
||||
"description": "Sidebar navigation items (label_key, path, icon, group, order)",
|
||||
},
|
||||
"page_routes": {
|
||||
"type": "list[FrontendPageRoute]",
|
||||
"required": "false",
|
||||
"description": "Frontend page routes (path, component, parent, protected)",
|
||||
},
|
||||
"detail_tabs": {
|
||||
"type": "list[FrontendDetailTab]",
|
||||
"required": "false",
|
||||
"description": "Entity detail tabs (entity_type, label_key, component, icon, permission)",
|
||||
},
|
||||
"settings_pages": {
|
||||
"type": "list[FrontendSettingsPage]",
|
||||
"required": "false",
|
||||
"description": "Settings sub-pages (path, label_key, component, icon, permission)",
|
||||
},
|
||||
"dashboard_widgets": {
|
||||
"type": "list[FrontendDashboardWidget]",
|
||||
"required": "false",
|
||||
"description": "Dashboard widgets (id, label_key, component, col_span, permission)",
|
||||
},
|
||||
},
|
||||
example=PluginManifest(
|
||||
name="example_plugin",
|
||||
@@ -131,5 +240,21 @@ MANIFEST_SCHEMA_DOC = ManifestSchemaResponse(
|
||||
events=["contact.created"],
|
||||
migrations=["0001_initial.sql"],
|
||||
permissions=["contacts.read"],
|
||||
menu_items=[
|
||||
FrontendMenuItem(
|
||||
label_key="nav.examplePlugin",
|
||||
label="Example",
|
||||
path="/example",
|
||||
icon="Sparkles",
|
||||
order=50,
|
||||
)
|
||||
],
|
||||
page_routes=[
|
||||
FrontendPageRoute(
|
||||
path="/example",
|
||||
component="@/pages/Example",
|
||||
protected=True,
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user