diff --git a/lib/memex_web/live/context_live/show.ex b/lib/memex_web/live/context_live/show.ex index 7215374..66f6940 100644 --- a/lib/memex_web/live/context_live/show.ex +++ b/lib/memex_web/live/context_live/show.ex @@ -14,10 +14,14 @@ defmodule MemexWeb.ContextLive.Show do _, %{assigns: %{live_action: live_action, current_user: current_user}} = socket ) do - {:noreply, - socket - |> assign(:page_title, page_title(live_action)) - |> assign(:context, Contexts.get_context!(id, current_user))} + context = Contexts.get_context!(id, current_user) + + socket = + socket + |> assign(:page_title, page_title(live_action, context)) + |> assign(:context, context) + + {:noreply, socket} end @impl true @@ -36,8 +40,8 @@ defmodule MemexWeb.ContextLive.Show do {:noreply, socket} end - defp page_title(:show), do: gettext("show context") - defp page_title(:edit), do: gettext("edit context") + defp page_title(:show, %{title: title}), do: title + defp page_title(:edit, %{title: title}), do: gettext("edit %{title}", title: title) @spec is_owner_or_admin?(Context.t(), User.t()) :: boolean() defp is_owner_or_admin?(%{user_id: user_id}, %{id: user_id}), do: true diff --git a/lib/memex_web/live/note_live/show.ex b/lib/memex_web/live/note_live/show.ex index 071d9f3..de20ce7 100644 --- a/lib/memex_web/live/note_live/show.ex +++ b/lib/memex_web/live/note_live/show.ex @@ -14,10 +14,14 @@ defmodule MemexWeb.NoteLive.Show do _, %{assigns: %{live_action: live_action, current_user: current_user}} = socket ) do - {:noreply, - socket - |> assign(:page_title, page_title(live_action)) - |> assign(:note, Notes.get_note!(id, current_user))} + note = Notes.get_note!(id, current_user) + + socket = + socket + |> assign(:page_title, page_title(live_action, note)) + |> assign(:note, note) + + {:noreply, socket} end @impl true @@ -36,8 +40,8 @@ defmodule MemexWeb.NoteLive.Show do {:noreply, socket} end - defp page_title(:show), do: gettext("show note") - defp page_title(:edit), do: gettext("edit note") + defp page_title(:show, %{title: title}), do: title + defp page_title(:edit, %{title: title}), do: gettext("edit %{title}", title: title) @spec is_owner_or_admin?(Note.t(), User.t()) :: boolean() defp is_owner_or_admin?(%{user_id: user_id}, %{id: user_id}), do: true diff --git a/lib/memex_web/live/pipeline_live/show.ex b/lib/memex_web/live/pipeline_live/show.ex index 4f01d0e..7e76ae1 100644 --- a/lib/memex_web/live/pipeline_live/show.ex +++ b/lib/memex_web/live/pipeline_live/show.ex @@ -14,10 +14,14 @@ defmodule MemexWeb.PipelineLive.Show do _, %{assigns: %{live_action: live_action, current_user: current_user}} = socket ) do - {:noreply, - socket - |> assign(:page_title, page_title(live_action)) - |> assign(:pipeline, Pipelines.get_pipeline!(id, current_user))} + pipeline = Pipelines.get_pipeline!(id, current_user) + + socket = + socket + |> assign(:page_title, page_title(live_action, pipeline)) + |> assign(:pipeline, pipeline) + + {:noreply, socket} end @impl true @@ -36,8 +40,8 @@ defmodule MemexWeb.PipelineLive.Show do {:noreply, socket} end - defp page_title(:show), do: gettext("show pipeline") - defp page_title(:edit), do: gettext("edit pipeline") + defp page_title(:show, %{title: title}), do: title + defp page_title(:edit, %{title: title}), do: gettext("edit %{title}", title: title) @spec is_owner_or_admin?(Pipeline.t(), User.t()) :: boolean() defp is_owner_or_admin?(%{user_id: user_id}, %{id: user_id}), do: true diff --git a/priv/gettext/default.pot b/priv/gettext/default.pot index 09bd55b..c7d922e 100644 --- a/priv/gettext/default.pot +++ b/priv/gettext/default.pot @@ -18,11 +18,11 @@ msgid "%{title} created" msgstr "" #: lib/memex_web/live/context_live/index.ex:57 -#: lib/memex_web/live/context_live/show.ex:33 +#: lib/memex_web/live/context_live/show.ex:37 #: lib/memex_web/live/note_live/index.ex:57 -#: lib/memex_web/live/note_live/show.ex:33 +#: lib/memex_web/live/note_live/show.ex:37 #: lib/memex_web/live/pipeline_live/index.ex:57 -#: lib/memex_web/live/pipeline_live/show.ex:33 +#: lib/memex_web/live/pipeline_live/show.ex:37 #, elixir-autogen, elixir-format msgid "%{title} deleted" msgstr "" @@ -184,8 +184,11 @@ msgid "document your processes, attaching contexts to each step" msgstr "" #: lib/memex_web/live/context_live/index.ex:23 +#: lib/memex_web/live/context_live/show.ex:44 #: lib/memex_web/live/note_live/index.ex:23 +#: lib/memex_web/live/note_live/show.ex:44 #: lib/memex_web/live/pipeline_live/index.ex:23 +#: lib/memex_web/live/pipeline_live/show.ex:44 #, elixir-autogen, elixir-format msgid "edit %{title}" msgstr "" @@ -436,11 +439,6 @@ msgstr "" msgid "visibility: %{visibility}" msgstr "" -#: lib/memex_web/live/note_live/show.ex:40 -#, elixir-autogen, elixir-format -msgid "edit note" -msgstr "" - #: lib/memex_web/live/note_live/index.ex:29 #, elixir-autogen, elixir-format msgid "new note" @@ -453,16 +451,6 @@ msgstr "" msgid "search" msgstr "" -#: lib/memex_web/live/note_live/show.ex:39 -#, elixir-autogen, elixir-format -msgid "show note" -msgstr "" - -#: lib/memex_web/live/context_live/show.ex:40 -#, elixir-autogen, elixir-format -msgid "edit context" -msgstr "" - #: lib/memex_web/live/context_live/index.ex:29 #, elixir-autogen, elixir-format msgid "new context" @@ -473,22 +461,12 @@ msgstr "" msgid "no contexts found" msgstr "" -#: lib/memex_web/live/context_live/show.ex:39 -#, elixir-autogen, elixir-format -msgid "show context" -msgstr "" - #: lib/memex_web/components/pipelines_table_component.ex:48 #: lib/memex_web/live/pipeline_live/form_component.html.heex:23 #, elixir-autogen, elixir-format msgid "description" msgstr "" -#: lib/memex_web/live/pipeline_live/show.ex:40 -#, elixir-autogen, elixir-format -msgid "edit pipeline" -msgstr "" - #: lib/memex_web/live/pipeline_live/index.ex:29 #, elixir-autogen, elixir-format msgid "new pipeline" @@ -498,8 +476,3 @@ msgstr "" #, elixir-autogen, elixir-format msgid "no pipelines found" msgstr "" - -#: lib/memex_web/live/pipeline_live/show.ex:39 -#, elixir-autogen, elixir-format -msgid "show pipeline" -msgstr "" diff --git a/test/memex_web/live/context_live_test.exs b/test/memex_web/live/context_live_test.exs index 6e17aa5..c2d83dc 100644 --- a/test/memex_web/live/context_live_test.exs +++ b/test/memex_web/live/context_live_test.exs @@ -95,7 +95,7 @@ defmodule MemexWeb.ContextLiveTest do test "displays context", %{conn: conn, context: context} do {:ok, _show_live, html} = live(conn, Routes.context_show_path(conn, :show, context)) - assert html =~ "show context" + assert html =~ "context" assert html =~ context.content end diff --git a/test/memex_web/live/note_live_test.exs b/test/memex_web/live/note_live_test.exs index 9181ce4..46a9716 100644 --- a/test/memex_web/live/note_live_test.exs +++ b/test/memex_web/live/note_live_test.exs @@ -95,7 +95,7 @@ defmodule MemexWeb.NoteLiveTest do test "displays note", %{conn: conn, note: note} do {:ok, _show_live, html} = live(conn, Routes.note_show_path(conn, :show, note)) - assert html =~ "show note" + assert html =~ "note" assert html =~ note.content end diff --git a/test/memex_web/live/pipeline_live_test.exs b/test/memex_web/live/pipeline_live_test.exs index 76ad9b9..587192f 100644 --- a/test/memex_web/live/pipeline_live_test.exs +++ b/test/memex_web/live/pipeline_live_test.exs @@ -98,7 +98,7 @@ defmodule MemexWeb.PipelineLiveTest do test "displays pipeline", %{conn: conn, pipeline: pipeline} do {:ok, _show_live, html} = live(conn, Routes.pipeline_show_path(conn, :show, pipeline)) - assert html =~ "show pipeline" + assert html =~ "pipeline" assert html =~ pipeline.description end