Skip to content
Shamar

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
}
interface HandleActionResult {
message?: string
/** true → use message as title; or { title, body } for the topbar bell */
notification?: boolean | { title?: string; body?: string }
}
  • Return null / undefined when the action name is unknown so the controller can 400.
  • message flashes in the panel UI.
  • notification pushes to the signed-in user’s topbar bell (session-scoped).
  • Resource handleAction does not support redirect — use Page actions (redirectTo) for page-level redirects.
Placement Typical path
Row POST …/:id/action/:action
Bulk POST …/bulk (action + selected ids)
Header (non-create) POST …/action/:action

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

MethodDescription
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.