diff --git a/admin-js/src/App.js b/admin-js/src/App.js index ee814dd2..efc8d383 100644 --- a/admin-js/src/App.js +++ b/admin-js/src/App.js @@ -59,7 +59,8 @@ const DatagridSingle = (props) => ( const COMPONENTS = { Datagrid, DatagridSingle, - BulkDeleteButton, + BulkDeleteButton, BulkExportButton, BulkUpdateButton, CloneButton, CreateButton, + ExportButton, FilterButton, ListButton, ShowButton, BooleanField, DateField, NumberField, ReferenceField, ReferenceManyField, ReferenceOneField, SelectField, TextField, TimeField, @@ -291,6 +292,7 @@ const AiohttpList = (resource, name, permissions) => { const AiohttpShow = (resource, name, permissions) => { const ShowActions = () => ( + {resource["show_actions"].map(evaluate)} hasPermission(`${name}.edit`, permissions, record) && } /> ); diff --git a/aiohttp_admin/routes.py b/aiohttp_admin/routes.py index 9e6e1347..c9f201b5 100644 --- a/aiohttp_admin/routes.py +++ b/aiohttp_admin/routes.py @@ -49,7 +49,7 @@ def setup_resources(admin: web.Application, schema: Schema) -> None: state = {"fields": fields, "inputs": inputs, "list_omit": tuple(omit_fields), "repr": repr_field, "label": r.get("label"), "icon": r.get("icon"), - "bulk_update": r.get("bulk_update", {})} + "bulk_update": r.get("bulk_update", {}), "show_actions": r.get("show_actions", ())} admin["state"]["resources"][m.name] = state diff --git a/aiohttp_admin/types.py b/aiohttp_admin/types.py index 6b9f7fd9..6c2c64a6 100644 --- a/aiohttp_admin/types.py +++ b/aiohttp_admin/types.py @@ -90,6 +90,8 @@ class _Resource(TypedDict, total=False): field_props: dict[str, dict[str, Any]] # Custom props to add to inputs. input_props: dict[str, dict[str, Any]] + # Custom components to add to the actions in the show view. + show_actions: Sequence[ComponentState] class Resource(_Resource): @@ -111,6 +113,7 @@ class _ResourceState(TypedDict): display: Sequence[str] fields: dict[str, ComponentState] inputs: dict[str, InputState] + show_actions: Sequence[ComponentState] repr: str icon: Optional[str] urls: dict[str, tuple[str, str]] # (method, url)