Module: Ci::StatusHelper

Defined in:
app/helpers/ci/status_helper.rb

Instance Method Summary collapse

Instance Method Details

#ci_icon_for_status(status, size: 24) ⇒ Object

rubocop:disable Metrics/CyclomaticComplexity



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'app/helpers/ci/status_helper.rb', line 13

def ci_icon_for_status(status, size: 24)
  icon_name =
    if detailed_status?(status)
      status.icon
    else
      case status
      when 'success'
        'status_success'
      when 'success-with-warnings'
        'status_warning'
      when 'failed'
        'status_failed'
      when 'pending'
        'status_pending'
      when 'waiting-for-resource'
        'status_pending'
      when 'preparing'
        'status_preparing'
      when 'running'
        'status_running'
      when 'play'
        'play'
      when 'created'
        'status_created'
      when 'skipped'
        'status_skipped'
      when 'manual'
        'status_manual'
      when 'scheduled'
        'status_scheduled'
      else
        'status_canceled'
      end
    end

  icon_name = icon_name == 'play' ? icon_name : "#{icon_name}_borderless"

  sprite_icon(icon_name, size: size, css_class: 'gl-icon')
end

#render_ci_icon(status, path = nil, tooltip_placement: 'left', option_css_classes: '', container: 'body', show_status_text: false) ⇒ Object



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'app/helpers/ci/status_helper.rb', line 66

def render_ci_icon(
  status,
  path = nil,
  tooltip_placement: 'left',
  option_css_classes: '',
  container: 'body',
  show_status_text: false
)
   = path ? :a : :span
  variant = badge_variant(status)
  badge_classes = "ci-icon ci-icon-variant-#{variant} gl-inline-flex gl-items-center gl-text-sm #{option_css_classes}"
  title = "#{_('Pipeline')}: #{ci_label_for_status(status)}"
  data = { toggle: 'tooltip', placement: tooltip_placement, container: container, testid: 'ci-icon' }

  icon_wrapper_class = "ci-icon-gl-icon-wrapper"

  (, href: path, class: badge_classes, title: title, data: data) do
    if show_status_text
      (:span, ci_icon_for_status(status), { class: icon_wrapper_class }) + (:span, status.label, { class: 'gl-mx-2 gl-whitespace-nowrap gl-leading-1 gl-self-center', data: { testid: 'ci-icon-text' } })
    else
      (:span, ci_icon_for_status(status), { class: icon_wrapper_class })
    end
  end
end

#render_commit_status(commit, status, ref: nil, tooltip_placement: 'left') ⇒ Object

rubocop:enable Metrics/CyclomaticComplexity



54
55
56
57
58
59
60
61
62
63
64
# File 'app/helpers/ci/status_helper.rb', line 54

def render_commit_status(commit, status, ref: nil, tooltip_placement: 'left')
  project = commit.project
  path = pipelines_project_commit_path(project, commit, ref: ref)

  render_ci_icon(
    status,
    path,
    tooltip_placement: tooltip_placement,
    option_css_classes: 'gl-ml-3'
  )
end