Skip to content

Commit 06514f3

Browse files
committed
Show cron name in header when it differs
1 parent ac7c666 commit 06514f3

5 files changed

Lines changed: 15 additions & 9 deletions

File tree

lib/oban/web/live/crons/detail_component.ex

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
defmodule Oban.Web.Crons.DetailComponent do
22
use Oban.Web, :live_component
33

4-
import Oban.Web.Crons.Helpers, only: [state_icon: 1, maybe_to_unix: 1]
4+
import Oban.Web.Crons.Helpers, only: [state_icon: 1, maybe_to_unix: 1, show_name?: 1]
55
import Oban.Web.FormComponents
66

77
alias Oban.Job
@@ -23,7 +23,12 @@ defmodule Oban.Web.Crons.DetailComponent do
2323
phx-hook="Tippy"
2424
>
2525
<Icons.arrow_left class="w-5 h-5" />
26-
<span class="text-lg font-bold ml-2">{@cron.worker}</span>
26+
<span class="text-lg font-bold ml-2">
27+
{@cron.worker}
28+
<span :if={show_name?(@cron)} class="font-normal text-gray-500 dark:text-gray-400">
29+
({@cron.name})
30+
</span>
31+
</span>
2732
</.link>
2833
2934
<div class="flex space-x-3">

lib/oban/web/live/crons/helpers.ex

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,7 @@ defmodule Oban.Web.Crons.Helpers do
4747
|> DateTime.from_naive!("Etc/UTC")
4848
|> DateTime.to_unix(:millisecond)
4949
end
50+
51+
def show_name?(%{dynamic?: true, name: name, worker: worker}), do: name != worker
52+
def show_name?(_cron), do: false
5053
end

lib/oban/web/live/queues/detail_instance_component.ex

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,5 +203,4 @@ defmodule Oban.Web.Queues.DetailInstanceComponent do
203203

204204
{:noreply, assign(socket, local_limit: limit, editing?: false)}
205205
end
206-
207206
end

lib/oban/web/pages/crons_page.ex

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ defmodule Oban.Web.CronsPage do
33

44
use Oban.Web, :live_component
55

6-
import Oban.Web.Crons.Helpers, only: [maybe_to_unix: 1, state_icon: 1]
6+
import Oban.Web.Crons.Helpers, only: [maybe_to_unix: 1, show_name?: 1, state_icon: 1]
77

88
alias Oban.Web.Crons.{DetailComponent, NewComponent}
99
alias Oban.Web.{Cron, CronQuery, Page, QueueQuery, SearchComponent, SortComponent, Utils}
@@ -503,8 +503,4 @@ defmodule Oban.Web.CronsPage do
503503
defp has_tags?(opts), do: Map.has_key?(opts, "tags") and opts["tags"] != []
504504

505505
defp get_tags(opts), do: Map.get(opts, "tags", [])
506-
507-
defp show_name?(%{dynamic?: true, name: name, worker: worker}), do: name != worker
508-
509-
defp show_name?(_cron), do: false
510506
end

test/oban/web/pages/queues/detail_test.exs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,10 @@ defmodule Oban.Web.Pages.Queues.DetailTest do
108108

109109
live
110110
|> form("#global-form")
111-
|> render_submit(%{global_partition_fields: "meta,worker", global_partition_keys: "tenant_id"})
111+
|> render_submit(%{
112+
global_partition_fields: "meta,worker",
113+
global_partition_keys: "tenant_id"
114+
})
112115

113116
assert_signal(%{
114117
"action" => "scale",

0 commit comments

Comments
 (0)