Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phoenix html 4 #149

Merged
merged 3 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ jobs:
fail-fast: false
matrix:
include:
- elixir: 1.12.3
otp: 24
- elixir: 1.13.4
otp: 24
check_warnings: true
check_format: true
- elixir: 1.14.3
otp: 25.2.1
- elixir: 1.16
otp: 26
check_warnings: true
check_format: true
steps:
Expand Down
16 changes: 11 additions & 5 deletions assets/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion config/test.exs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Config

# Print only warnings and errors during test
config :logger, level: :warn
config :logger, level: :warning

config :exq_ui, DemoWeb.Endpoint,
secret_key_base: "JUrii8hEdYZjAo/LHUziUO1xx0ViDK+I1yYDVvNrLpcYWH93l4kSBvWsbfGwJRu5",
Expand Down
4 changes: 3 additions & 1 deletion lib/exq_ui_web.ex
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ defmodule ExqUIWeb do
defp view_helpers do
quote do
# Use all HTML functionality (forms, tags, etc)
use Phoenix.HTML
import Phoenix.HTML
import Phoenix.HTML.Form
use PhoenixHTMLHelpers

import Phoenix.Component
# Import LiveView helpers (live_render, live_component, live_patch, etc)
Expand Down
7 changes: 3 additions & 4 deletions lib/exq_ui_web/live/busy_live/index.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,9 @@
<td><%= job.pid %></td>
<td><%= job.payload.jid %></td>
<td>
<%= live_redirect(job.queue,
class: "nounderline",
to: Routes.queue_show_path(@socket, job.queue)
) %>
<.link class="nounderline" navigate={Routes.queue_show_path(@socket, job.queue)}>
<%= job.queue %>
</.link>
</td>
<td><%= job.payload.class %></td>
<td><%= inspect(job.payload.args) %></td>
Expand Down
2 changes: 1 addition & 1 deletion lib/exq_ui_web/live/dead_live/index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ defmodule ExqUIWeb.DeadLive.Index do
%{
header: "Last Failed",
accessor: fn item ->
live_redirect(human_time(item.scheduled_at),
live_link(human_time(item.scheduled_at),
to: Routes.dead_show_path(socket, item.score, item.id),
class: "nounderline"
)
Expand Down
7 changes: 3 additions & 4 deletions lib/exq_ui_web/live/queue_live/index.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
<tr>
<td>
<span>
<%= live_redirect(queue.name,
class: "nounderline",
to: Routes.queue_show_path(@socket, queue.name)
) %>
<.link class="nounderline" navigate={Routes.queue_show_path(@socket, queue.name)}>
<%= queue.name %>
</.link>
</span>
</td>
<td><%= queue.count %></td>
Expand Down
2 changes: 1 addition & 1 deletion lib/exq_ui_web/live/retry_live/index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ defmodule ExqUIWeb.RetryLive.Index do
%{
header: "Next Retry",
accessor: fn item ->
live_redirect(human_time(item.scheduled_at),
live_link(human_time(item.scheduled_at),
to: Routes.retry_show_path(socket, item.score, item.id),
class: "nounderline"
)
Expand Down
2 changes: 1 addition & 1 deletion lib/exq_ui_web/live/scheduled_live/index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ defmodule ExqUIWeb.ScheduledLive.Index do
%{
header: "When",
accessor: fn item ->
live_redirect(human_time(item.scheduled_at),
live_link(human_time(item.scheduled_at),
to: Routes.scheduled_show_path(socket, item.score, item.id),
class: "nounderline"
)
Expand Down
4 changes: 3 additions & 1 deletion lib/exq_ui_web/templates/layout/root.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<%= csrf_meta_tag() %>
<%= live_title_tag(assigns[:page_title] || "ExqUI") %>
<.live_title>
<%= assigns[:page_title] || "ExqUI" %>
</.live_title>
<style>
<%= raw(render("app.css")) %>
</style>
Expand Down
19 changes: 16 additions & 3 deletions lib/exq_ui_web/views/helpers.ex
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
defmodule ExqUIWeb.Helpers do
@moduledoc false
use Phoenix.HTML
import Phoenix.LiveView.Helpers

use PhoenixHTMLHelpers
import Phoenix.Component

def nav_link(socket, name, link) do
active =
Expand All @@ -11,7 +12,19 @@ defmodule ExqUIWeb.Helpers do
""
end

live_redirect(name, to: link, class: "nav-link" <> active)
assigns = %{to: link, class: "nav-link" <> active, name: name}

~H|<.link navigate={@to} class={@class}><%= @name %></.link>|
end

def live_link(text, options) do
assigns = %{
to: Keyword.fetch!(options, :to),
class: Keyword.get(options, :class, ""),
text: text
}

~H|<.link navigate={@to} class={@class}><%= @text %></.link>|
end

def human_time(nil) do
Expand Down
3 changes: 2 additions & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ defmodule ExqUI.MixProject do
[
{:exq, ">= 0.16.2"},
{:exq_scheduler, "~> 1.0", optional: true},
{:phoenix_live_view, "~> 0.18"},
{:phoenix_live_view, "~> 0.20"},
{:phoenix_live_reload, "~> 1.2", only: :dev},
{:phoenix_view, "~> 2.0"},
{:phoenix_html_helpers, "~> 1.0"},
{:jason, "~> 1.0"},
{:plug_cowboy, "~> 2.0"},
{:redix, ">= 0.9.0"},
Expand Down
Loading
Loading