Skip to content

Commit

Permalink
use Phoenix 1.6 style (#1238)
Browse files Browse the repository at this point in the history
* use Phoenix 1.6 style

Phoenix 1.7 has deprecated Phoenix.View in favor
of Phoenix.Component and moved the get_flash
function out of controllers, making us call it
directly

* fix deprecated LV stuff

Some things have changed in LV, these changes
should address that.

- some helpers have moved to Phoenix.Component (live_flash)
- some syntax changes let={f} vs :let={f}
- live_title_tag is now .live_title
  • Loading branch information
Tuxified authored Nov 21, 2023
1 parent e45eeba commit a958972
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/featureflagservice/lib/featureflagservice_web.ex
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ defmodule FeatureflagserviceWeb do
root: "lib/featureflagservice_web/templates",
namespace: FeatureflagserviceWeb

# Import moved helpers
use Phoenix.Component
# Import convenience functions from controllers
import Phoenix.Controller,
only: [get_flash: 1, get_flash: 2, view_module: 1, view_template: 1]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
--%>

<.form let={f} for={@changeset} action={@action}>
<.form :let={f} for={@changeset} action={@action}>
<%= if @changeset.action do %>
<div class="alert alert-danger">
<p>Oops, something went wrong! Please check the errors below.</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
--%>

<main class="container">
<p class="alert alert-info" role="alert"><%= get_flash(@conn, :info) %></p>
<p class="alert alert-danger" role="alert"><%= get_flash(@conn, :error) %></p>
<p class="alert alert-info" role="alert"><%= Phoenix.Flash.get(@flash, :info) %></p>
<p class="alert alert-danger" role="alert"><%= Phoenix.Flash.get(@flash, :error) %></p>
<%= @inner_content %>
</main>
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta name="csrf-token" content={csrf_token_value()}>
<%= live_title_tag assigns[:page_title] || "Feature flag service" %>
<.live_title>
<%= assigns[:page_title] || "Feature flag service" %>
</.live_title>
<link phx-track-static rel="stylesheet" href={Routes.static_path(@conn, "/assets/app.css")}/>
<script defer phx-track-static type="text/javascript" src={Routes.static_path(@conn, "/assets/app.js")}></script>
</head>
Expand Down
1 change: 1 addition & 0 deletions src/featureflagservice/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ defmodule Featureflagservice.MixProject do
{:phoenix_html, "~> 3.0"},
{:phoenix_live_reload, "~> 1.2", only: :dev},
{:phoenix_live_view, "~> 0.20.0"},
{:phoenix_view, "~> 2.0"},
{:floki, "~> 0.35.0", only: :test},
{:esbuild, "~> 0.8", runtime: Mix.env() == :dev},
{:telemetry_metrics, "~> 0.6"},
Expand Down

0 comments on commit a958972

Please sign in to comment.