move components to Components context

This commit is contained in:
shibao 2022-02-11 22:47:33 -05:00
parent 993d583fdd
commit c0b3de75a9
19 changed files with 47 additions and 40 deletions

View File

@ -1,4 +1,4 @@
defmodule CanneryWeb.AmmoGroupLive.AmmoGroupCard do defmodule CanneryWeb.Components.AmmoGroupCard do
@moduledoc """ @moduledoc """
Display card for an ammo group Display card for an ammo group
""" """

View File

@ -1,4 +1,4 @@
defmodule CanneryWeb.ContainerLive.ContainerCard do defmodule CanneryWeb.Components.ContainerCard do
@moduledoc """ @moduledoc """
Display card for a container Display card for a container
""" """

View File

@ -1,4 +1,4 @@
defmodule CanneryWeb.ModalComponent do defmodule CanneryWeb.Components.Modal do
@moduledoc """ @moduledoc """
Livecomponent that displays a floating modal window Livecomponent that displays a floating modal window
""" """

View File

@ -1,4 +1,4 @@
defmodule CanneryWeb.TagLive.TagCard do defmodule CanneryWeb.Components.TagCard do
@moduledoc """ @moduledoc """
Display card for a tag Display card for a tag
""" """

View File

@ -1,4 +1,4 @@
defmodule CanneryWeb.Component.Topbar do defmodule CanneryWeb.Components.Topbar do
@moduledoc """ @moduledoc """
Component that renders a topbar with user functions/links Component that renders a topbar with user functions/links
""" """

View File

@ -4,7 +4,7 @@ defmodule CanneryWeb.AmmoGroupLive.Show do
""" """
use CanneryWeb, :live_view use CanneryWeb, :live_view
import CanneryWeb.ContainerLive.ContainerCard import CanneryWeb.Components.ContainerCard
alias Cannery.{Ammo, Repo} alias Cannery.{Ammo, Repo}
@impl true @impl true

View File

@ -4,7 +4,7 @@ defmodule CanneryWeb.AmmoTypeLive.Show do
""" """
use CanneryWeb, :live_view use CanneryWeb, :live_view
import CanneryWeb.AmmoGroupLive.AmmoGroupCard import CanneryWeb.Components.AmmoGroupCard
alias Cannery.Ammo alias Cannery.Ammo
@impl true @impl true

View File

@ -4,7 +4,7 @@ defmodule CanneryWeb.ContainerLive.Index do
""" """
use CanneryWeb, :live_view use CanneryWeb, :live_view
import CanneryWeb.ContainerLive.ContainerCard import CanneryWeb.Components.ContainerCard
alias Cannery.{Containers, Containers.Container} alias Cannery.{Containers, Containers.Container}
alias Ecto.Changeset alias Ecto.Changeset

View File

@ -4,7 +4,7 @@ defmodule CanneryWeb.ContainerLive.Show do
""" """
use CanneryWeb, :live_view use CanneryWeb, :live_view
import CanneryWeb.AmmoGroupLive.AmmoGroupCard import CanneryWeb.Components.AmmoGroupCard
alias Cannery.{Containers, Repo} alias Cannery.{Containers, Repo}
alias Ecto.Changeset alias Ecto.Changeset

View File

@ -6,9 +6,10 @@ defmodule CanneryWeb.LiveHelpers do
import Phoenix.LiveView.Helpers import Phoenix.LiveView.Helpers
import Phoenix.LiveView, only: [assign_new: 3] import Phoenix.LiveView, only: [assign_new: 3]
alias Cannery.Accounts alias Cannery.Accounts
alias CanneryWeb.Components.Modal
@doc """ @doc """
Renders a component inside the `CanneryWeb.ModalComponent` component. Renders a component inside the `Modal` component.
The rendered modal receives a `:return_to` option to properly update The rendered modal receives a `:return_to` option to properly update
the URL when the modal is closed. the URL when the modal is closed.
@ -23,8 +24,7 @@ defmodule CanneryWeb.LiveHelpers do
""" """
def live_modal(component, opts) do def live_modal(component, opts) do
path = Keyword.fetch!(opts, :return_to) path = Keyword.fetch!(opts, :return_to)
modal_opts = [id: :modal, return_to: path, component: component, opts: opts] live_component(Modal, id: :modal, return_to: path, component: component, opts: opts)
live_component(CanneryWeb.ModalComponent, modal_opts)
end end
def assign_defaults(socket, %{"user_token" => user_token} = _session) do def assign_defaults(socket, %{"user_token" => user_token} = _session) do

View File

@ -4,7 +4,7 @@ defmodule CanneryWeb.TagLive.Index do
""" """
use CanneryWeb, :live_view use CanneryWeb, :live_view
import CanneryWeb.TagLive.TagCard import CanneryWeb.Components.TagCard
alias Cannery.Tags alias Cannery.Tags
alias Cannery.Tags.Tag alias Cannery.Tags.Tag

View File

