From 6b565abf934affc399544d6152c314e2180e1a6c Mon Sep 17 00:00:00 2001 From: shibao Date: Mon, 7 Nov 2022 22:36:38 -0500 Subject: [PATCH] update to liveview 0.18 and use elixir 1.14 --- .drone.yml | 2 +- .tool-versions | 4 +- CHANGELOG.md | 1 + Dockerfile | 2 +- lib/cannery_web.ex | 2 +- .../components/add_shot_group_component.ex | 2 +- .../add_shot_group_component.html.heex | 2 +- lib/cannery_web/components/ammo_group_card.ex | 13 +- lib/cannery_web/components/container_card.ex | 5 +- .../components/move_ammo_group_component.ex | 11 +- lib/cannery_web/components/topbar.ex | 117 +++-- .../live/ammo_group_live/form_component.ex | 4 +- .../ammo_group_live/form_component.html.heex | 2 +- lib/cannery_web/live/ammo_group_live/index.ex | 85 ++-- .../live/ammo_group_live/index.html.heex | 28 +- lib/cannery_web/live/ammo_group_live/show.ex | 30 +- .../live/ammo_group_live/show.html.heex | 60 +-- .../live/ammo_type_live/form_component.ex | 4 +- .../ammo_type_live/form_component.html.heex | 2 +- lib/cannery_web/live/ammo_type_live/index.ex | 56 ++- .../live/ammo_type_live/index.html.heex | 14 +- lib/cannery_web/live/ammo_type_live/show.ex | 2 +- .../live/ammo_type_live/show.html.heex | 33 +- .../edit_tags_component.html.heex | 35 +- .../live/container_live/form_component.ex | 4 +- .../container_live/form_component.html.heex | 2 +- .../live/container_live/index.html.heex | 53 ++- lib/cannery_web/live/container_live/show.ex | 2 +- .../live/container_live/show.html.heex | 47 +- lib/cannery_web/live/home_live.ex | 58 ++- lib/cannery_web/live/init_assigns.ex | 2 +- .../live/invite_live/form_component.ex | 4 +- .../live/invite_live/form_component.html.heex | 2 +- lib/cannery_web/live/invite_live/index.ex | 2 +- .../live/invite_live/index.html.heex | 103 +++-- lib/cannery_web/live/live_helpers.ex | 35 +- .../live/range_live/form_component.ex | 2 +- .../live/range_live/form_component.html.heex | 2 +- lib/cannery_web/live/range_live/index.ex | 37 +- .../live/range_live/index.html.heex | 24 +- .../live/tag_live/form_component.ex | 6 +- lib/cannery_web/live/tag_live/index.html.heex | 44 +- lib/cannery_web/router.ex | 2 +- .../templates/layout/root.html.heex | 5 +- .../templates/user_confirmation/new.html.heex | 14 +- .../templates/user_registration/new.html.heex | 14 +- .../user_reset_password/edit.html.heex | 14 +- .../user_reset_password/new.html.heex | 14 +- .../templates/user_session/new.html.heex | 14 +- .../templates/user_settings/edit.html.heex | 20 +- lib/cannery_web/views/error_helpers.ex | 2 +- lib/cannery_web/views/view_helpers.ex | 21 +- mix.exs | 10 +- mix.lock | 46 +- priv/gettext/actions.pot | 90 ++-- priv/gettext/de/LC_MESSAGES/actions.po | 90 ++-- priv/gettext/de/LC_MESSAGES/default.po | 426 +++++++++--------- priv/gettext/de/LC_MESSAGES/emails.po | 30 +- priv/gettext/de/LC_MESSAGES/errors.po | 66 +-- priv/gettext/de/LC_MESSAGES/prompts.po | 110 ++--- priv/gettext/default.pot | 426 +++++++++--------- priv/gettext/emails.pot | 30 +- priv/gettext/en/LC_MESSAGES/actions.po | 90 ++-- priv/gettext/en/LC_MESSAGES/default.po | 426 +++++++++--------- priv/gettext/en/LC_MESSAGES/emails.po | 30 +- priv/gettext/en/LC_MESSAGES/errors.po | 66 +-- priv/gettext/en/LC_MESSAGES/prompts.po | 110 ++--- priv/gettext/errors.pot | 66 +-- priv/gettext/es/LC_MESSAGES/actions.po | 90 ++-- priv/gettext/es/LC_MESSAGES/default.po | 426 +++++++++--------- priv/gettext/es/LC_MESSAGES/emails.po | 30 +- priv/gettext/es/LC_MESSAGES/errors.po | 66 +-- priv/gettext/es/LC_MESSAGES/prompts.po | 110 ++--- priv/gettext/fr/LC_MESSAGES/actions.po | 90 ++-- priv/gettext/fr/LC_MESSAGES/default.po | 426 +++++++++--------- priv/gettext/fr/LC_MESSAGES/emails.po | 30 +- priv/gettext/fr/LC_MESSAGES/errors.po | 66 +-- priv/gettext/fr/LC_MESSAGES/prompts.po | 110 ++--- priv/gettext/prompts.pot | 110 ++--- 79 files changed, 2410 insertions(+), 2321 deletions(-) diff --git a/.drone.yml b/.drone.yml index 54422fc9..de997860 100644 --- a/.drone.yml +++ b/.drone.yml @@ -16,7 +16,7 @@ steps: - assets/node_modules/ - name: test - image: elixir:1.13.4-alpine + image: elixir:1.14.1-alpine environment: TEST_DATABASE_URL: ecto://postgres:postgres@database/cannery_test HOST: testing.example.tld diff --git a/.tool-versions b/.tool-versions index 6e9c5642..66bce827 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,3 +1,3 @@ -elixir 1.13.4-otp-24 -erlang 24.2 +elixir 1.14.1-otp-25 +erlang 25.1.2 nodejs 16.13.2 diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a1ea4a2..093dad45 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - Make container show page a bit more compact - Make container show page filter used-up ammo - Forgot to add the logo as the favicon whoops +- Update project dependencies, use Elixir v1.14.1 # v0.5.4 - Rename "Ammo" tab to "Catalog", and "Manage" tab is now "Ammo" diff --git a/Dockerfile b/Dockerfile index 7024fc80..76b61f60 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM elixir:1.13.4-alpine AS build +FROM elixir:1.14.1-alpine AS build # install build dependencies RUN apk add --no-cache build-base npm git python3 diff --git a/lib/cannery_web.ex b/lib/cannery_web.ex index 1fbd9a43..d294a5c0 100644 --- a/lib/cannery_web.ex +++ b/lib/cannery_web.ex @@ -96,7 +96,7 @@ defmodule CanneryWeb do # Import LiveView and .heex helpers (live_render, live_patch, <.form>, etc) # credo:disable-for-next-line Credo.Check.Consistency.MultiAliasImportRequireUse - import Phoenix.LiveView.Helpers + import Phoenix.Component # Import basic rendering functionality (render, render_layout, etc) # credo:disable-for-next-line Credo.Check.Consistency.MultiAliasImportRequireUse diff --git a/lib/cannery_web/components/add_shot_group_component.ex b/lib/cannery_web/components/add_shot_group_component.ex index 1500aaf0..0beb3cc4 100644 --- a/lib/cannery_web/components/add_shot_group_component.ex +++ b/lib/cannery_web/components/add_shot_group_component.ex @@ -54,7 +54,7 @@ defmodule CanneryWeb.Components.AddShotGroupComponent do |> case do {:ok, _shot_group} -> prompt = dgettext("prompts", "Shots recorded successfully") - socket |> put_flash(:info, prompt) |> push_redirect(to: return_to) + socket |> put_flash(:info, prompt) |> push_navigate(to: return_to) {:error, %Ecto.Changeset{} = changeset} -> socket |> assign(changeset: changeset) diff --git a/lib/cannery_web/components/add_shot_group_component.html.heex b/lib/cannery_web/components/add_shot_group_component.html.heex index 79fa8b3a..7e0fc219 100644 --- a/lib/cannery_web/components/add_shot_group_component.html.heex +++ b/lib/cannery_web/components/add_shot_group_component.html.heex @@ -4,7 +4,7 @@ <.form - let={f} + :let={f} for={@changeset} id="shot-group-form" class="flex flex-col space-y-4 sm:space-y-0 sm:grid sm:grid-cols-3 sm:gap-4 justify-center items-center" diff --git a/lib/cannery_web/components/ammo_group_card.ex b/lib/cannery_web/components/ammo_group_card.ex index e20842d8..5cb26965 100644 --- a/lib/cannery_web/components/ammo_group_card.ex +++ b/lib/cannery_web/components/ammo_group_card.ex @@ -22,12 +22,11 @@ defmodule CanneryWeb.Components.AmmoGroupCard do border border-gray-400 rounded-lg shadow-lg hover:shadow-md transition-all duration-300 ease-in-out" > - <%= live_patch to: Routes.ammo_group_show_path(Endpoint, :show, @ammo_group), - class: "mb-2 link" do %> + <.link patch={Routes.ammo_group_show_path(Endpoint, :show, @ammo_group)} class="mb-2 link">

