Skip to content

Commit d8ab462

Browse files
Allow customising show actions (#762)
1 parent ed98578 commit d8ab462

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

admin-js/src/App.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ const DatagridSingle = (props) => (
5959
const COMPONENTS = {
6060
Datagrid, DatagridSingle,
6161

62-
BulkDeleteButton,
62+
BulkDeleteButton, BulkExportButton, BulkUpdateButton, CloneButton, CreateButton,
63+
ExportButton, FilterButton, ListButton, ShowButton,
6364

6465
BooleanField, DateField, NumberField, ReferenceField, ReferenceManyField,
6566
ReferenceOneField, SelectField, TextField, TimeField,
@@ -291,6 +292,7 @@ const AiohttpList = (resource, name, permissions) => {
291292
const AiohttpShow = (resource, name, permissions) => {
292293
const ShowActions = () => (
293294
<TopToolbar>
295+
{resource["show_actions"].map(evaluate)}
294296
<WithRecord render={(record) => hasPermission(`${name}.edit`, permissions, record) && <EditButton />} />
295297
</TopToolbar>
296298
);

aiohttp_admin/routes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ def setup_resources(admin: web.Application, schema: Schema) -> None:
4949

5050
state = {"fields": fields, "inputs": inputs, "list_omit": tuple(omit_fields),
5151
"repr": repr_field, "label": r.get("label"), "icon": r.get("icon"),
52-
"bulk_update": r.get("bulk_update", {})}
52+
"bulk_update": r.get("bulk_update", {}),
53+
"show_actions": r.get("show_actions", ())}
5354
admin["state"]["resources"][m.name] = state
5455

5556

aiohttp_admin/types.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ class _Resource(TypedDict, total=False):
9090
field_props: dict[str, dict[str, Any]]
9191
# Custom props to add to inputs.
9292
input_props: dict[str, dict[str, Any]]
93+
# Custom components to add to the actions in the show view.
94+
show_actions: Sequence[ComponentState]
9395

9496

9597
class Resource(_Resource):
@@ -111,6 +113,7 @@ class _ResourceState(TypedDict):
111113
display: Sequence[str]
112114
fields: dict[str, ComponentState]
113115
inputs: dict[str, InputState]
116+
show_actions: Sequence[ComponentState]
114117
repr: str
115118
icon: Optional[str]
116119
urls: dict[str, tuple[str, str]] # (method, url)

0 commit comments

Comments
 (0)