@ -13,7 +13,7 @@
</head> </head>
<body class="pb-8 m-0 p-0 w-full h-full"> <body class="pb-8 m-0 p-0 w-full h-full">
<header> <header>
<CanneryWeb.Component.Topbar.topbar current_user={assigns[:current_user]}></CanneryWeb.Component.Topbar.topbar> <.topbar current_user={assigns[:current_user]}></.topbar>
</header> </header>
<div class="pb-8 w-full flex flex-col justify-center items-center text-center"> <div class="pb-8 w-full flex flex-col justify-center items-center text-center">

View File

@ -1,6 +1,6 @@
<main class="mb-8 container min-w-full"> <main class="mb-8 container min-w-full">
<header> <header>
<CanneryWeb.Component.Topbar.topbar current_user={assigns[:current_user]}></CanneryWeb.Component.Topbar.topbar> <.topbar current_user={assigns[:current_user]}></.topbar>
<div class="mx-8 my-2 flex flex-col space-y-4 text-center"> <div class="mx-8 my-2 flex flex-col space-y-4 text-center">
<%= if @flash && @flash |> Map.has_key?("info") do %> <%= if @flash && @flash |> Map.has_key?("info") do %>

View File

@ -1,5 +1,6 @@
defmodule CanneryWeb.ErrorView do defmodule CanneryWeb.ErrorView do
use CanneryWeb, :view use CanneryWeb, :view
import CanneryWeb.Components.Topbar
alias CanneryWeb.{Endpoint, HomeLive} alias CanneryWeb.{Endpoint, HomeLive}
def template_not_found(error_path, _assigns) do def template_not_found(error_path, _assigns) do

View File

@ -1,5 +1,6 @@
defmodule CanneryWeb.LayoutView do defmodule CanneryWeb.LayoutView do
use CanneryWeb, :view use CanneryWeb, :view
import CanneryWeb.Components.Topbar
alias Cannery.Accounts alias Cannery.Accounts
alias CanneryWeb.{Endpoint, HomeLive} alias CanneryWeb.{Endpoint, HomeLive}

View File

@ -11,7 +11,7 @@ msgid ""
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/component/topbar.ex:96 #: lib/cannery_web/components/topbar.ex:96
#: lib/cannery_web/templates/layout/topbar.html.heex:36 #: lib/cannery_web/templates/layout/topbar.html.heex:36
#: lib/cannery_web/templates/user_confirmation/new.html.heex:26 #: lib/cannery_web/templates/user_confirmation/new.html.heex:26
#: lib/cannery_web/templates/user_registration/new.html.heex:39 #: lib/cannery_web/templates/user_registration/new.html.heex:39
@ -23,7 +23,7 @@ msgid "Log in"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/component/topbar.ex:89 #: lib/cannery_web/components/topbar.ex:89
#: lib/cannery_web/templates/layout/topbar.html.heex:28 #: lib/cannery_web/templates/layout/topbar.html.heex:28
#: lib/cannery_web/templates/user_confirmation/new.html.heex:21 #: lib/cannery_web/templates/user_confirmation/new.html.heex:21
#: lib/cannery_web/templates/user_registration/new.html.heex:3 #: lib/cannery_web/templates/user_registration/new.html.heex:3

View File

@ -76,27 +76,27 @@ msgid "Self-host your own instance, or use an instance from someone you trust."
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/component/topbar.ex:47 #: lib/cannery_web/components/topbar.ex:47
msgid "Ammo" msgid "Ammo"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/component/topbar.ex:41 #: lib/cannery_web/components/topbar.ex:41
msgid "Containers" msgid "Containers"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/component/topbar.ex:60 #: lib/cannery_web/components/topbar.ex:60
msgid "Invites" msgid "Invites"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/component/topbar.ex:53 #: lib/cannery_web/components/topbar.ex:53
msgid "Manage" msgid "Manage"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/component/topbar.ex:35 #: lib/cannery_web/components/topbar.ex:35
msgid "Tags" msgid "Tags"
msgstr "" msgstr ""
@ -117,7 +117,7 @@ msgid "Count"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_group_live/ammo_group_card.ex:28 #: lib/cannery_web/components/ammo_group_card.ex:28
#: lib/cannery_web/live/ammo_group_live/show.html.heex:8 #: lib/cannery_web/live/ammo_group_live/show.html.heex:8
msgid "Count:" msgid "Count:"
msgstr "" msgstr ""
@ -150,7 +150,7 @@ msgid "Notes"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_group_live/ammo_group_card.ex:34 #: lib/cannery_web/components/ammo_group_card.ex:34
#: lib/cannery_web/live/ammo_group_live/show.html.heex:14 #: lib/cannery_web/live/ammo_group_live/show.html.heex:14
msgid "Notes:" msgid "Notes:"
msgstr "" msgstr ""
@ -162,7 +162,7 @@ msgid "Price paid"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_group_live/ammo_group_card.ex:41 #: lib/cannery_web/components/ammo_group_card.ex:41
#: lib/cannery_web/live/ammo_group_live/show.html.heex:21 #: lib/cannery_web/live/ammo_group_live/show.html.heex:21
msgid "Price paid:" msgid "Price paid:"
msgstr "" msgstr ""
@ -371,7 +371,7 @@ msgid "Tracer"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/container_live/container_card.ex:26 #: lib/cannery_web/components/container_card.ex:26
#: lib/cannery_web/live/container_live/show.html.heex:8 #: lib/cannery_web/live/container_live/show.html.heex:8
msgid "Description:" msgid "Description:"
msgstr "" msgstr ""
@ -394,7 +394,7 @@ msgid "Location"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/container_live/container_card.ex:38 #: lib/cannery_web/components/container_card.ex:38
#: lib/cannery_web/live/container_live/show.html.heex:20 #: lib/cannery_web/live/container_live/show.html.heex:20
msgid "Location:" msgid "Location:"
msgstr "" msgstr ""
@ -445,7 +445,7 @@ msgid "Type"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/container_live/container_card.ex:32 #: lib/cannery_web/components/container_card.ex:32
#: lib/cannery_web/live/container_live/show.html.heex:14 #: lib/cannery_web/live/container_live/show.html.heex:14
msgid "Type:" msgid "Type:"
msgstr "" msgstr ""
@ -461,7 +461,7 @@ msgid "Disable"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/invite_live/index.ex:23 #: lib/cannery_web/live/invite_live/index.ex:35
msgid "Edit Invite" msgid "Edit Invite"
msgstr "" msgstr ""
@ -481,7 +481,7 @@ msgid "Invite Disabled"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/invite_live/index.ex:31 #: lib/cannery_web/live/invite_live/index.ex:43
#: lib/cannery_web/live/invite_live/index.html.leex:3 #: lib/cannery_web/live/invite_live/index.html.leex:3
msgid "Listing Invites" msgid "Listing Invites"
msgstr "" msgstr ""
@ -493,7 +493,7 @@ msgid "Listing Tags"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/invite_live/index.ex:27 #: lib/cannery_web/live/invite_live/index.ex:39
msgid "New Invite" msgid "New Invite"
msgstr "" msgstr ""

