ed7a7a5ce0
PR 4 of 4 for configurable dashboard widgets. - Replace hard-coded Jellyfin/Backups dashboard sections with a loop that renders enabled widget instances by sort_order. - Add WidgetInstance renderer and WidgetConfigDialog for adding, editing, enabling/disabling, deleting, and reordering widgets. - Add addon pages for grafana, prometheus, and ssh-tasks at /addons/:addonId. - Register /addons/:addonId route in App.tsx. - Update docs/REQUIREMENTS.md with the widget system design and API. Verification: - backend ruff clean; pytest 200 passed - frontend npm run lint: 0 errors - frontend npm run build: success - frontend npm run test -- src/widgets/registry.test.ts: 3 passed
27 lines
656 B
TypeScript
27 lines
656 B
TypeScript
import { Alert, AlertDescription } from "@/components/ui/alert";
|
|
import { getWidgetDefinition } from "../widgets/registry";
|
|
import type { WidgetInstance } from "../types";
|
|
import { SectionCard } from "./SectionCard";
|
|
|
|
interface Props {
|
|
widget: WidgetInstance;
|
|
}
|
|
|
|
export function WidgetInstance({ widget }: Props) {
|
|
const def = getWidgetDefinition(widget.widget_type);
|
|
if (!def) {
|
|
return (
|
|
<SectionCard title={widget.title}>
|
|
<Alert>
|
|
<AlertDescription>
|
|
Unknown widget type: {widget.widget_type}
|
|
</AlertDescription>
|
|
</Alert>
|
|
</SectionCard>
|
|
);
|
|
}
|
|
|
|
const Component = def.component;
|
|
return <Component widget={widget} />;
|
|
}
|