fix page titles

This commit is contained in:
shibao 2022-11-24 17:44:01 -05:00
parent 44c8cf77bb
commit e9360fb3d5
7 changed files with 39 additions and 54 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 ""

View File

@ -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

View File

@ -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

View File

@ -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