From c0b3de75a9ed572db2f69fe6b6798fb3bd3c3504 Mon Sep 17 00:00:00 2001 From: shibao Date: Fri, 11 Feb 2022 22:47:33 -0500 Subject: [PATCH] move components to Components context --- .../ammo_group_card.ex | 2 +- .../container_card.ex | 2 +- .../modal.ex} | 2 +- .../{live/tag_live => components}/tag_card.ex | 2 +- .../{component => components}/topbar.ex | 2 +- lib/cannery_web/live/ammo_group_live/show.ex | 2 +- lib/cannery_web/live/ammo_type_live/show.ex | 2 +- lib/cannery_web/live/container_live/index.ex | 2 +- lib/cannery_web/live/container_live/show.ex | 2 +- lib/cannery_web/live/live_helpers.ex | 6 ++-- lib/cannery_web/live/tag_live/index.ex | 2 +- .../templates/error/error.html.heex | 2 +- .../templates/layout/live.html.heex | 2 +- lib/cannery_web/views/error_view.ex | 1 + lib/cannery_web/views/layout_view.ex | 1 + priv/gettext/actions.pot | 4 +-- priv/gettext/default.pot | 28 +++++++++---------- priv/gettext/errors.pot | 11 ++++++-- priv/gettext/prompts.pot | 12 ++++---- 19 files changed, 47 insertions(+), 40 deletions(-) rename lib/cannery_web/{live/ammo_group_live => components}/ammo_group_card.ex (96%) rename lib/cannery_web/{live/container_live => components}/container_card.ex (96%) rename lib/cannery_web/{live/modal_component.ex => components/modal.ex} (96%) rename lib/cannery_web/{live/tag_live => components}/tag_card.ex (96%) rename lib/cannery_web/{component => components}/topbar.ex (98%) diff --git a/lib/cannery_web/live/ammo_group_live/ammo_group_card.ex b/lib/cannery_web/components/ammo_group_card.ex similarity index 96% rename from lib/cannery_web/live/ammo_group_live/ammo_group_card.ex rename to lib/cannery_web/components/ammo_group_card.ex index d3aeaee..be5fa69 100644 --- a/lib/cannery_web/live/ammo_group_live/ammo_group_card.ex +++ b/lib/cannery_web/components/ammo_group_card.ex @@ -1,4 +1,4 @@ -defmodule CanneryWeb.AmmoGroupLive.AmmoGroupCard do +defmodule CanneryWeb.Components.AmmoGroupCard do @moduledoc """ Display card for an ammo group """ diff --git a/lib/cannery_web/live/container_live/container_card.ex b/lib/cannery_web/components/container_card.ex similarity index 96% rename from lib/cannery_web/live/container_live/container_card.ex rename to lib/cannery_web/components/container_card.ex index d8cacf0..2d1742f 100644 --- a/lib/cannery_web/live/container_live/container_card.ex +++ b/lib/cannery_web/components/container_card.ex @@ -1,4 +1,4 @@ -defmodule CanneryWeb.ContainerLive.ContainerCard do +defmodule CanneryWeb.Components.ContainerCard do @moduledoc """ Display card for a container """ diff --git a/lib/cannery_web/live/modal_component.ex b/lib/cannery_web/components/modal.ex similarity index 96% rename from lib/cannery_web/live/modal_component.ex rename to lib/cannery_web/components/modal.ex index 0c70ae7..2820997 100644 --- a/lib/cannery_web/live/modal_component.ex +++ b/lib/cannery_web/components/modal.ex @@ -1,4 +1,4 @@ -defmodule CanneryWeb.ModalComponent do +defmodule CanneryWeb.Components.Modal do @moduledoc """ Livecomponent that displays a floating modal window """ diff --git a/lib/cannery_web/live/tag_live/tag_card.ex b/lib/cannery_web/components/tag_card.ex similarity index 96% rename from lib/cannery_web/live/tag_live/tag_card.ex rename to lib/cannery_web/components/tag_card.ex index e5b2b3f..d3d4a2c 100644 --- a/lib/cannery_web/live/tag_live/tag_card.ex +++ b/lib/cannery_web/components/tag_card.ex @@ -1,4 +1,4 @@ -defmodule CanneryWeb.TagLive.TagCard do +defmodule CanneryWeb.Components.TagCard do @moduledoc """ Display card for a tag """ diff --git a/lib/cannery_web/component/topbar.ex b/lib/cannery_web/components/topbar.ex similarity index 98% rename from lib/cannery_web/component/topbar.ex rename to lib/cannery_web/components/topbar.ex index 22d1aba..452ee20 100644 --- a/lib/cannery_web/component/topbar.ex +++ b/lib/cannery_web/components/topbar.ex @@ -1,4 +1,4 @@ -defmodule CanneryWeb.Component.Topbar do +defmodule CanneryWeb.Components.Topbar do @moduledoc """ Component that renders a topbar with user functions/links """ diff --git a/lib/cannery_web/live/ammo_group_live/show.ex b/lib/cannery_web/live/ammo_group_live/show.ex index c217058..b93de87 100644 --- a/lib/cannery_web/live/ammo_group_live/show.ex +++ b/lib/cannery_web/live/ammo_group_live/show.ex @@ -4,7 +4,7 @@ defmodule CanneryWeb.AmmoGroupLive.Show do """ use CanneryWeb, :live_view - import CanneryWeb.ContainerLive.ContainerCard + import CanneryWeb.Components.ContainerCard alias Cannery.{Ammo, Repo} @impl true diff --git a/lib/cannery_web/live/ammo_type_live/show.ex b/lib/cannery_web/live/ammo_type_live/show.ex index fbf10b3..59cad6e 100644 --- a/lib/cannery_web/live/ammo_type_live/show.ex +++ b/lib/cannery_web/live/ammo_type_live/show.ex @@ -4,7 +4,7 @@ defmodule CanneryWeb.AmmoTypeLive.Show do """ use CanneryWeb, :live_view - import CanneryWeb.AmmoGroupLive.AmmoGroupCard + import CanneryWeb.Components.AmmoGroupCard alias Cannery.Ammo @impl true diff --git a/lib/cannery_web/live/container_live/index.ex b/lib/cannery_web/live/container_live/index.ex index 59aa420..485739e 100644 --- a/lib/cannery_web/live/container_live/index.ex +++ b/lib/cannery_web/live/container_live/index.ex @@ -4,7 +4,7 @@ defmodule CanneryWeb.ContainerLive.Index do """ use CanneryWeb, :live_view - import CanneryWeb.ContainerLive.ContainerCard + import CanneryWeb.Components.ContainerCard alias Cannery.{Containers, Containers.Container} alias Ecto.Changeset diff --git a/lib/cannery_web/live/container_live/show.ex b/lib/cannery_web/live/container_live/show.ex index 91cbe7c..66f7414 100644 --- a/lib/cannery_web/live/container_live/show.ex +++ b/lib/cannery_web/live/container_live/show.ex @@ -4,7 +4,7 @@ defmodule CanneryWeb.ContainerLive.Show do """ use CanneryWeb, :live_view - import CanneryWeb.AmmoGroupLive.AmmoGroupCard + import CanneryWeb.Components.AmmoGroupCard alias Cannery.{Containers, Repo} alias Ecto.Changeset diff --git a/lib/cannery_web/live/live_helpers.ex b/lib/cannery_web/live/live_helpers.ex index a390c8b..69e80a3 100644 --- a/lib/cannery_web/live/live_helpers.ex +++ b/lib/cannery_web/live/live_helpers.ex @@ -6,9 +6,10 @@ defmodule CanneryWeb.LiveHelpers do import Phoenix.LiveView.Helpers import Phoenix.LiveView, only: [assign_new: 3] alias Cannery.Accounts + alias CanneryWeb.Components.Modal @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 URL when the modal is closed. @@ -23,8 +24,7 @@ defmodule CanneryWeb.LiveHelpers do """ def live_modal(component, opts) do path = Keyword.fetch!(opts, :return_to) - modal_opts = [id: :modal, return_to: path, component: component, opts: opts] - live_component(CanneryWeb.ModalComponent, modal_opts) + live_component(Modal, id: :modal, return_to: path, component: component, opts: opts) end def assign_defaults(socket, %{"user_token" => user_token} = _session) do diff --git a/lib/cannery_web/live/tag_live/index.ex b/lib/cannery_web/live/tag_live/index.ex index 4e2bac4..5f0ce2e 100644 --- a/lib/cannery_web/live/tag_live/index.ex +++ b/lib/cannery_web/live/tag_live/index.ex @@ -4,7 +4,7 @@ defmodule CanneryWeb.TagLive.Index do """ use CanneryWeb, :live_view - import CanneryWeb.TagLive.TagCard + import CanneryWeb.Components.TagCard alias Cannery.Tags alias Cannery.Tags.Tag diff --git a/lib/cannery_web/templates/error/error.html.heex b/lib/cannery_web/templates/error/error.html.heex index cc39628..a34b410 100644 --- a/lib/cannery_web/templates/error/error.html.heex +++ b/lib/cannery_web/templates/error/error.html.heex @@ -13,7 +13,7 @@
- + <.topbar current_user={assigns[:current_user]}>
diff --git a/lib/cannery_web/templates/layout/live.html.heex b/lib/cannery_web/templates/layout/live.html.heex index 5690388..55f13ac 100644 --- a/lib/cannery_web/templates/layout/live.html.heex +++ b/lib/cannery_web/templates/layout/live.html.heex @@ -1,6 +1,6 @@
- + <.topbar current_user={assigns[:current_user]}>
<%= if @flash && @flash |> Map.has_key?("info") do %> diff --git a/lib/cannery_web/views/error_view.ex b/lib/cannery_web/views/error_view.ex index debdeff..978b4cd 100644 --- a/lib/cannery_web/views/error_view.ex +++ b/lib/cannery_web/views/error_view.ex @@ -1,5 +1,6 @@ defmodule CanneryWeb.ErrorView do use CanneryWeb, :view + import CanneryWeb.Components.Topbar alias CanneryWeb.{Endpoint, HomeLive} def template_not_found(error_path, _assigns) do diff --git a/lib/cannery_web/views/layout_view.ex b/lib/cannery_web/views/layout_view.ex index a725ee7..bb248cb 100644 --- a/lib/cannery_web/views/layout_view.ex +++ b/lib/cannery_web/views/layout_view.ex @@ -1,5 +1,6 @@ defmodule CanneryWeb.LayoutView do use CanneryWeb, :view + import CanneryWeb.Components.Topbar alias Cannery.Accounts alias CanneryWeb.{Endpoint, HomeLive} diff --git a/priv/gettext/actions.pot b/priv/gettext/actions.pot index 8d75449..5374035 100644 --- a/priv/gettext/actions.pot +++ b/priv/gettext/actions.pot @@ -11,7 +11,7 @@ msgid "" msgstr "" #, 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/user_confirmation/new.html.heex:26 #: lib/cannery_web/templates/user_registration/new.html.heex:39 @@ -23,7 +23,7 @@ msgid "Log in" msgstr "" #, 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/user_confirmation/new.html.heex:21 #: lib/cannery_web/templates/user_registration/new.html.heex:3 diff --git a/priv/gettext/default.pot b/priv/gettext/default.pot index da281e0..065bb90 100644 --- a/priv/gettext/default.pot +++ b/priv/gettext/default.pot @@ -76,27 +76,27 @@ msgid "Self-host your own instance, or use an instance from someone you trust." msgstr "" #, elixir-format, ex-autogen -#: lib/cannery_web/component/topbar.ex:47 +#: lib/cannery_web/components/topbar.ex:47 msgid "Ammo" msgstr "" #, elixir-format, ex-autogen -#: lib/cannery_web/component/topbar.ex:41 +#: lib/cannery_web/components/topbar.ex:41 msgid "Containers" msgstr "" #, elixir-format, ex-autogen -#: lib/cannery_web/component/topbar.ex:60 +#: lib/cannery_web/components/topbar.ex:60 msgid "Invites" msgstr "" #, elixir-format, ex-autogen -#: lib/cannery_web/component/topbar.ex:53 +#: lib/cannery_web/components/topbar.ex:53 msgid "Manage" msgstr "" #, elixir-format, ex-autogen -#: lib/cannery_web/component/topbar.ex:35 +#: lib/cannery_web/components/topbar.ex:35 msgid "Tags" msgstr "" @@ -117,7 +117,7 @@ msgid "Count" msgstr "" #, 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 msgid "Count:" msgstr "" @@ -150,7 +150,7 @@ msgid "Notes" msgstr "" #, 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 msgid "Notes:" msgstr "" @@ -162,7 +162,7 @@ msgid "Price paid" msgstr "" #, 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 msgid "Price paid:" msgstr "" @@ -371,7 +371,7 @@ msgid "Tracer" msgstr "" #, 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 msgid "Description:" msgstr "" @@ -394,7 +394,7 @@ msgid "Location" msgstr "" #, 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 msgid "Location:" msgstr "" @@ -445,7 +445,7 @@ msgid "Type" msgstr "" #, 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 msgid "Type:" msgstr "" @@ -461,7 +461,7 @@ msgid "Disable" msgstr "" #, 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" msgstr "" @@ -481,7 +481,7 @@ msgid "Invite Disabled" msgstr "" #, 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 msgid "Listing Invites" msgstr "" @@ -493,7 +493,7 @@ msgid "Listing Tags" msgstr "" #, 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" msgstr "" diff --git a/priv/gettext/errors.pot b/priv/gettext/errors.pot index ab9ef09..a7bae92 100644 --- a/priv/gettext/errors.pot +++ b/priv/gettext/errors.pot @@ -119,17 +119,17 @@ msgid "Error" msgstr "" #, elixir-format, ex-autogen -#: lib/cannery_web/views/error_view.ex:10 +#: lib/cannery_web/views/error_view.ex:11 msgid "Internal Server Error" msgstr "" #, elixir-format, ex-autogen -#: lib/cannery_web/views/error_view.ex:8 +#: lib/cannery_web/views/error_view.ex:9 msgid "Not found" msgstr "" #, elixir-format, ex-autogen -#: lib/cannery_web/views/error_view.ex:9 +#: lib/cannery_web/views/error_view.ex:10 msgid "Unauthorized" msgstr "" @@ -208,3 +208,8 @@ msgstr "" #: lib/cannery_web/live/container_live/show.ex:52 msgid "Could not delete %{name}: %{error}" msgstr "" + +#, elixir-format, ex-autogen +#: lib/cannery_web/live/invite_live/index.ex:20 +msgid "You are not authorized to view this page" +msgstr "" diff --git a/priv/gettext/prompts.pot b/priv/gettext/prompts.pot index 47baa54..afca47d 100644 --- a/priv/gettext/prompts.pot +++ b/priv/gettext/prompts.pot @@ -16,7 +16,7 @@ msgid "Register to setup %{name}" msgstr "" #, 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 msgid "Are you sure you want to log out?" msgstr "" @@ -103,10 +103,10 @@ msgid "Saving..." msgstr "" #, 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/container_live/index.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}?" msgstr "" @@ -132,7 +132,7 @@ msgstr "" #, elixir-format, ex-autogen #: lib/cannery_web/live/ammo_type_live/index.ex:41 #: 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 msgid "%{name} deleted succesfully" msgstr "" @@ -152,16 +152,16 @@ msgid "Ammo group deleted succesfully" msgstr "" #, 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" msgstr "" #, 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" msgstr "" #, 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" msgstr ""