fix page titles
This commit is contained in:
		| @@ -14,10 +14,14 @@ defmodule MemexWeb.ContextLive.Show do | |||||||
|         _, |         _, | ||||||
|         %{assigns: %{live_action: live_action, current_user: current_user}} = socket |         %{assigns: %{live_action: live_action, current_user: current_user}} = socket | ||||||
|       ) do |       ) do | ||||||
|     {:noreply, |     context = Contexts.get_context!(id, current_user) | ||||||
|  |  | ||||||
|  |     socket = | ||||||
|       socket |       socket | ||||||
|      |> assign(:page_title, page_title(live_action)) |       |> assign(:page_title, page_title(live_action, context)) | ||||||
|      |> assign(:context, Contexts.get_context!(id, current_user))} |       |> assign(:context, context) | ||||||
|  |  | ||||||
|  |     {:noreply, socket} | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   @impl true |   @impl true | ||||||
| @@ -36,8 +40,8 @@ defmodule MemexWeb.ContextLive.Show do | |||||||
|     {:noreply, socket} |     {:noreply, socket} | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   defp page_title(:show), do: gettext("show context") |   defp page_title(:show, %{title: title}), do: title | ||||||
|   defp page_title(:edit), do: gettext("edit context") |   defp page_title(:edit, %{title: title}), do: gettext("edit %{title}", title: title) | ||||||
|  |  | ||||||
|   @spec is_owner_or_admin?(Context.t(), User.t()) :: boolean() |   @spec is_owner_or_admin?(Context.t(), User.t()) :: boolean() | ||||||
|   defp is_owner_or_admin?(%{user_id: user_id}, %{id: user_id}), do: true |   defp is_owner_or_admin?(%{user_id: user_id}, %{id: user_id}), do: true | ||||||
|   | |||||||
| @@ -14,10 +14,14 @@ defmodule MemexWeb.NoteLive.Show do | |||||||
|         _, |         _, | ||||||
|         %{assigns: %{live_action: live_action, current_user: current_user}} = socket |         %{assigns: %{live_action: live_action, current_user: current_user}} = socket | ||||||
|       ) do |       ) do | ||||||
|     {:noreply, |     note = Notes.get_note!(id, current_user) | ||||||
|  |  | ||||||
|  |     socket = | ||||||
|       socket |       socket | ||||||
|      |> assign(:page_title, page_title(live_action)) |       |> assign(:page_title, page_title(live_action, note)) | ||||||
|      |> assign(:note, Notes.get_note!(id, current_user))} |       |> assign(:note, note) | ||||||
|  |  | ||||||
|  |     {:noreply, socket} | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   @impl true |   @impl true | ||||||
| @@ -36,8 +40,8 @@ defmodule MemexWeb.NoteLive.Show do | |||||||
|     {:noreply, socket} |     {:noreply, socket} | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   defp page_title(:show), do: gettext("show note") |   defp page_title(:show, %{title: title}), do: title | ||||||
|   defp page_title(:edit), do: gettext("edit note") |   defp page_title(:edit, %{title: title}), do: gettext("edit %{title}", title: title) | ||||||
|  |  | ||||||
|   @spec is_owner_or_admin?(Note.t(), User.t()) :: boolean() |   @spec is_owner_or_admin?(Note.t(), User.t()) :: boolean() | ||||||
|   defp is_owner_or_admin?(%{user_id: user_id}, %{id: user_id}), do: true |   defp is_owner_or_admin?(%{user_id: user_id}, %{id: user_id}), do: true | ||||||
|   | |||||||
| @@ -14,10 +14,14 @@ defmodule MemexWeb.PipelineLive.Show do | |||||||
|         _, |         _, | ||||||
|         %{assigns: %{live_action: live_action, current_user: current_user}} = socket |         %{assigns: %{live_action: live_action, current_user: current_user}} = socket | ||||||
|       ) do |       ) do | ||||||
|     {:noreply, |     pipeline = Pipelines.get_pipeline!(id, current_user) | ||||||
|  |  | ||||||
|  |     socket = | ||||||
|       socket |       socket | ||||||
|      |> assign(:page_title, page_title(live_action)) |       |> assign(:page_title, page_title(live_action, pipeline)) | ||||||
|      |> assign(:pipeline, Pipelines.get_pipeline!(id, current_user))} |       |> assign(:pipeline, pipeline) | ||||||
|  |  | ||||||
|  |     {:noreply, socket} | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   @impl true |   @impl true | ||||||
| @@ -36,8 +40,8 @@ defmodule MemexWeb.PipelineLive.Show do | |||||||
|     {:noreply, socket} |     {:noreply, socket} | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   defp page_title(:show), do: gettext("show pipeline") |   defp page_title(:show, %{title: title}), do: title | ||||||
|   defp page_title(:edit), do: gettext("edit pipeline") |   defp page_title(:edit, %{title: title}), do: gettext("edit %{title}", title: title) | ||||||
|  |  | ||||||
|   @spec is_owner_or_admin?(Pipeline.t(), User.t()) :: boolean() |   @spec is_owner_or_admin?(Pipeline.t(), User.t()) :: boolean() | ||||||
|   defp is_owner_or_admin?(%{user_id: user_id}, %{id: user_id}), do: true |   defp is_owner_or_admin?(%{user_id: user_id}, %{id: user_id}), do: true | ||||||
|   | |||||||
| @@ -18,11 +18,11 @@ msgid "%{title} created" | |||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/memex_web/live/context_live/index.ex:57 | #: 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/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/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 | #, elixir-autogen, elixir-format | ||||||
| msgid "%{title} deleted" | msgid "%{title} deleted" | ||||||
| msgstr "" | msgstr "" | ||||||
| @@ -184,8 +184,11 @@ msgid "document your processes, attaching contexts to each step" | |||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/memex_web/live/context_live/index.ex:23 | #: 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/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/index.ex:23 | ||||||
|  | #: lib/memex_web/live/pipeline_live/show.ex:44 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| msgid "edit %{title}" | msgid "edit %{title}" | ||||||
| msgstr "" | msgstr "" | ||||||
| @@ -436,11 +439,6 @@ msgstr "" | |||||||
| msgid "visibility: %{visibility}" | msgid "visibility: %{visibility}" | ||||||
| msgstr "" | 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 | #: lib/memex_web/live/note_live/index.ex:29 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| msgid "new note" | msgid "new note" | ||||||
| @@ -453,16 +451,6 @@ msgstr "" | |||||||
| msgid "search" | msgid "search" | ||||||
| msgstr "" | 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 | #: lib/memex_web/live/context_live/index.ex:29 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| msgid "new context" | msgid "new context" | ||||||
| @@ -473,22 +461,12 @@ msgstr "" | |||||||
| msgid "no contexts found" | msgid "no contexts found" | ||||||
| msgstr "" | 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/components/pipelines_table_component.ex:48 | ||||||
| #: lib/memex_web/live/pipeline_live/form_component.html.heex:23 | #: lib/memex_web/live/pipeline_live/form_component.html.heex:23 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| msgid "description" | msgid "description" | ||||||
| msgstr "" | 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 | #: lib/memex_web/live/pipeline_live/index.ex:29 | ||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| msgid "new pipeline" | msgid "new pipeline" | ||||||
| @@ -498,8 +476,3 @@ msgstr "" | |||||||
| #, elixir-autogen, elixir-format | #, elixir-autogen, elixir-format | ||||||
| msgid "no pipelines found" | msgid "no pipelines found" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: lib/memex_web/live/pipeline_live/show.ex:39 |  | ||||||
| #, elixir-autogen, elixir-format |  | ||||||
| msgid "show pipeline" |  | ||||||
| msgstr "" |  | ||||||
|   | |||||||
| @@ -95,7 +95,7 @@ defmodule MemexWeb.ContextLiveTest do | |||||||
|     test "displays context", %{conn: conn, context: context} do |     test "displays context", %{conn: conn, context: context} do | ||||||
|       {:ok, _show_live, html} = live(conn, Routes.context_show_path(conn, :show, context)) |       {:ok, _show_live, html} = live(conn, Routes.context_show_path(conn, :show, context)) | ||||||
|  |  | ||||||
|       assert html =~ "show context" |       assert html =~ "context" | ||||||
|       assert html =~ context.content |       assert html =~ context.content | ||||||
|     end |     end | ||||||
|  |  | ||||||
|   | |||||||
| @@ -95,7 +95,7 @@ defmodule MemexWeb.NoteLiveTest do | |||||||
|     test "displays note", %{conn: conn, note: note} do |     test "displays note", %{conn: conn, note: note} do | ||||||
|       {:ok, _show_live, html} = live(conn, Routes.note_show_path(conn, :show, note)) |       {:ok, _show_live, html} = live(conn, Routes.note_show_path(conn, :show, note)) | ||||||
|  |  | ||||||
|       assert html =~ "show note" |       assert html =~ "note" | ||||||
|       assert html =~ note.content |       assert html =~ note.content | ||||||
|     end |     end | ||||||
|  |  | ||||||
|   | |||||||
| @@ -98,7 +98,7 @@ defmodule MemexWeb.PipelineLiveTest do | |||||||
|     test "displays pipeline", %{conn: conn, pipeline: pipeline} do |     test "displays pipeline", %{conn: conn, pipeline: pipeline} do | ||||||
|       {:ok, _show_live, html} = live(conn, Routes.pipeline_show_path(conn, :show, pipeline)) |       {:ok, _show_live, html} = live(conn, Routes.pipeline_show_path(conn, :show, pipeline)) | ||||||
|  |  | ||||||
|       assert html =~ "show pipeline" |       assert html =~ "pipeline" | ||||||
|       assert html =~ pipeline.description |       assert html =~ pipeline.description | ||||||
|     end |     end | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user