Commit e95326d1 authored by allison.browne's avatar allison.browne

Change format of namespacing

Change format of namespacing to be consistent with other files
parent 3e567872
# frozen_string_literal: true
module Ci::RunnersHelper
def runner_status_icon(runner)
status = runner.status
case status
when :not_connected
content_tag :i, nil,
class: "fa fa-warning",
title: "New runner. Has not connected yet"
module Ci
module RunnersHelper
def runner_status_icon(runner)
status = runner.status
case status
when :not_connected
content_tag :i, nil,
class: "fa fa-warning",
title: "New runner. Has not connected yet"
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"
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
end
end
def runner_link(runner)
display_name = truncate(runner.display_name, length: 15)
id = "\##{runner.id}"
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
if current_user && current_user.admin
link_to admin_runner_path(runner) do
display_name + id
end
else
display_name + id
end
else
display_name + id
end
end
# 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: https://gitlab.com/gitlab-org/gitlab-foss/issues/55920
def runner_contacted_at(runner)
if params[:sort] == 'contacted_asc'
runner.uncached_contacted_at
else
runner.contacted_at
# 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: https://gitlab.com/gitlab-org/gitlab-foss/issues/55920
def runner_contacted_at(runner)
if params[:sort] == 'contacted_asc'
runner.uncached_contacted_at
else
runner.contacted_at
end
end
end
end
......
# frozen_string_literal: true
module EE
module Ci::RunnersHelper
include ::Gitlab::Utils::StrongMemoize
module Ci
module RunnersHelper
include ::Gitlab::Utils::StrongMemoize
BUY_PIPELINE_MINUTES_NOTIFICATION_DOT = 'buy_pipeline_minutes_notification_dot'
BUY_PIPELINE_MINUTES_NOTIFICATION_DOT = 'buy_pipeline_minutes_notification_dot'
def show_buy_pipeline_minutes?(project, namespace)
return false unless experiment_enabled?(:ci_notification_dot) || experiment_enabled?(:buy_ci_minutes_version_a)
def show_buy_pipeline_minutes?(project, namespace)
return false unless experiment_enabled?(:ci_notification_dot) || experiment_enabled?(:buy_ci_minutes_version_a)
show_out_of_pipeline_minutes_notification?(project, namespace)
end
show_out_of_pipeline_minutes_notification?(project, namespace)
end
def show_pipeline_minutes_notification_dot?(project, namespace)
return false unless experiment_enabled?(:ci_notification_dot)
return false if notification_dot_acknowledged?
def show_pipeline_minutes_notification_dot?(project, namespace)
return false unless experiment_enabled?(:ci_notification_dot)
return false if notification_dot_acknowledged?
show_out_of_pipeline_minutes_notification?(project, namespace)
end
show_out_of_pipeline_minutes_notification?(project, namespace)
end
def show_buy_pipeline_with_subtext?(project, namespace)
return false unless experiment_enabled?(:ci_notification_dot)
return false unless notification_dot_acknowledged?
def show_buy_pipeline_with_subtext?(project, namespace)
return false unless experiment_enabled?(:ci_notification_dot)
return false unless notification_dot_acknowledged?
show_out_of_pipeline_minutes_notification?(project, namespace)
end
show_out_of_pipeline_minutes_notification?(project, namespace)
end
private
private
def notification_dot_acknowledged?
strong_memoize(:notification_dot_acknowledged) do
user_dismissed?(BUY_PIPELINE_MINUTES_NOTIFICATION_DOT)
def notification_dot_acknowledged?
strong_memoize(:notification_dot_acknowledged) do
user_dismissed?(BUY_PIPELINE_MINUTES_NOTIFICATION_DOT)
end
end
end
def show_out_of_pipeline_minutes_notification?(project, namespace)
strong_memoize(:show_out_of_pipeline_minutes_notification) do
next unless project&.persisted? || namespace&.persisted?
def show_out_of_pipeline_minutes_notification?(project, namespace)
strong_memoize(:show_out_of_pipeline_minutes_notification) do
next unless project&.persisted? || namespace&.persisted?
::Ci::Minutes::Notification.new(project, namespace).show?(current_user)
::Ci::Minutes::Notification.new(project, namespace).show?(current_user)
end
end
end
end
......
......@@ -16,7 +16,7 @@
- if show_pipeline_minutes_notification_dot?(project, namespace)
- link_class << ' js-follow-link'
%li.js-buy-pipeline-minutes-notification-callout{ data: { feature_id: Ci::RunnersHelper::BUY_PIPELINE_MINUTES_NOTIFICATION_DOT,
%li.js-buy-pipeline-minutes-notification-callout{ data: { feature_id: ::Ci::RunnersHelper::BUY_PIPELINE_MINUTES_NOTIFICATION_DOT,
dismiss_endpoint: user_callouts_path } }
= link_to path, class: link_class, data: data_attributes do
= yield :buy_pipeline_with_subtext
......
......@@ -39,7 +39,7 @@ RSpec.describe 'layouts/header/_current_user_dropdown' do
expect(subject).to have_link('Buy Pipeline minutes')
expect(subject).to have_content('One of your groups is running out')
expect(subject).to have_selector('.js-follow-link')
expect(subject).to have_selector("[data-feature-id='#{Ci::RunnersHelper::BUY_PIPELINE_MINUTES_NOTIFICATION_DOT}']")
expect(subject).to have_selector("[data-feature-id='#{::Ci::RunnersHelper::BUY_PIPELINE_MINUTES_NOTIFICATION_DOT}']")
expect(subject).to have_selector("[data-dismiss-endpoint='#{user_callouts_path}']")
end
end
......@@ -51,7 +51,7 @@ RSpec.describe 'layouts/header/_current_user_dropdown' do
expect(subject).to have_link('Buy Pipeline minutes')
expect(subject).to have_content('One of your groups is running out')
expect(subject).not_to have_selector('.js-follow-link')
expect(subject).not_to have_selector("[data-feature-id='#{Ci::RunnersHelper::BUY_PIPELINE_MINUTES_NOTIFICATION_DOT}']")
expect(subject).not_to have_selector("[data-feature-id='#{::Ci::RunnersHelper::BUY_PIPELINE_MINUTES_NOTIFICATION_DOT}']")
expect(subject).not_to have_selector("[data-dismiss-endpoint='#{user_callouts_path}']")
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment