Built-in action type registry.
Provides lookup for built-in action types by atom name. Action types define how row action buttons are rendered.
Built-in Types
:link- Navigation link:event- Custom event button (default):edit- Edit action (opens form):destroy- Delete button with confirmation:update- Ash update action trigger:unarchive- Restore archived record:permanent_destroy- Permanently delete archived record:row_click- Full-row click handler:accordion- Expandable row toggle (requires:expandfeature)
Custom Action Types
Implement the MishkaGervaz.Table.Behaviours.ActionType behaviour:
defmodule MyApp.ActionTypes.Archive do
@behaviour MishkaGervaz.Table.Behaviours.ActionType
use Phoenix.Component
@impl true
def render(assigns, action, record, ui, target) do
# Return rendered HEEx
end
endThen use in DSL:
row_actions do
action :archive, type: MyApp.ActionTypes.Archive
endSee MishkaGervaz.Table.Behaviours.TypeRegistry (base),
MishkaGervaz.Table.Behaviours.ActionType, and
MishkaGervaz.Table.Entities.RowAction.
Summary
Functions
Check if type name is registered.
List all built-in type names.
Get the default type module.
Get module by type name.
Get module, falling back to type itself for custom modules.
Resolve action type module from action configuration.
Functions
Check if type name is registered.
@spec builtin_types() :: [atom()]
List all built-in type names.
@spec default() :: module() | nil
Get the default type module.
Get module by type name.
Returns the module for built-in types, or the type itself if it's already a module (for custom types).
Get module, falling back to type itself for custom modules.
Unlike get/1 which returns nil for unknown types,
this returns the type as-is (assuming it's a custom module).
Resolve action type module from action configuration.
Checks in order:
- If type is a module with
render/4, use it directly - If type is an atom, look up in built-in registry
- Otherwise, default to Event action
Examples
iex> MishkaGervaz.Table.Types.Action.resolve_type(%{type: :link})
MishkaGervaz.Table.Types.Action.Link
iex> MishkaGervaz.Table.Types.Action.resolve_type(%{type: :destroy})
MishkaGervaz.Table.Types.Action.Destroy