Role CRUD LiveViews closes #325 #326
4 changed files with 84 additions and 41 deletions
|
|
@ -1897,21 +1897,11 @@ msgstr "Berechtigungssatz"
|
|||
msgid "Role"
|
||||
msgstr ""
|
||||
|
||||
#: lib/mv_web/live/role_live/index.ex
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Role deleted successfully"
|
||||
msgstr "Rolle erfolgreich gelöscht"
|
||||
|
||||
#: lib/mv_web/live/role_live/show.ex
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Role details and permissions."
|
||||
msgstr "Rollen-Details und Berechtigungen."
|
||||
|
||||
#: lib/mv_web/live/role_live/form.ex
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Role saved successfully"
|
||||
msgstr "Rolle erfolgreich gespeichert"
|
||||
|
||||
#: lib/mv_web/live/role_live/form.ex
|
||||
#, elixir-autogen, elixir-format, fuzzy
|
||||
msgid "Save Role"
|
||||
|
|
@ -1973,6 +1963,7 @@ msgstr "read_only - Lesezugriff auf alle Daten"
|
|||
msgid "Delete Role"
|
||||
msgstr "Rolle löschen"
|
||||
|
||||
#: lib/mv_web/live/role_live/index.ex
|
||||
#: lib/mv_web/live/role_live/show.ex
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Role deleted successfully."
|
||||
|
|
@ -1989,6 +1980,24 @@ msgstr "Rollen"
|
|||
msgid "Cannot delete role. %{count} user(s) are still assigned to this role. Please assign them to another role first."
|
||||
msgstr "Rolle kann nicht gelöscht werden. %{count} Benutzer*in(nen) sind dieser Rolle noch zugeordnet. Bitte weisen Sie sie zunächst einer anderen Rolle zu."
|
||||
|
||||
#: lib/mv_web/live/role_live/form.ex
|
||||
#: lib/mv_web/live/role_live/index.ex
|
||||
#: lib/mv_web/live/role_live/show.ex
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Role not found."
|
||||
msgstr "Rolle nicht gefunden."
|
||||
|
||||
#: lib/mv_web/live/role_live/form.ex
|
||||
#, elixir-autogen, elixir-format, fuzzy
|
||||
msgid "Role saved successfully."
|
||||
msgstr "Rolle erfolgreich gespeichert"
|
||||
|
||||
#: lib/mv_web/live/role_live/index.ex
|
||||
#: lib/mv_web/live/role_live/show.ex
|
||||
#, elixir-autogen, elixir-format, fuzzy
|
||||
msgid "System roles cannot be deleted."
|
||||
msgstr "System-Rollen können nicht gelöscht werden."
|
||||
|
||||
#~ #: lib/mv_web/live/member_live/form.ex
|
||||
#~ #: lib/mv_web/live/member_live/show.ex
|
||||
#~ #: lib/mv_web/translations/member_fields.ex
|
||||
|
|
|
|||
|
|
@ -1898,21 +1898,11 @@ msgstr ""
|
|||
msgid "Role"
|
||||
msgstr ""
|
||||
|
||||
#: lib/mv_web/live/role_live/index.ex
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Role deleted successfully"
|
||||
msgstr ""
|
||||
|
||||
#: lib/mv_web/live/role_live/show.ex
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Role details and permissions."
|
||||
msgstr ""
|
||||
|
||||
#: lib/mv_web/live/role_live/form.ex
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Role saved successfully"
|
||||
msgstr ""
|
||||
|
||||
#: lib/mv_web/live/role_live/form.ex
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Save Role"
|
||||
|
|
@ -1974,6 +1964,7 @@ msgstr ""
|
|||
msgid "Delete Role"
|
||||
msgstr ""
|
||||
|
||||
#: lib/mv_web/live/role_live/index.ex
|
||||
#: lib/mv_web/live/role_live/show.ex
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Role deleted successfully."
|
||||
|
|
@ -1989,3 +1980,21 @@ msgstr ""
|
|||
#, elixir-autogen, elixir-format
|
||||
msgid "Cannot delete role. %{count} user(s) are still assigned to this role. Please assign them to another role first."
|
||||
msgstr ""
|
||||
|
||||
#: lib/mv_web/live/role_live/form.ex
|
||||
#: lib/mv_web/live/role_live/index.ex
|
||||
#: lib/mv_web/live/role_live/show.ex
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Role not found."
|
||||
msgstr ""
|
||||
|
||||
#: lib/mv_web/live/role_live/form.ex
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Role saved successfully."
|
||||
msgstr ""
|
||||
|
||||
#: lib/mv_web/live/role_live/index.ex
|
||||
#: lib/mv_web/live/role_live/show.ex
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "System roles cannot be deleted."
|
||||
msgstr ""
|
||||
|
|
|
|||
|
|
@ -1898,21 +1898,11 @@ msgstr ""
|
|||
msgid "Role"
|
||||
msgstr ""
|
||||
|
||||
#: lib/mv_web/live/role_live/index.ex
|
||||
#, elixir-autogen, elixir-format, fuzzy
|
||||
msgid "Role deleted successfully"
|
||||
msgstr ""
|
||||
|
||||
#: lib/mv_web/live/role_live/show.ex
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Role details and permissions."
|
||||
msgstr ""
|
||||
|
||||
#: lib/mv_web/live/role_live/form.ex
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Role saved successfully"
|
||||
msgstr ""
|
||||
|
||||
#: lib/mv_web/live/role_live/form.ex
|
||||
#, elixir-autogen, elixir-format, fuzzy
|
||||
msgid "Save Role"
|
||||
|
|
@ -1974,6 +1964,7 @@ msgstr ""
|
|||
msgid "Delete Role"
|
||||
msgstr ""
|
||||
|
||||
#: lib/mv_web/live/role_live/index.ex
|
||||
#: lib/mv_web/live/role_live/show.ex
|
||||
#, elixir-autogen, elixir-format, fuzzy
|
||||
msgid "Role deleted successfully."
|
||||
|
|
@ -1990,6 +1981,24 @@ msgstr ""
|
|||
msgid "Cannot delete role. %{count} user(s) are still assigned to this role. Please assign them to another role first."
|
||||
msgstr ""
|
||||
|
||||
#: lib/mv_web/live/role_live/form.ex
|
||||
#: lib/mv_web/live/role_live/index.ex
|
||||
#: lib/mv_web/live/role_live/show.ex
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Role not found."
|
||||
msgstr ""
|
||||
|
||||
#: lib/mv_web/live/role_live/form.ex
|
||||
#, elixir-autogen, elixir-format, fuzzy
|
||||
msgid "Role saved successfully."
|
||||
msgstr ""
|
||||
|
||||
#: lib/mv_web/live/role_live/index.ex
|
||||
#: lib/mv_web/live/role_live/show.ex
|
||||
#, elixir-autogen, elixir-format, fuzzy
|
||||
msgid "System roles cannot be deleted."
|
||||
msgstr ""
|
||||
|
||||
#~ #: lib/mv_web/live/components/payment_filter_component.ex
|
||||
#~ #, elixir-autogen, elixir-format
|
||||
#~ msgid "All payment statuses"
|
||||
|
|
|
|||
|
|
@ -208,10 +208,11 @@ defmodule MvWeb.RoleLiveTest do
|
|||
test "returns 404 for invalid role ID", %{conn: conn} do
|
||||
invalid_id = Ecto.UUID.generate()
|
||||
|
||||
# Ash.get! raises Ash.Error.Invalid with Query.NotFound inside
|
||||
assert_raise Ash.Error.Invalid, fn ->
|
||||
live(conn, "/admin/roles/#{invalid_id}")
|
||||
end
|
||||
# Should redirect to index with error message
|
||||
# redirect in mount returns {:error, {:redirect, ...}}
|
||||
result = live(conn, "/admin/roles/#{invalid_id}")
|
||||
|
||||
assert match?({:error, {:redirect, %{to: "/admin/roles"}}}, result)
|
||||
end
|
||||
|
||||
test "shows system role badge if is_system_role is true", %{conn: conn} do
|
||||
|
|
@ -269,21 +270,20 @@ defmodule MvWeb.RoleLiveTest do
|
|||
test "shows error with invalid permission_set_name", %{conn: conn} do
|
||||
{:ok, view, _html} = live(conn, "/admin/roles/new")
|
||||
|
||||
# Use a valid permission set name but test validation differently
|
||||
# The select dropdown prevents invalid values, so we test via form validation
|
||||
# Try to submit with empty permission_set_name (invalid)
|
||||
attrs = %{
|
||||
"name" => "New Role",
|
||||
"description" => "New description",
|
||||
"permission_set_name" => "read_only"
|
||||
"permission_set_name" => ""
|
||||
}
|
||||
|
||||
# Submit with valid data first
|
||||
view
|
||||
|> form("#role-form", role: attrs)
|
||||
|> render_submit()
|
||||
|
||||
# Should succeed - validation happens on backend
|
||||
assert_redirect(view, "/admin/roles")
|
||||
# Should show validation error
|
||||
html = render(view)
|
||||
assert html =~ "error" || html =~ "required" || html =~ "Permission Set"
|
||||
end
|
||||
|
||||
test "shows flash message after successful creation", %{conn: conn} do
|
||||
|
|
@ -317,6 +317,16 @@ defmodule MvWeb.RoleLiveTest do
|
|||
assert html =~ role.name
|
||||
end
|
||||
|
||||
test "returns 404 for invalid role ID in edit", %{conn: conn} do
|
||||
invalid_id = Ecto.UUID.generate()
|
||||
|
||||
# Should redirect to index with error message
|
||||
# redirect in mount returns {:error, {:redirect, ...}}
|
||||
result = live(conn, "/admin/roles/#{invalid_id}/edit")
|
||||
|
||||
assert match?({:error, {:redirect, %{to: "/admin/roles"}}}, result)
|
||||
end
|
||||
|
||||
test "updates role name", %{conn: conn, role: role} do
|
||||
{:ok, view, _html} = live(conn, "/admin/roles/#{role.id}/edit?return_to=show")
|
||||
|
||||
|
|
@ -400,12 +410,18 @@ defmodule MvWeb.RoleLiveTest do
|
|||
|> Ash.Changeset.force_change_attribute(:is_system_role, true)
|
||||
|> Ash.create!()
|
||||
|
||||
{:ok, _view, html} = live(conn, "/admin/roles")
|
||||
{:ok, view, html} = live(conn, "/admin/roles")
|
||||
|
||||
# System role delete button should be disabled
|
||||
assert html =~ "disabled" || html =~ "cursor-not-allowed" ||
|
||||
html =~ "System roles cannot be deleted"
|
||||
|
||||
# Try to delete via event (backend check)
|
||||
render_click(view, "delete", %{"id" => system_role.id})
|
||||
|
||||
# Should show error message
|
||||
assert render(view) =~ "System roles cannot be deleted"
|
||||
|
||||
# Role should still exist
|
||||
{:ok, _role} = Authorization.get_role(system_role.id)
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue