Module: Ci::RunnersHelper

Includes:
IconsHelper
Defined in:
app/helpers/ci/runners_helper.rb

Constant Summary

Constants included from IconsHelper

IconsHelper::DEFAULT_ICON_SIZE

Instance Method Summary collapse

Methods included from IconsHelper

#audit_icon, #boolean_to_icon, #custom_icon, #external_snippet_icon, #file_type_icon_class, #gl_loading_icon, #sprite_file_icons_path, #sprite_icon, #sprite_icon_path, #visibility_level_icon

Instance Method Details

#admin_runners_data_attributesObject


61
62
63
64
65
66
67
68
69
70
# File 'app/helpers/ci/runners_helper.rb', line 61

def admin_runners_data_attributes
  {
    # Runner install help page is external, located at
    # https://gitlab.com/gitlab-org/gitlab-runner
    runner_install_help_page: 'https://docs.gitlab.com/runner/install/',
    registration_token: Gitlab::CurrentSettings.runners_registration_token,
    online_contact_timeout_secs: ::Ci::Runner::ONLINE_CONTACT_TIMEOUT.to_i,
    stale_timeout_secs: ::Ci::Runner::STALE_TIMEOUT.to_i
  }
end

#group_runners_data_attributes(group) ⇒ Object


83
84
85
86
87
88
89
90
91
92
# File 'app/helpers/ci/runners_helper.rb', line 83

def group_runners_data_attributes(group)
  {
    registration_token: group.runners_token,
    group_id: group.id,
    group_full_path: group.full_path,
    runner_install_help_page: 'https://docs.gitlab.com/runner/install/',
    online_contact_timeout_secs: ::Ci::Runner::ONLINE_CONTACT_TIMEOUT.to_i,
    stale_timeout_secs: ::Ci::Runner::STALE_TIMEOUT.to_i
  }
end

#group_shared_runners_settings_data(group) ⇒ Object


72
73
74
75
76
77
78
79
80
81
# File 'app/helpers/ci/runners_helper.rb', line 72

def group_shared_runners_settings_data(group)
  {
    update_path: api_v4_groups_path(id: group.id),
    shared_runners_setting: group.shared_runners_setting,
    parent_shared_runners_setting: group.parent&.shared_runners_setting,
    runner_enabled_value: Namespace::SR_ENABLED,
    runner_disabled_value: Namespace::SR_DISABLED_AND_UNOVERRIDABLE,
    runner_allow_override_value: Namespace::SR_DISABLED_WITH_OVERRIDE
  }
end

#runner_contacted_at(runner) ⇒ Object

Due to inability of performing sorting of runners by cached “contacted_at” values we have to show uncached values if sorting by “contacted_asc” is requested. Please refer to the following issue for more details: gitlab.com/gitlab-org/gitlab-foss/issues/55920


53
54
55
56
57
58
59
# File 'app/helpers/ci/runners_helper.rb', line 53

def runner_contacted_at(runner)
  if params[:sort] == 'contacted_asc'
    runner.uncached_contacted_at
  else
    runner.contacted_at
  end
end

38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/helpers/ci/runners_helper.rb', line 38

def runner_link(runner)
  display_name = truncate(runner.display_name, length: 15)
  id = "\##{runner.id}"

  if current_user && current_user.admin
    link_to admin_runner_path(runner) do
      display_name + id
    end
  else
    display_name + id
  end
end

#runner_status_icon(runner, size: 16, icon_class: '') ⇒ Object


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/helpers/ci/runners_helper.rb', line 7

def runner_status_icon(runner, size: 16, icon_class: '')
  status = runner.status
  contacted_at = runner.contacted_at

  title = ''
  icon = 'warning-solid'
  span_class = ''

  case status
  when :online
    title = s_("Runners|Runner is online; last contact was %{runner_contact} ago") % { runner_contact: time_ago_in_words(contacted_at) }
    icon = 'status-active'
    span_class = 'gl-text-green-500'
  when :not_connected, :never_contacted
    title = s_("Runners|Runner has never contacted this instance")
    icon = 'warning-solid'
  when :offline
    title = s_("Runners|Runner is offline; last contact was %{runner_contact} ago") % { runner_contact: time_ago_in_words(contacted_at) }
    icon = 'status-failed'
    span_class = 'gl-text-red-500'
  when :stale
    # runner may have contacted (or not) and be stale: consider both cases.
    title = contacted_at ? s_("Runners|Runner is stale; last contact was %{runner_contact} ago") % { runner_contact: time_ago_in_words(contacted_at) } : s_("Runners|Runner is stale; it has never contacted this instance")
    icon = 'warning-solid'
  end

  (:span, class: span_class, title: title, data: { toggle: 'tooltip', container: 'body', testid: 'runner_status_icon', qa_selector: "runner_status_#{status}_content" }) do
    sprite_icon(icon, size: size, css_class: icon_class)
  end
end

#toggle_shared_runners_settings_data(project) ⇒ Object


94
95
96
97
98
99
100
# File 'app/helpers/ci/runners_helper.rb', line 94

def toggle_shared_runners_settings_data(project)
  {
    is_enabled: "#{project.shared_runners_enabled?}",
    is_disabled_and_unoverridable: "#{project.group&.shared_runners_setting == Namespace::SR_DISABLED_AND_UNOVERRIDABLE}",
    update_path: toggle_shared_runners_project_runners_path(project)
  }
end