Skip to content

Commit

Permalink
fix: don't go to potentially non-existant create actions
Browse files Browse the repository at this point in the history
  • Loading branch information
zachdaniel committed Jun 25, 2024
1 parent 4c31983 commit cbde312
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions lib/ash_admin/components/resource/nav.ex
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,27 @@ defmodule AshAdmin.Components.Resource.Nav do
end

defp create_action(resource) do
AshAdmin.Helpers.primary_action(resource, :create) ||
Enum.find(Ash.Resource.Info.actions(resource), &(&1.type == :create))
case AshAdmin.Helpers.primary_action(resource, :create) ||
Enum.find(Ash.Resource.Info.actions(resource), &(&1.type == :create)) do
nil ->
nil

primary_action ->
case AshAdmin.Resource.create_actions(resource) do
nil ->
primary_action

list ->
if primary_action.name in list do
primary_action
else
case Enum.at(list, 0) do
nil -> nil
action -> Ash.Resource.Info.action(resource, action)
end
end
end
end
end

defp data_groups(prefix, domain, resource, current_action, table) do
Expand Down

0 comments on commit cbde312

Please sign in to comment.