Module: RailsErrorDashboard::ApplicationHelper

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

Instance Method Summary collapse

Instance Method Details

#current_user_nameString

Returns the current user name for filtering “My Errors” Uses configured dashboard username or system username

Returns:

  • (String)

    Current user identifier



62
63
64
# File 'app/helpers/rails_error_dashboard/application_helper.rb', line 62

def current_user_name
  RailsErrorDashboard.configuration.dashboard_username || ENV["USER"] || "unknown"
end

#platform_color_var(platform) ⇒ String

Returns platform-specific color class

Parameters:

  • platform (String)

    Platform name (ios, android, web, api)

Returns:

  • (String)

    CSS color variable



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 platform_color_var(platform)
  case platform&.downcase
  when "ios"
    "var(--platform-ios)"
  when "android"
    "var(--platform-android)"
  when "web"
    "var(--platform-web)"
  when "api"
    "var(--platform-api)"
  else
    "var(--text-color)"
  end
end

#severity_color(severity) ⇒ String

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

Parameters:

  • severity (Symbol)

    The severity level (:critical, :high, :medium, :low, :info)

Returns:

  • (String)

    Bootstrap color class (danger, warning, info, secondary)



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/helpers/rails_error_dashboard/application_helper.rb', line 7

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:

  • severity (Symbol)

    The severity level

Returns:

  • (String)

    CSS variable reference



26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/helpers/rails_error_dashboard/application_helper.rb', line 26

def severity_color_var(severity)
  case severity&.to_sym
  when :critical
    "var(--ctp-red)"
  when :high
    "var(--ctp-peach)"
  when :medium
    "var(--ctp-blue)"
  when :low
    "var(--ctp-overlay1)"
  else
    "var(--ctp-overlay1)"
  end
end

#sortable_header(label, column) ⇒ String

Generates a sortable column header link

Parameters:

  • label (String)

    The column label to display

  • column (String)

    The column name to sort by

Returns:

  • (String)

    HTML safe link with sort indicator



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'app/helpers/rails_error_dashboard/application_helper.rb', line 70

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 existing filter params while adding sort params
  link_params = params.permit!.to_h.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