Files
leocrm/app/core/system_miniapps.py
Agent Zero 3c496f4b6a
Check Cross-Plugin Imports / check (push) Has been cancelled
feat(M4): System-Rueckbau — Dashboard-Inhalte als MiniApps, Core = reiner Host (#362)
- system_miniapps.py: audit_activity (audit:read, settings max_items) + system_metrics (settings:read) als Core-Apps in Registry
- base.py-Fix: native Manifest-MiniApps reichen component durch (M1-Luecke)
- contacts-Manifest: contacts_stats (ContactsStatsWidget, contacts:read, show_companies/show_persons)
- Seed-Fix: nur renderbare Apps (component) landen im Dashboard-Layout
- Frontend: ContactsStatsWidget, AuditActivityWidget, SystemMetricsWidget; MiniAppHost-Registry +3
- Dashboard.tsx = reiner Host (26 Z.); Page-Tests auf Pure-Host umgeschrieben
- Tests: M4 7/7 (TDD rot->gruen), Backend-Regression 46/46, Vitest 22/22, tsc clean, build OK
2026-08-30 22:22:20 +02:00

64 lines
2.1 KiB
Python

"""Core-owned system MiniApps (Phase M4).
Host-level MiniApps that are not owned by a single plugin: audit activity
feed and system metrics. They register in the universal registry with
``plugin_name="system"`` at app startup and unregister with the registry
reset (tests) — they never depend on plugin activation state.
Permissions follow the owning data source:
- audit_activity -> audit:read (audit log route guard, CORE_PERMISSIONS)
- system_metrics -> settings:read (Roadmap M4; the /system/dashboard
endpoint itself stays require_admin — the widget degrades gracefully
with a permission hint for non-admins)
"""
from __future__ import annotations
from app.plugins.miniapp_registry import get_miniapp_registry
SYSTEM_PLUGIN_NAME = "system"
def register_system_miniapps() -> None:
"""Register the core system MiniApps in the universal registry."""
registry = get_miniapp_registry()
registry.register(
app_id="audit_activity",
name="Aktivitäten",
icon="History",
description="Letzte Aktivitäten aus dem Audit-Log (Benutzer, Aktion, Zeitpunkt).",
plugin_name=SYSTEM_PLUGIN_NAME,
permission="audit:read",
settings_schema={
"fields": [
{
"name": "max_items",
"label": "Max. Einträge",
"type": "number",
"default": 10,
}
]
},
col_span=2,
row_span=1,
hosts=["chat", "dashboard", "window"],
component="@/components/dashboard/AuditActivityWidget",
order=40,
)
registry.register(
app_id="system_metrics",
name="System Status",
icon="Server",
description="Datenbank-, Redis-, Worker- und API-Metriken (Administration).",
plugin_name=SYSTEM_PLUGIN_NAME,
permission="settings:read",
settings_schema={},
col_span=2,
row_span=1,
hosts=["chat", "dashboard", "window"],
component="@/components/dashboard/SystemMetricsWidget",
order=50,
)