Module: RailsErrorDashboard::ApplicationHelper

Defined in:
app/helpers/rails_error_dashboard/application_helper.rb

Instance Method Summary collapse



20
21
22
23
24
25
26
27
28
# File 'app/helpers/rails_error_dashboard/application_helper.rb', line 20

def red_javascript_tag(&block)
  nonce = red_csp_nonce
  content = capture(&block)
  if nonce
    (:script, content.html_safe, nonce: nonce)
  else
    (:script, content.html_safe)
  end
end

#severity_color(severity) ⇒ String

Returns Bootstrap color class for error severity Uses Catppuccin Mocha colors in dark theme via CSS variables

Parameters:

Returns:



44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'app/helpers/rails_error_dashboard/application_helper.rb', line 44

def severity_color(severity)
  case severity&.to_sym
  when :critical
    "danger"   # Maps to --ctp-red in dark mode
  when :high
    "warning"  # Maps to --ctp-peach in dark mode
  when :medium
    "info"     # Maps to --ctp-blue in dark mode
  when :low
    "secondary" # Maps to --ctp-overlay1 in dark mode
  else
    "secondary"
  end
end

#severity_color_var(severity) ⇒ String

Returns CSS variable for severity color (for inline styles) Useful when you need to set background-color or color directly

Parameters:

Returns:



63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'app/helpers/rails_error_dashboard/application_helper.rb', line 63

def severity_color_var(severity)
  case severity&.to_sym
  when :critical
    "var(--status-critical)"
  when :high
    "var(--status-warning)"
  when :medium
    "var(--status-info)"
  when :low
    "var(--text-tertiary)"
  else
    "var(--text-tertiary)"
  end
end

#sortable_header(label, column) ⇒ String

Generates a sortable column header link

Parameters:

Returns:



134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'app/helpers/rails_error_dashboard/application_helper.rb', line 134

def sortable_header(label, column)
  current_sort = params[:sort_by]
  current_direction = params[:sort_direction] || "desc"

  # Determine new direction: if clicking same column, toggle; otherwise default to desc
  new_direction = if current_sort == column
    current_direction == "asc" ? "desc" : "asc"
  else
    "desc"
  end

  # Choose icon based on current state
  icon = if current_sort == column
    current_direction == "asc" ? "" : ""
  else
    ""  # Unsorted indicator
  end

  # Preserve whitelisted filter params while adding sort params
  link_params = permitted_filter_params.merge(sort_by: column, sort_direction: new_direction)

  link_to errors_path(link_params), class: "text-decoration-none" do
    (:span, "#{label} ", class: current_sort == column ? "fw-bold" : "") +
    (:span, icon, class: "text-muted small")
  end
end