Module: GoodJob::IconsHelper

Included in:
ApplicationHelper
Defined in:
app/helpers/good_job/icons_helper.rb

Constant Summary collapse

STATUS_ICONS =
{
  discarded: "exclamation",
  succeeded: "check",
  queued: "dash_circle",
  retried: "arrow_clockwise",
  running: "play",
  scheduled: "clock",
}.freeze
STATUS_COLOR =
{
  discarded: "danger",
  succeeded: "success",
  queued: "secondary",
  retried: "warning",
  running: "primary",
  scheduled: "secondary",
}.freeze

Instance Method Summary collapse

Instance Method Details

#render_icon(name, **options) ⇒ Object



34
35
36
37
38
39
# File 'app/helpers/good_job/icons_helper.rb', line 34

def render_icon(name, **options)
  # workaround to render svg icons without all of the log messages
  partial = lookup_context.find_template("good_job/shared/icons/#{name}", [], true)
  options[:class] = Array(options[:class]).join(" ")
  partial.render(self, { class: options[:class] })
end

#status_badge(status) ⇒ Object



23
24
25
26
# File 'app/helpers/good_job/icons_helper.rb', line 23

def status_badge(status)
   :span, status_icon(status, class: "text-white") + t(status, scope: 'good_job.status', count: 1),
              class: "badge rounded-pill bg-#{STATUS_COLOR.fetch(status)} d-inline-flex gap-2 ps-1 pe-3 align-items-center"
end

#status_icon(status, **options) ⇒ Object



28
29
30
31
32
# File 'app/helpers/good_job/icons_helper.rb', line 28

def status_icon(status, **options)
  options[:class] ||= "text-#{STATUS_COLOR.fetch(status)}"
  icon = render_icon STATUS_ICONS.fetch(status)
   :span, icon, **options
end