Skip to content

Commit 3534057

Browse files
committed
chore: format
1 parent c055999 commit 3534057

7 files changed

Lines changed: 107 additions & 20 deletions

File tree

lib/ash_admin/components/resource/data_table.ex

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,15 @@ defmodule AshAdmin.Components.Resource.DataTable do
127127
<%!-- Show --%>
128128
<.link
129129
:if={AshAdmin.Resource.show_action(@resource)}
130-
navigate={admin_path(@prefix, domain: AshAdmin.Domain.name(@domain), resource: AshAdmin.Resource.name(@resource), table: @table, primary_key: encode_primary_key(record), action_type: "read")}
130+
navigate={
131+
admin_path(@prefix,
132+
domain: AshAdmin.Domain.name(@domain),
133+
resource: AshAdmin.Resource.name(@resource),
134+
table: @table,
135+
primary_key: encode_primary_key(record),
136+
action_type: "read"
137+
)
138+
}
131139
class="p-1 text-slate-400 hover:text-slate-600 dark:hover:text-slate-200"
132140
title="View"
133141
>
@@ -204,7 +212,16 @@ defmodule AshAdmin.Components.Resource.DataTable do
204212
defp row_actions(%{actions: [_single]} = assigns) do
205213
~H"""
206214
<.link
207-
navigate={admin_path(@prefix, domain: AshAdmin.Domain.name(@domain), resource: AshAdmin.Resource.name(@resource), action_type: @action_type, action: hd(@actions).name, table: @table, primary_key: encode_primary_key(@record))}
215+
navigate={
216+
admin_path(@prefix,
217+
domain: AshAdmin.Domain.name(@domain),
218+
resource: AshAdmin.Resource.name(@resource),
219+
action_type: @action_type,
220+
action: hd(@actions).name,
221+
table: @table,
222+
primary_key: encode_primary_key(@record)
223+
)
224+
}
208225
class={["p-1 text-slate-400", @hover_class]}
209226
title={@title}
210227
>
@@ -231,7 +248,16 @@ defmodule AshAdmin.Components.Resource.DataTable do
231248
>
232249
<.link
233250
:for={action <- @actions}
234-
navigate={admin_path(@prefix, domain: AshAdmin.Domain.name(@domain), resource: AshAdmin.Resource.name(@resource), action_type: @action_type, action: action.name, table: @table, primary_key: encode_primary_key(@record))}
251+
navigate={
252+
admin_path(@prefix,
253+
domain: AshAdmin.Domain.name(@domain),
254+
resource: AshAdmin.Resource.name(@resource),
255+
action_type: @action_type,
256+
action: action.name,
257+
table: @table,
258+
primary_key: encode_primary_key(@record)
259+
)
260+
}
235261
class="block px-3 py-1.5 text-sm text-slate-700 dark:text-slate-300 hover:bg-slate-50 dark:hover:bg-slate-700"
236262
>
237263
{action_label(action)}

lib/ash_admin/components/resource/form.ex

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1327,7 +1327,15 @@ defmodule AshAdmin.Components.Resource.Form do
13271327
render_attribute_input(assigns, %{attribute | type: Ash.Type.Map}, form, value, name, id)
13281328
end
13291329

1330-
def render_attribute_input(assigns, %{type: Ash.Type.Struct} = attribute, form, value, name, id, _) do
1330+
def render_attribute_input(
1331+
assigns,
1332+
%{type: Ash.Type.Struct} = attribute,
1333+
form,
1334+
value,
1335+
name,
1336+
id,
1337+
_
1338+
) do
13311339
value =
13321340
case value(value, form, attribute) do
13331341
%_{} = struct -> Map.from_struct(struct)

lib/ash_admin/components/resource/relationship_field.ex

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ defmodule AshAdmin.Components.Resource.RelationshipField do
3838
def update(assigns, socket) do
3939
pk_field = Ash.Resource.Info.primary_key(assigns.resource) |> List.first()
4040
label_field = AshAdmin.Resource.label_field(assigns.resource)
41-
current_label = get_current_label(assigns.resource, assigns.value, label_field, ash_opts(assigns))
41+
42+
current_label =
43+
get_current_label(assigns.resource, assigns.value, label_field, ash_opts(assigns))
4244

4345
{:ok,
4446
assign(socket, assigns)

lib/ash_admin/components/resource/show.ex

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,31 @@ defmodule AshAdmin.Components.Resource.Show do
6767
<div :if={@buttons} class="px-4 py-3 text-right sm:px-6">
6868
<.link
6969
:if={destroy?(@resource)}
70-
navigate={admin_path(@prefix, domain: AshAdmin.Domain.name(@domain), resource: AshAdmin.Resource.name(@resource), action_type: "destroy", table: @table, primary_key: encode_primary_key(@record))}
70+
navigate={
71+
admin_path(@prefix,
72+
domain: AshAdmin.Domain.name(@domain),
73+
resource: AshAdmin.Resource.name(@resource),
74+
action_type: "destroy",
75+
table: @table,
76+
primary_key: encode_primary_key(@record)
77+
)
78+
}
7179
class="inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-slate-800 hover:bg-slate-700 dark:bg-slate-200 dark:hover:bg-slate-300 dark:text-slate-900 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-slate-500"
7280
>
7381
Destroy
7482
</.link>
7583
7684
<.link
7785
:if={update?(@resource)}
78-
navigate={admin_path(@prefix, domain: AshAdmin.Domain.name(@domain), resource: AshAdmin.Resource.name(@resource), action_type: "update", table: @table, primary_key: encode_primary_key(@record))}
86+
navigate={
87+
admin_path(@prefix,
88+
domain: AshAdmin.Domain.name(@domain),
89+
resource: AshAdmin.Resource.name(@resource),
90+
action_type: "update",
91+
table: @table,
92+
primary_key: encode_primary_key(@record)
93+
)
94+
}
7995
class="inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-slate-800 hover:bg-slate-700 dark:bg-slate-200 dark:hover:bg-slate-300 dark:text-slate-900 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-slate-500"
8096
>
8197
Update
@@ -249,7 +265,18 @@ defmodule AshAdmin.Components.Resource.Show do
249265
<div class="px-4 py-3 text-right sm:px-6">
250266
<.link
251267
:if={AshAdmin.Resource.show_action(@destination)}
252-
navigate={admin_path(@prefix, domain: AshAdmin.Domain.name(@destination_domain || Ash.Resource.Info.domain(@destination) || @domain), resource: AshAdmin.Resource.name(@destination), table: @context[:data_layer][:table], primary_key: encode_primary_key(@record), action_type: "read")}
268+
navigate={
269+
admin_path(@prefix,
270+
domain:
271+
AshAdmin.Domain.name(
272+
@destination_domain || Ash.Resource.Info.domain(@destination) || @domain
273+
),
274+
resource: AshAdmin.Resource.name(@destination),
275+
table: @context[:data_layer][:table],
276+
primary_key: encode_primary_key(@record),
277+
action_type: "read"
278+
)
279+
}
253280
class="inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-slate-800 hover:bg-slate-700 dark:bg-slate-200 dark:hover:bg-slate-300 dark:text-slate-900 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-slate-500"
254281
>
255282
Show

lib/ash_admin/components/resource/table.ex

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,15 @@ defmodule AshAdmin.Components.Resource.Table do
5454
<td :if={@actions && actions?(@resource)}>
5555
<div class="flex h-max justify-items-center">
5656
<div :if={AshAdmin.Resource.show_action(@resource)}>
57-
<.link navigate={admin_path(@prefix, domain: AshAdmin.Domain.name(@domain), resource: AshAdmin.Resource.name(@resource), table: @table, primary_key: encode_primary_key(record), action_type: "read")}>
57+
<.link navigate={
58+
admin_path(@prefix,
59+
domain: AshAdmin.Domain.name(@domain),
60+
resource: AshAdmin.Resource.name(@resource),
61+
table: @table,
62+
primary_key: encode_primary_key(record),
63+
action_type: "read"
64+
)
65+
}>
5866
<.icon
5967
name="hero-information-circle-solid"
6068
class="h-5 w-5 text-slate-500 dark:text-slate-400"
@@ -63,7 +71,15 @@ defmodule AshAdmin.Components.Resource.Table do
6371
</div>
6472
6573
<div :if={AshAdmin.Helpers.primary_action(@resource, :update)}>
66-
<.link navigate={admin_path(@prefix, domain: AshAdmin.Domain.name(@domain), resource: AshAdmin.Resource.name(@resource), action_type: "update", table: @table, primary_key: encode_primary_key(record))}>
74+
<.link navigate={
75+
admin_path(@prefix,
76+
domain: AshAdmin.Domain.name(@domain),
77+
resource: AshAdmin.Resource.name(@resource),
78+
action_type: "update",
79+
table: @table,
80+
primary_key: encode_primary_key(record)
81+
)
82+
}>
6783
<.icon
6884
name="hero-pencil-solid"
6985
class="h-5 w-5 text-slate-500 dark:text-slate-400"
@@ -72,7 +88,15 @@ defmodule AshAdmin.Components.Resource.Table do
7288
</div>
7389
7490
<div :if={AshAdmin.Helpers.primary_action(@resource, :destroy)}>
75-
<.link navigate={admin_path(@prefix, domain: AshAdmin.Domain.name(@domain), resource: AshAdmin.Resource.name(@resource), action_type: "destroy", table: @table, primary_key: encode_primary_key(record))}>
91+
<.link navigate={
92+
admin_path(@prefix,
93+
domain: AshAdmin.Domain.name(@domain),
94+
resource: AshAdmin.Resource.name(@resource),
95+
action_type: "destroy",
96+
table: @table,
97+
primary_key: encode_primary_key(record)
98+
)
99+
}>
76100
<.icon
77101
name="hero-x-circle-solid"
78102
class="h-5 w-5 text-slate-500 dark:text-slate-400"

test/ash_admin/helpers_test.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ defmodule AshAdmin.HelpersTest do
1212
use Ash.Resource, domain: nil, validate_domain_inclusion?: false
1313

1414
attributes do
15-
attribute :org_id, :integer, primary_key?: true, allow_nil?: false, public?: true
16-
attribute :seq, :integer, primary_key?: true, allow_nil?: false, public?: true
15+
attribute(:org_id, :integer, primary_key?: true, allow_nil?: false, public?: true)
16+
attribute(:seq, :integer, primary_key?: true, allow_nil?: false, public?: true)
1717
end
1818
end
1919

test/components/resource/relationship_field_test.exs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ defmodule AshAdmin.Test.RelationshipFieldTest do
1212
use Ash.Domain, validate_config_inclusion?: false
1313

1414
authorization do
15-
require_actor? true
15+
require_actor?(true)
1616
end
1717

1818
resources do
19-
allow_unregistered? true
19+
allow_unregistered?(true)
2020
end
2121
end
2222

@@ -28,24 +28,24 @@ defmodule AshAdmin.Test.RelationshipFieldTest do
2828
extensions: [AshAdmin.Resource]
2929

3030
ets do
31-
private? true
31+
private?(true)
3232
end
3333

3434
admin do
3535
label_field :name
3636
end
3737

3838
actions do
39-
defaults [:read]
39+
defaults([:read])
4040

4141
create :create do
42-
accept [:name]
42+
accept([:name])
4343
end
4444
end
4545

4646
attributes do
47-
uuid_primary_key :id
48-
attribute :name, :string, public?: true
47+
uuid_primary_key(:id)
48+
attribute(:name, :string, public?: true)
4949
end
5050
end
5151

0 commit comments

Comments
 (0)