diff --git a/elixir/apps/web/lib/web/live/actors/components.ex b/elixir/apps/web/lib/web/live/actors/components.ex index f74ea31fc..04931e4d1 100644 --- a/elixir/apps/web/lib/web/live/actors/components.ex +++ b/elixir/apps/web/lib/web/live/actors/components.ex @@ -45,7 +45,7 @@ defmodule Web.Actors.Components do def actor_name_and_role(assigns) do ~H""" <.link - navigate={~p"/#{@account}/actors/#{@actor}"} + navigate={actor_show_url(@account, @actor)} class={["text-accent-500 hover:underline", @class]} > <%= @actor.name %> @@ -56,6 +56,9 @@ defmodule Web.Actors.Components do (service account) + + (api client) + """ end @@ -190,4 +193,12 @@ defmodule Web.Actors.Components do def next_step_path(_other, account) do ~p"/#{account}/actors/users/new" end + + def actor_show_url(account, %Domain.Actors.Actor{type: :api_client} = actor) do + ~p"/#{account}/settings/api_clients/#{actor}" + end + + def actor_show_url(account, actor) do + ~p"/#{account}/actors/#{actor}" + end end diff --git a/elixir/apps/web/test/web/live/actors/index_test.exs b/elixir/apps/web/test/web/live/actors/index_test.exs index 75b4574db..839aaf288 100644 --- a/elixir/apps/web/test/web/live/actors/index_test.exs +++ b/elixir/apps/web/test/web/live/actors/index_test.exs @@ -144,4 +144,25 @@ defmodule Web.Live.Actors.IndexTest do assert String.contains?(row["last signed in"], "1 hour ago") end) end + + test "renders proper URL for API client 'show' page", %{ + account: account, + identity: identity, + conn: conn + } do + api_client = Fixtures.Actors.create_actor(type: :api_client, account: account) + + {:ok, lv, _html} = + conn + |> authorize_conn(identity) + |> live(~p"/#{account}/actors") + + items = + lv + |> element("#actors") + |> render() + |> Floki.find("a[href*=\"api_clients/#{api_client.id}\"]") + + assert length(items) == 1 + end end