Module: Protege::ResponsibilitiesHelper

Included in:
ApplicationHelper
Defined in:
app/helpers/protege/responsibilities_helper.rb

Overview

View helpers for responsibility pages — status display and run-history formatting.

Instance Method Summary collapse

Instance Method Details

#all_responsibilitiesActiveRecord::Relation<Protege::Responsibility>

Fetch every Responsibility (persona eager-loaded) for the global sidebar listing. The model's default scope already orders by name.

Returns:



10
11
12
# File 'app/helpers/protege/responsibilities_helper.rb', line 10

def all_responsibilities
  Responsibility.includes(:persona)
end

#responsibility_runs_table(responsibility) ⇒ Protege::Components::TablesHelper::Table

Build the responsibility Show page's recent-runs table — its headers and one [status badge, when, detail link] row per run, newest first (capped at ten).

Parameters:

Returns:



40
41
42
43
44
45
46
47
48
49
50
51
# File 'app/helpers/protege/responsibilities_helper.rb', line 40

def responsibility_runs_table(responsibility)
  rows = responsibility.responsibility_runs.order(created_at: :desc).limit(10).map do |run|
    [
      run_status_badge(run),
      run.correlation_id,
      run_time(run),
      ui_link('Details', responsibility_run_path(run))
    ]
  end

  Components::TablesHelper::Table.new(headers: ['Status', 'Correlation ID', 'When', ''], rows:)
end

#responsibility_status(responsibility) ⇒ ActiveSupport::SafeBuffer

Render a status dot reflecting whether a responsibility is active.

Parameters:

Returns:

  • (ActiveSupport::SafeBuffer)

    a green dot when active, grey when paused



18
19
20
21
22
23
24
# File 'app/helpers/protege/responsibilities_helper.rb', line 18

def responsibility_status(responsibility)
  if responsibility.active?
    status_dot('Active', :green)
  else
    status_dot('Paused', :gray)
  end
end

#run_status_badge(run) ⇒ ActiveSupport::SafeBuffer

Render a run's status as a colour-coded badge.

Parameters:

Returns:

  • (ActiveSupport::SafeBuffer)

    the badge markup



30
31
32
33
# File 'app/helpers/protege/responsibilities_helper.rb', line 30

def run_status_badge(run)
  colors = { 'completed' => :green, 'failed' => :red, 'running' => :gray, 'pending' => :gray }
  badge(run.status, colors.fetch(run.status, :gray))
end