Custom actions
Register custom actions with header(), row(), or bulk(), then implement static handleAction(name, records, ctx) on the resource.
static resourceActions(actions: ActionBuilder) { actions.header('notify_self', 'Test notification').icon('bell') actions.header('export', 'Export CSV').icon('download') actions.row('escalate', 'Escalate').icon('arrow-up').color('accent').ungrouped() actions.row('resolve', 'Mark resolved').icon('check').confirm('Resolve this ticket?') actions.bulk('assign_me', 'Assign to me') return actions}
static override async handleAction( name: string, records: Record<string, unknown>[], _ctx: HandleActionContext,) { if (name === 'escalate') { // mutate records[0]… return { message: 'Escalated', notification: { title: 'Escalated', body: 'Priority raised.' }, } } if (name === 'notify_self') { return { notification: { title: 'Hello', body: 'From a header action.' } } } if (name === 'assign_me') { return { message: `Assigned ${records.length} ticket(s)`, notification: true } } return null // unknown → host responds 400}Handler contract
Section titled “Handler contract”interface HandleActionResult { message?: string /** true → use message as title; or { title, body } for the topbar bell */ notification?: boolean | { title?: string; body?: string }}- Return
null/undefinedwhen the action name is unknown so the controller can 400. messageflashes in the panel UI.notificationpushes to the signed-in user’s topbar bell (session-scoped).- Resource
handleActiondoes not supportredirect— use Page actions (redirectTo) for page-level redirects.
Routes (Adonis host)
Section titled “Routes (Adonis host)”| Placement | Typical path |
|---|---|
| Row | POST …/:id/action/:action |
| Bulk | POST …/bulk (action + selected ids) |
| Header (non-create) | POST …/action/:action |
Visibility patterns
Section titled “Visibility patterns”Most visibility is ability-based (Authorization). Some resources add record-state rules in the host (e.g. API key revoke vs reactivate). Prefer abilities + handleAction guards for app-specific rules.
Playground: Tickets (Ops) — header Test notification / Export CSV, row Escalate / Mark resolved.
Custom action API
| Method | Description |
|---|---|
actions.header(name, label) | Toolbar action. |
actions.row(name, label) | Per-record action. |
actions.bulk(name, label) | Selection-bar action. |
handleAction(name, records, ctx) | Run custom logic; return message / notification. |