View File

@ -119,17 +119,17 @@ msgid "Error"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/views/error_view.ex:10 #: lib/cannery_web/views/error_view.ex:11
msgid "Internal Server Error" msgid "Internal Server Error"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/views/error_view.ex:8 #: lib/cannery_web/views/error_view.ex:9
msgid "Not found" msgid "Not found"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/views/error_view.ex:9 #: lib/cannery_web/views/error_view.ex:10
msgid "Unauthorized" msgid "Unauthorized"
msgstr "" msgstr ""
@ -208,3 +208,8 @@ msgstr ""
#: lib/cannery_web/live/container_live/show.ex:52 #: lib/cannery_web/live/container_live/show.ex:52
msgid "Could not delete %{name}: %{error}" msgid "Could not delete %{name}: %{error}"
msgstr "" msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/invite_live/index.ex:20
msgid "You are not authorized to view this page"
msgstr ""

View File

@ -16,7 +16,7 @@ msgid "Register to setup %{name}"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/component/topbar.ex:75 #: lib/cannery_web/components/topbar.ex:75
#: lib/cannery_web/templates/layout/topbar.html.heex:21 #: lib/cannery_web/templates/layout/topbar.html.heex:21
msgid "Are you sure you want to log out?" msgid "Are you sure you want to log out?"
msgstr "" msgstr ""
@ -103,10 +103,10 @@ msgid "Saving..."
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/components/tag_card.ex:33
#: lib/cannery_web/live/ammo_type_live/show.html.heex:26 #: lib/cannery_web/live/ammo_type_live/show.html.heex:26
#: lib/cannery_web/live/container_live/index.html.heex:36 #: lib/cannery_web/live/container_live/index.html.heex:36
#: lib/cannery_web/live/container_live/show.html.heex:36 #: lib/cannery_web/live/container_live/show.html.heex:36
#: lib/cannery_web/live/tag_live/tag_card.ex:33
msgid "Are you sure you want to delete %{name}?" msgid "Are you sure you want to delete %{name}?"
msgstr "" msgstr ""
@ -132,7 +132,7 @@ msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/index.ex:41 #: lib/cannery_web/live/ammo_type_live/index.ex:41
#: lib/cannery_web/live/ammo_type_live/show.ex:39 #: lib/cannery_web/live/ammo_type_live/show.ex:39
#: lib/cannery_web/live/invite_live/index.ex:39 #: lib/cannery_web/live/invite_live/index.ex:51
#: lib/cannery_web/live/tag_live/index.ex:41 #: lib/cannery_web/live/tag_live/index.ex:41
msgid "%{name} deleted succesfully" msgid "%{name} deleted succesfully"
msgstr "" msgstr ""
@ -152,16 +152,16 @@ msgid "Ammo group deleted succesfully"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/invite_live/index.ex:87 #: lib/cannery_web/live/invite_live/index.ex:99
msgid "%{name} disabled succesfully" msgid "%{name} disabled succesfully"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/invite_live/index.ex:69 #: lib/cannery_web/live/invite_live/index.ex:81
msgid "%{name} enabled succesfully" msgid "%{name} enabled succesfully"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/invite_live/index.ex:53 #: lib/cannery_web/live/invite_live/index.ex:65
msgid "%{name} updated succesfully" msgid "%{name} updated succesfully"
msgstr "" msgstr ""