یہ صفحہ ابھی اردو میں دستیاب نہیں، اس لیے انگریزی میں دکھایا جا رہا ہے۔
Widget kinds, HTML sanitising and the dashboard filter
The four data kinds, tones and links, which HTML survives, and how the dashboard.widgets filter hides widgets per user.
| Kind | Shape |
|---|---|
stat | items[{ label, value, hint?, tone?, href? }], up to 8 |
list | items[{ title, subtitle?, meta?, tone?, href? }], up to 20, plus empty? |
text | text |
html | html — sanitised: only b i strong em u s p br ul ol li code span small a[href] survive |
Every kind accepts href + linkLabel for the card header link. tone is good, warn or bad. Return null to render nothing.
import { defineWidget } from "@/lib/plugins/sdk";
export const summary = defineWidget(async (ctx) => ({
kind: "stat",
href: "/admin/site-visits",
linkLabel: "Open",
items: [
{ label: "Planned", value: 4, href: "/admin/site-visits?status=PLANNED" },
{ label: "Today", value: 1, tone: "warn" },
{ label: "Done this month", value: 12, tone: "good", hint: "12 of 15" },
],
}));Hiding widgets per user
The dashboard.widgets filter receives the widget ids (catalogue order) with { userId, may } and may remove ids to hide widgets for that user. Adding ids is not supported yet — the page resolves the layout before the filter runs.
filters: {
"dashboard.widgets": async (ids, ctx) => (ctx.may("invoices.view") ? ids : ids.filter((id) => !id.startsWith("plugin:site-visits:"))),
},Written from: docs/PLUGIN-DEVELOPER-GUIDE.md, src/lib/plugins/types.ts, src/lib/plugins/widget-html.ts, src/lib/plugins/filters.ts, src/lib/plugins/sdk.ts