diff --git a/lib/backpex/item_actions/item_action.ex b/lib/backpex/item_actions/item_action.ex index 8ce98074..8895ae55 100644 --- a/lib/backpex/item_actions/item_action.ex +++ b/lib/backpex/item_actions/item_action.ex @@ -147,4 +147,24 @@ defmodule Backpex.ItemAction do module.fields() != [] end + + @doc """ + Returns default item actions. + """ + def default_actions do + [ + show: %{ + module: Backpex.ItemActions.Show, + only: [:row] + }, + edit: %{ + module: Backpex.ItemActions.Edit, + only: [:row, :show] + }, + delete: %{ + module: Backpex.ItemActions.Delete, + only: [:row, :index, :show] + } + ] + end end diff --git a/lib/backpex/live_resource.ex b/lib/backpex/live_resource.ex index 2100be67..82d30de3 100644 --- a/lib/backpex/live_resource.ex +++ b/lib/backpex/live_resource.ex @@ -701,7 +701,7 @@ defmodule Backpex.LiveResource do end defp apply_item_actions(socket, action) when action in [:index, :resource_action] do - item_actions = socket.assigns.live_resource.item_actions(default_item_actions()) + item_actions = Backpex.ItemAction.default_actions() |> socket.assigns.live_resource.item_actions() assign(socket, :item_actions, item_actions) end @@ -1575,23 +1575,6 @@ defmodule Backpex.LiveResource do if value in permitted, do: value, else: default end - defp default_item_actions do - [ - show: %{ - module: Backpex.ItemActions.Show, - only: [:row] - }, - edit: %{ - module: Backpex.ItemActions.Edit, - only: [:row, :show] - }, - delete: %{ - module: Backpex.ItemActions.Delete, - only: [:row, :index, :show] - } - ] - end - defp maybe_put_empty_filter(%{} = filters, empty_filter_key) when filters == %{} do Map.put(filters, Atom.to_string(empty_filter_key), true) end