Skip to content

Commit

Permalink
Add GoodJob::Job#display_name to allow customizing dashboard job di…
Browse files Browse the repository at this point in the history
…splay (#1008)

* Added BaseExecution#job_display_name

* Narrow to `GoodJob::Job#display_name` and remove documentation from readme

---------

Co-authored-by: Ben Sheldon [he/him] <[email protected]>
  • Loading branch information
paul and bensheldon authored Jul 13, 2023
1 parent f0891a6 commit 3ce19f2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions app/models/good_job/job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,12 @@ def display_serialized_params
})
end

# Used when displaying this job in the GoodJob dashboard.
# @return [String]
def display_name
job_class
end

# Tests whether the job is being executed right now.
# @return [Boolean]
def running?
Expand Down
2 changes: 1 addition & 1 deletion app/views/good_job/batches/_jobs.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<div class="row align-items-center">
<div class="col-lg-4">
<%= tag.code link_to(job.id, job_path(job), class: "small text-muted text-decoration-none") %>
<%= tag.h5 tag.code(link_to(job.job_class, job_path(job), class: "text-reset text-decoration-none")), class: "text-reset mb-0" %>
<%= tag.h5 tag.code(link_to(job.display_name, job_path(job), class: "text-reset text-decoration-none")), class: "text-reset mb-0" %>
</div>
<div class="col-4 col-lg-1 text-lg-center">
<div class="d-lg-none small text-muted mt-1"><%=t "good_job.models.job.queue" %></div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/good_job/jobs/_table.erb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<%= check_box_tag 'job_ids[]', job.id, false, id: dom_id(job, :checkbox), data: { "checkbox-toggle-each": "job_ids" } %>
<div class="ms-2">
<%= tag.code link_to(job.id, job_path(job), class: "small text-muted text-decoration-none") %>
<%= tag.h5 tag.code(link_to(job.job_class, job_path(job), class: "text-reset text-decoration-none")), class: "text-reset mb-0" %>
<%= tag.h5 tag.code(link_to(job.display_name, job_path(job), class: "text-reset text-decoration-none")), class: "text-reset mb-0" %>
<% if job.error %>
<div class="mt-1 small">
<strong class="small"><%=t "good_job.shared.error" %>:</strong>
Expand Down
2 changes: 1 addition & 1 deletion app/views/good_job/jobs/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</nav>
<div class="row align-items-center">
<div class="col-md-5">
<h2 class="mb-2 mb-md-0"><%= tag.code @job.job_class %></h2>
<h2 class="mb-2 mb-md-0"><%= tag.code @job.display_name %></h2>
</div>
<div class="col-6 col-md-2">
<div class="small text-muted text-uppercase"><%= t "good_job.models.job.queue" %></div>
Expand Down

0 comments on commit 3ce19f2

Please sign in to comment.