<%= @ammo_group.ammo_type.name %>

- <% end %> +
@@ -67,10 +66,12 @@ defmodule CanneryWeb.Components.AmmoGroupCard do <%= gettext("Container:") %> - <%= live_patch to: Routes.container_show_path(Endpoint, :show, @ammo_group.container), - class: "link" do %> + <.link + patch={Routes.container_show_path(Endpoint, :show, @ammo_group.container)} + class="link" + > <%= @ammo_group.container.name %> - <% end %> + <% end %>
diff --git a/lib/cannery_web/components/container_card.ex b/lib/cannery_web/components/container_card.ex index db3af291..b96c0957 100644 --- a/lib/cannery_web/components/container_card.ex +++ b/lib/cannery_web/components/container_card.ex @@ -19,12 +19,11 @@ defmodule CanneryWeb.Components.ContainerCard do transition-all duration-300 ease-in-out" >
- <%= live_redirect to: Routes.container_show_path(Endpoint, :show, @container), - class: "link" do %> + <.link navigate={Routes.container_show_path(Endpoint, :show, @container)} class="link">

<%= @container.name %>

- <% end %> + <%= if @container.desc do %> diff --git a/lib/cannery_web/components/move_ammo_group_component.ex b/lib/cannery_web/components/move_ammo_group_component.ex index 06f6b036..105c990e 100644 --- a/lib/cannery_web/components/move_ammo_group_component.ex +++ b/lib/cannery_web/components/move_ammo_group_component.ex @@ -52,7 +52,7 @@ defmodule CanneryWeb.Components.MoveAmmoGroupComponent do {:ok, _ammo_group} -> prompt = dgettext("prompts", "Ammo moved to %{name} successfully", name: container_name) - socket |> put_flash(:info, prompt) |> push_redirect(to: return_to) + socket |> put_flash(:info, prompt) |> push_navigate(to: return_to) {:error, %Ecto.Changeset{} = changeset} -> socket |> assign(changeset: changeset) @@ -86,10 +86,9 @@ defmodule CanneryWeb.Components.MoveAmmoGroupComponent do <%= display_emoji("😔") %> - <%= live_patch(dgettext("actions", "Add another container!"), - to: Routes.container_index_path(Endpoint, :new), - class: "btn btn-primary" - ) %> + <.link patch={Routes.container_index_path(Endpoint, :new)} class="btn btn-primary"> + <%= dgettext("actions", "Add another container!") %> + <% else %> <.live_component module={CanneryWeb.Components.TableComponent} @@ -122,7 +121,7 @@ defmodule CanneryWeb.Components.MoveAmmoGroupComponent do class="btn btn-primary" phx-click="move" phx-target={@myself} - phx-value-container_id={container.id} + phx-value-container_id={@container.id} > <%= dgettext("actions", "Select") %> diff --git a/lib/cannery_web/components/topbar.ex b/lib/cannery_web/components/topbar.ex index 58438383..2116bf07 100644 --- a/lib/cannery_web/components/topbar.ex +++ b/lib/cannery_web/components/topbar.ex @@ -16,16 +16,17 @@ defmodule CanneryWeb.Components.Topbar do