2018-08-18 07:19:57 -04:00
# frozen_string_literal: true
2015-09-29 10:26:40 -04:00
module RunnersHelper
def runner_status_icon ( runner )
2015-10-12 15:12:31 -04:00
status = runner . status
case status
when :not_connected
content_tag :i , nil ,
2015-10-14 07:51:29 -04:00
class : " fa fa-warning " ,
2015-10-12 15:12:31 -04:00
title : " New runner. Has not connected yet "
2015-09-29 10:26:40 -04:00
2015-10-12 15:12:31 -04:00
when :online , :offline , :paused
content_tag :i , nil ,
class : " fa fa-circle runner-status- #{ status } " ,
title : " Runner is #{ status } , last contact was #{ time_ago_in_words ( runner . contacted_at ) } ago "
end
2015-09-29 10:26:40 -04:00
end
2015-10-14 06:15:03 -04:00
def runner_link ( runner )
2015-10-15 11:13:36 -04:00
display_name = truncate ( runner . display_name , length : 15 )
2015-10-14 06:15:03 -04:00
id = " \# #{ runner . id } "
if current_user && current_user . admin
2015-12-04 06:55:23 -05:00
link_to admin_runner_path ( runner ) do
2015-10-14 06:15:03 -04:00
display_name + id
end
else
display_name + id
end
end
2019-01-04 00:54:45 -05:00
# 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.
2019-09-18 10:02:45 -04:00
# Please refer to the following issue for more details: https://gitlab.com/gitlab-org/gitlab-foss/issues/55920
2019-01-04 00:54:45 -05:00
def runner_contacted_at ( runner )
if params [ :sort ] == 'contacted_asc'
runner . uncached_contacted_at
else
runner . contacted_at
end
end
2015-09-29 10:26:40 -04:00
end
2019-09-13 09:26:31 -04:00
RunnersHelper . prepend_if_ee ( 'EE::RunnersHelper' )