@@ -42,6 +42,13 @@ def read_cls_docstring(cls):
4242
4343def get_versions ():
4444 return [
45+ {
46+ "version" : "0.4.2" ,
47+ "changes" : [
48+ "Replace DashboardWidgetAdmin with widget_action decorator. (no backward compatibility)" ,
49+ "Fix mobile view." ,
50+ ],
51+ },
4552 {
4653 "version" : "0.4.1" ,
4754 "changes" : [
@@ -372,8 +379,6 @@ def get_sections():
372379
373380
374381def get_page_context (page_url ):
375- from docs .code .dashboard import djangoorm as dashboard_djangoorm
376- from docs .code .dashboard import tortoise as dashboard_tortoise
377382 from docs .code .inlines import tortoise as inlines_tortoise
378383 from docs .code .models import tortoise as models_tortoise
379384 from docs .code .quick_tutorial import django as quick_tutorial_django
@@ -384,8 +389,17 @@ def get_page_context(page_url):
384389 from docs .code .quick_tutorial import sqlalchemy as quick_tutorial_sqlalchemy
385390 from docs .code .quick_tutorial import tortoise as quick_tutorial_tortoise
386391
387- from fastadmin import DashboardWidgetAdmin , DashboardWidgetType , InlineModelAdmin , ModelAdmin , WidgetType
392+ from fastadmin import InlineModelAdmin , ModelAdmin , WidgetType , widget_action
388393 from fastadmin .models .base import BaseModelAdmin
394+ from fastadmin .models .schemas import (
395+ WidgetActionArgumentProps ,
396+ WidgetActionChartProps ,
397+ WidgetActionFilter ,
398+ WidgetActionInputSchema ,
399+ WidgetActionProps ,
400+ WidgetActionResponseSchema ,
401+ WidgetActionType ,
402+ )
389403
390404 match page_url :
391405 case "#introduction" :
@@ -553,61 +567,63 @@ def get_page_context(page_url):
553567 },
554568 ]
555569 # widgets
556- case "#registering-widgets " :
570+ case "#widget-methods-and-attributes " :
557571 return [
558572 {
559- "type" : "text-lead" ,
560- "content" : "Register dashboard widgets" ,
573+ "type" : "text" ,
574+ "content" : (
575+ "Use the @widget_action decorator on ModelAdmin methods to declare "
576+ "dashboard widgets and actions. The decorator attaches metadata used "
577+ "to render chart widgets and action forms on the dashboard."
578+ ),
561579 },
580+ {"type" : "code-python" , "content" : inspect .getsource (widget_action )},
562581 {
563- "type" : "tabs" ,
564- "id" : "register_dashboard_widgets" ,
565- "content" : [
566- {
567- "name" : "Tortoise ORM" ,
568- "id" : "dashboard_tortoise_orm" ,
569- "content" : [{"type" : "code-python" , "content" : inspect .getsource (dashboard_tortoise )}],
570- },
571- {
572- "name" : "Django ORM" ,
573- "id" : "dashboard_django_orm" ,
574- "content" : [{"type" : "code-python" , "content" : inspect .getsource (dashboard_djangoorm )}],
575- },
576- {
577- "name" : "SQLAlchemy" ,
578- "id" : "dashboard_sql_alchemy" ,
579- "content" : [{"type" : "alert-info" , "content" : "See the Tortoise ORM example above." }],
580- },
581- {
582- "name" : "Pony ORM" ,
583- "id" : "dashboard_pony_orm" ,
584- "content" : [{"type" : "alert-info" , "content" : "See the Tortoise ORM example above." }],
585- },
586- ],
582+ "type" : "text" ,
583+ "content" : (
584+ "Widget actions use the following types for configuration "
585+ "(chart props, arguments, filters and payload schema):"
586+ ),
587587 },
588- ]
589- case "#widget-methods-and-attributes" :
590- return [
591588 {
592- "type" : "text" ,
593- "content" : "The following methods and attributes are available for dashboard widget admins:" ,
589+ "type" : "code-python" ,
590+ "content" : "\n \n " .join (
591+ [
592+ inspect .getsource (WidgetActionChartProps ),
593+ inspect .getsource (WidgetActionArgumentProps ),
594+ inspect .getsource (WidgetActionProps ),
595+ inspect .getsource (WidgetActionFilter ),
596+ inspect .getsource (WidgetActionInputSchema ),
597+ inspect .getsource (WidgetActionResponseSchema ),
598+ ]
599+ ),
594600 },
595- {"type" : "code-python" , "content" : inspect .getsource (DashboardWidgetAdmin )},
596601 {
597602 "type" : "alert-warning" ,
598- "content" : f"See <a href='{ ANTD_CHARTS_EXAMPLES } ' target='_blank'>antd charts</a> for <code>x_field_filter_widget_props</code>." ,
603+ "content" : (
604+ "If you call @widget_action() without arguments, FastAdmin uses the "
605+ "documented defaults: tab='Default', title='Action', "
606+ "widget_action_type=WidgetActionType.Action and no props or filters."
607+ ),
599608 },
600609 ]
601610 case "#widget-chart-types" :
602611 return [
603612 {
604613 "type" : "text" ,
605- "content" : "The FastAdmin dashboard supports the following widget types:" ,
614+ "content" : (
615+ "The FastAdmin dashboard supports the following widget action types for charts and actions:"
616+ ),
606617 },
607- {"type" : "code-python" , "content" : inspect .getsource (DashboardWidgetType )},
618+ {"type" : "code-python" , "content" : inspect .getsource (WidgetActionType )},
608619 {
609620 "type" : "alert-warning" ,
610- "content" : f"See <a href='{ ANTD_CHARTS_EXAMPLES } ' target='_blank'>antd charts</a> for more details (e.g. how they look)." ,
621+ "content" : (
622+ "Chart-* widget actions render charts on the dashboard; the Action "
623+ "type renders a simple action widget. See "
624+ f"<a href='{ ANTD_CHARTS_EXAMPLES } ' target='_blank'>antd charts</a> "
625+ "for more details (e.g. how they look)."
626+ ),
611627 },
612628 ]
613629 # models
0 commit comments