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 # frozen_string_literal: true
module Ci::RunnersHelper module Ci
def runner_status_icon(runner) module RunnersHelper
status = runner.status def runner_status_icon(runner)
case status status = runner.status
when :not_connected case status
content_tag :i, nil, when :not_connected
class: "fa fa-warning", content_tag :i, nil,
title: "New runner. Has not connected yet" class: "fa fa-warning",
title: "New runner. Has not connected yet"
when :online, :offline, :paused when :online, :offline, :paused
content_tag :i, nil, content_tag :i, nil,
class: "fa fa-circle runner-status-#{status}", class: "fa fa-circle runner-status-#{status}",
title: "Runner is #{status}, last contact was #{time_ago_in_words(runner.contacted_at)} ago" title: "Runner is #{status}, last contact was #{time_ago_in_words(runner.contacted_at)} ago"
end
end end
end
def runner_link(runner) def runner_link(runner)
display_name = truncate(runner.display_name, length: 15) display_name = truncate(runner.display_name, length: 15)
id = "\##{runner.id}" id = "\##{runner.id}"
if current_user && current_user.admin if current_user && current_user.admin
link_to admin_runner_path(runner) do link_to admin_runner_path(runner) do
display_name + id
end
else
display_name + id display_name + id
end end
else
display_name + id
end 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. # 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 # Please refer to the following issue for more details: https://gitlab.com/gitlab-org/gitlab-foss/issues/55920
def runner_contacted_at(runner) def runner_contacted_at(runner)
if params[:sort] == 'contacted_asc' if params[:sort] == 'contacted_asc'
runner.uncached_contacted_at runner.uncached_contacted_at
else else
runner.contacted_at runner.contacted_at
end
end end
end end
end end
......
# frozen_string_literal: true # frozen_string_literal: true
module EE module EE
module Ci::RunnersHelper module Ci
include ::Gitlab::Utils::StrongMemoize 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) def show_buy_pipeline_minutes?(project, namespace)
return false unless experiment_enabled?(:ci_notification_dot) || experiment_enabled?(:buy_ci_minutes_version_a) return false unless experiment_enabled?(:ci_notification_dot) || experiment_enabled?(:buy_ci_minutes_version_a)
show_out_of_pipeline_minutes_notification?(project, namespace) show_out_of_pipeline_minutes_notification?(project, namespace)
end end
def show_pipeline_minutes_notification_dot?(project, namespace) def show_pipeline_minutes_notification_dot?(project, namespace)
return false unless experiment_enabled?(:ci_notification_dot) return false unless experiment_enabled?(:ci_notification_dot)
return false if notification_dot_acknowledged? return false if notification_dot_acknowledged?
show_out_of_pipeline_minutes_notification?(project, namespace) show_out_of_pipeline_minutes_notification?(project, namespace)
end end
def show_buy_pipeline_with_subtext?(project, namespace) def show_buy_pipeline_with_subtext?(project, namespace)
return false unless experiment_enabled?(:ci_notification_dot) return false unless experiment_enabled?(:ci_notification_dot)
return false unless notification_dot_acknowledged? return false unless notification_dot_acknowledged?
show_out_of_pipeline_minutes_notification?(project, namespace) show_out_of_pipeline_minutes_notification?(project, namespace)
end end
private private
def notification_dot_acknowledged? def notification_dot_acknowledged?
strong_memoize(:notification_dot_acknowledged) do strong_memoize(:notification_dot_acknowledged) do
user_dismissed?(BUY_PIPELINE_MINUTES_NOTIFICATION_DOT) user_dismissed?(BUY_PIPELINE_MINUTES_NOTIFICATION_DOT)
end
end end
end
def show_out_of_pipeline_minutes_notification?(project, namespace) def show_out_of_pipeline_minutes_notification?(project, namespace)
strong_memoize(:show_out_of_pipeline_minutes_notification) do strong_memoize(:show_out_of_pipeline_minutes_notification) do
next unless project&.persisted? || namespace&.persisted? 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 end
end end
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
- if show_pipeline_minutes_notification_dot?(project, namespace) - if show_pipeline_minutes_notification_dot?(project, namespace)
- link_class << ' js-follow-link' - 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 } } dismiss_endpoint: user_callouts_path } }
= link_to path, class: link_class, data: data_attributes do = link_to path, class: link_class, data: data_attributes do
= yield :buy_pipeline_with_subtext = yield :buy_pipeline_with_subtext
......
...@@ -39,7 +39,7 @@ RSpec.describe 'layouts/header/_current_user_dropdown' do ...@@ -39,7 +39,7 @@ RSpec.describe 'layouts/header/_current_user_dropdown' do
expect(subject).to have_link('Buy Pipeline minutes') expect(subject).to have_link('Buy Pipeline minutes')
expect(subject).to have_content('One of your groups is running out') 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('.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}']") expect(subject).to have_selector("[data-dismiss-endpoint='#{user_callouts_path}']")
end end
end end
...@@ -51,7 +51,7 @@ RSpec.describe 'layouts/header/_current_user_dropdown' do ...@@ -51,7 +51,7 @@ RSpec.describe 'layouts/header/_current_user_dropdown' do
expect(subject).to have_link('Buy Pipeline minutes') expect(subject).to have_link('Buy Pipeline minutes')
expect(subject).to have_content('One of your groups is running out') 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('.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}']") expect(subject).not_to have_selector("[data-dismiss-endpoint='#{user_callouts_path}']")
end end
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