From 8ef8da3e431a1f5597a4829fdf65f91428ef0894 Mon Sep 17 00:00:00 2001 From: Florian Arens <60519307+Flo0807@users.noreply.github.com> Date: Wed, 11 Dec 2024 12:27:50 +0100 Subject: [PATCH 1/2] Add public function for `default_item_actions` --- lib/backpex/item_actions/item_action.ex | 20 ++++++++++++++++++++ lib/backpex/live_resource.ex | 19 +------------------ 2 files changed, 21 insertions(+), 18 deletions(-) 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 From 2814166c1c621d7e8b3c7dc856268abe250fa095 Mon Sep 17 00:00:00 2001 From: Florian Arens <60519307+Flo0807@users.noreply.github.com> Date: Wed, 11 Dec 2024 12:30:40 +0100 Subject: [PATCH 2/2] Bump version in mix.exs to 0.9.1 --- mix.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mix.exs b/mix.exs index d109a14b..69ca6dfb 100644 --- a/mix.exs +++ b/mix.exs @@ -1,7 +1,7 @@ defmodule Backpex.MixProject do use Mix.Project - @version "0.9.0" + @version "0.9.1" @source_url "https://github.com/naymspace/backpex" @changelog_url "https://github.com/naymspace/backpex/releases"