mirror of
https://github.com/ash-project/ash_admin.git
synced 2024-09-19 12:53:28 +12:00
fix: don't go to potentially non-existant create actions
This commit is contained in:
parent
4c319839d4
commit
cbde3128c4
1 changed files with 21 additions and 2 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue