You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(spa): detail-page admin action buttons reusing the changelist actions API (#555) (#562)
Closes#555. Surface `ModelAdmin.actions` as buttons on the detail page,
alongside `History` / `View on site` / `Edit` / `Delete`. Each button
calls the **same** changelist action endpoint the list page uses —
just with a one-pk array (`[pk]`) — so there's no new wire surface and
the existing permission gate / queryset filter / `message_user` /
intermediate-redirect-in-new-tab flow all apply unchanged.
- Imports: `useList`, `ActionDescriptor` from `@dar/data`.
- `DetailResponse` doesn't carry `actions` (they live in the list
response — `django-admin-rest-api` owns that wire shape, no change),
so DetailPage reads the metadata through `useList({ pageSize: 1 })`.
The data layer caches it; for a user who arrived from the list it's
essentially free.
- `requestDetailAction` + `performDetailAction` mirror the list-page
flow: `requires_confirmation` opens the same styled confirm modal
(re-reading "Run X on *this object*?"), else runs immediately;
`result.redirect` opens in a new tab (the #250 minimum); messages
surface as toasts (#442).
- Buttons gated by `canChange` — same visibility rule the bulk runner
uses on the changelist.
Vitest: 145 passed. Typecheck + ESLint (--max-warnings 0) + stylelint +
dark-mode guard clean. `pnpm -r build` ok.
Closes#555
Co-authored-by: Martin Castro Laminrs <mcastro@laminr.ai>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0 commit comments