User LiveViews: row_id and data-testid for actions
Table row_id for scoped selectors; data-testid on New/Edit/Delete.
This commit is contained in:
parent
a4b13cef49
commit
ee6bfbacbb
2 changed files with 16 additions and 4 deletions
|
|
@ -3,14 +3,19 @@
|
||||||
{gettext("Listing Users")}
|
{gettext("Listing Users")}
|
||||||
<:actions>
|
<:actions>
|
||||||
<%= if can?(@current_user, :create, Mv.Accounts.User) do %>
|
<%= if can?(@current_user, :create, Mv.Accounts.User) do %>
|
||||||
<.button variant="primary" navigate={~p"/users/new"}>
|
<.button variant="primary" navigate={~p"/users/new"} data-testid="user-new">
|
||||||
<.icon name="hero-plus" /> {gettext("New User")}
|
<.icon name="hero-plus" /> {gettext("New User")}
|
||||||
</.button>
|
</.button>
|
||||||
<% end %>
|
<% end %>
|
||||||
</:actions>
|
</:actions>
|
||||||
</.header>
|
</.header>
|
||||||
|
|
||||||
<.table id="users" rows={@users} row_click={fn user -> JS.navigate(~p"/users/#{user}") end}>
|
<.table
|
||||||
|
id="users"
|
||||||
|
rows={@users}
|
||||||
|
row_id={fn user -> "row-#{user.id}" end}
|
||||||
|
row_click={fn user -> JS.navigate(~p"/users/#{user}") end}
|
||||||
|
>
|
||||||
<:col
|
<:col
|
||||||
:let={user}
|
:let={user}
|
||||||
label={
|
label={
|
||||||
|
|
@ -65,7 +70,9 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%= if can?(@current_user, :update, user) do %>
|
<%= if can?(@current_user, :update, user) do %>
|
||||||
<.link navigate={~p"/users/#{user}/edit"}>{gettext("Edit")}</.link>
|
<.link navigate={~p"/users/#{user}/edit"} data-testid="user-edit">
|
||||||
|
{gettext("Edit")}
|
||||||
|
</.link>
|
||||||
<% end %>
|
<% end %>
|
||||||
</:action>
|
</:action>
|
||||||
|
|
||||||
|
|
@ -74,6 +81,7 @@
|
||||||
<.link
|
<.link
|
||||||
phx-click={JS.push("delete", value: %{id: user.id}) |> hide("#row-#{user.id}")}
|
phx-click={JS.push("delete", value: %{id: user.id}) |> hide("#row-#{user.id}")}
|
||||||
data-confirm={gettext("Are you sure?")}
|
data-confirm={gettext("Are you sure?")}
|
||||||
|
data-testid="user-delete"
|
||||||
>
|
>
|
||||||
{gettext("Delete")}
|
{gettext("Delete")}
|
||||||
</.link>
|
</.link>
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,11 @@ defmodule MvWeb.UserLive.Show do
|
||||||
<span class="sr-only">{gettext("Back to users list")}</span>
|
<span class="sr-only">{gettext("Back to users list")}</span>
|
||||||
</.button>
|
</.button>
|
||||||
<%= if can?(@current_user, :update, @user) do %>
|
<%= if can?(@current_user, :update, @user) do %>
|
||||||
<.button variant="primary" navigate={~p"/users/#{@user}/edit?return_to=show"}>
|
<.button
|
||||||
|
variant="primary"
|
||||||
|
navigate={~p"/users/#{@user}/edit?return_to=show"}
|
||||||
|
data-testid="user-edit"
|
||||||
|
>
|
||||||
<.icon name="hero-pencil-square" /> {gettext("Edit User")}
|
<.icon name="hero-pencil-square" /> {gettext("Edit User")}
|
||||||
</.button>
|
</.button>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue