Commit b34b8007 authored by Serena Fang's avatar Serena Fang

Show banner on group pages

Also fix namespace helper and add specs
parent 3acc9f22
...@@ -88,8 +88,9 @@ module NamespacesHelper ...@@ -88,8 +88,9 @@ module NamespacesHelper
}.to_json }.to_json
end end
def show_minute_limit_banner?(project) def show_minute_limit_banner?(namespace)
return true if project.project_namespace.free_plan? return false unless ::Feature.enabled?(:show_minute_limit_banner)
return true if namespace.root_ancestor.free_plan? && !minute_limit_banner_dismissed?
false false
end end
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
- expanded = expanded_by_default? - expanded = expanded_by_default?
= render 'shared/namespaces/cascading_settings/lock_popovers' = render 'shared/namespaces/cascading_settings/lock_popovers'
= render_if_exists 'shared/minute_limit_banner', namespace: @group
%section.settings.gs-general.no-animate.expanded#js-general-settings %section.settings.gs-general.no-animate.expanded#js-general-settings
.settings-header .settings-header
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
- expanded = expanded_by_default? - expanded = expanded_by_default?
- general_expanded = @group.errors.empty? ? expanded : true - general_expanded = @group.errors.empty? ? expanded : true
= render_if_exists 'shared/minute_limit_banner', namespace: @group
-# Given we only have one field in this form which is also admin-only, -# Given we only have one field in this form which is also admin-only,
-# we don't want to show an empty section to non-admin users, -# we don't want to show an empty section to non-admin users,
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
= render_if_exists 'shared/qrtly_reconciliation_alert', group: @group = render_if_exists 'shared/qrtly_reconciliation_alert', group: @group
= render_if_exists 'shared/user_over_limit_free_plan_alert', source: @group = render_if_exists 'shared/user_over_limit_free_plan_alert', source: @group
= render_if_exists 'shared/minute_limit_banner', namespace: @group
- if show_invite_banner?(@group) - if show_invite_banner?(@group)
= content_for :group_invite_members_banner do = content_for :group_invite_members_banner do
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
- expanded = expanded_by_default? - expanded = expanded_by_default?
- reduce_visibility_form_id = 'reduce-visibility-form' - reduce_visibility_form_id = 'reduce-visibility-form'
= render_if_exists 'shared/minute_limit_banner', project: @project = render_if_exists 'shared/minute_limit_banner', namespace: @project
%section.settings.general-settings.no-animate.expanded#js-general-settings %section.settings.general-settings.no-animate.expanded#js-general-settings
.settings-header .settings-header
......
= render_if_exists 'shared/minute_limit_banner', project: @project = render_if_exists 'shared/minute_limit_banner', namespace: @project
- page_title _("Jobs") - page_title _("Jobs")
- add_page_specific_style 'page_bundles/ci_status' - add_page_specific_style 'page_bundles/ci_status'
......
= render_if_exists 'shared/minute_limit_banner', project: @project = render_if_exists 'shared/minute_limit_banner', namespace: @project
- breadcrumb_title _("Schedules") - breadcrumb_title _("Schedules")
- page_title _("Pipeline Schedules") - page_title _("Pipeline Schedules")
......
= render_if_exists 'shared/minute_limit_banner', project: @project = render_if_exists 'shared/minute_limit_banner', namespace: @project
- page_title _('Pipelines') - page_title _('Pipelines')
- add_page_specific_style 'page_bundles/pipelines' - add_page_specific_style 'page_bundles/pipelines'
......
= render_if_exists 'shared/minute_limit_banner', project: @project = render_if_exists 'shared/minute_limit_banner', namespace: @project
- @content_class = "limit-container-width" unless fluid_layout - @content_class = "limit-container-width" unless fluid_layout
- page_title _("CI/CD Settings") - page_title _("CI/CD Settings")
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
= auto_discovery_link_tag(:atom, project_path(@project, rss_url_options), title: "#{@project.name} activity") = auto_discovery_link_tag(:atom, project_path(@project, rss_url_options), title: "#{@project.name} activity")
= render_if_exists 'shared/user_over_limit_free_plan_alert', source: @project = render_if_exists 'shared/user_over_limit_free_plan_alert', source: @project
= render_if_exists 'shared/minute_limit_banner', project: @project = render_if_exists 'shared/minute_limit_banner', namespace: @project
= render partial: 'flash_messages', locals: { project: @project } = render partial: 'flash_messages', locals: { project: @project }
= render "projects/last_push" = render "projects/last_push"
......
- if show_minute_limit_banner?(project) - if show_minute_limit_banner?(namespace)
.container-fluid.container-limited.pt-3 .container-fluid.container-limited.pt-3
= render Pajamas::AlertComponent.new(title: s_("Free tier projects CI minutes quota"), = render Pajamas::AlertComponent.new(title: s_("Free tier projects CI minutes quota"),
alert_class: 'gl-mt-5 js-minute-limit-banner', alert_class: 'gl-mt-5 js-minute-limit-banner',
......
...@@ -272,28 +272,63 @@ RSpec.describe NamespacesHelper do ...@@ -272,28 +272,63 @@ RSpec.describe NamespacesHelper do
describe '#show_minute_limit_banner?' do describe '#show_minute_limit_banner?' do
let(:project) { create(:project) } let(:project) { create(:project) }
context 'when show_minute_limit_banner feature flag enabled' do
before do before do
stub_feature_flags(show_minute_limit_banner: true) stub_feature_flags(show_minute_limit_banner: true)
end end
context 'for a free project' do context 'for a free project' do
before do before do
allow(project.project_namespace).to receive(:free_plan?).and_return(true) allow(project.root_ancestor).to receive(:free_plan?).and_return(true)
end end
it 'returns true' do context 'when user has not dismissed banner' do
before do
allow(helper).to receive(:user_dismissed?).with(Users::CalloutsHelper::MINUTE_LIMIT_BANNER).and_return(false)
end
it 'shows the banner' do
expect(helper.show_minute_limit_banner?(project)).to eq(true) expect(helper.show_minute_limit_banner?(project)).to eq(true)
end end
end end
context 'when user has dismissed banner' do
before do
allow(helper).to receive(:user_dismissed?).with(Users::CalloutsHelper::MINUTE_LIMIT_BANNER).and_return(true)
end
it 'does not show the banner' do
expect(helper.show_minute_limit_banner?(project)).to eq(false)
end
end
end
context 'for a non-free project' do context 'for a non-free project' do
before do before do
allow(project.project_namespace).to receive(:free_plan?).and_return(false) allow(project.root_ancestor).to receive(:free_plan?).and_return(false)
end end
it 'returns false' do it 'does not show the banner' do
expect(helper.show_minute_limit_banner?(project)).to eq(false) expect(helper.show_minute_limit_banner?(project)).to eq(false)
end end
end end
end end
context 'when show_minute_limit_banner feature flag is not enabled' do
before do
stub_feature_flags(show_minute_limit_banner: false)
end
context 'for a free project and user has not dismissed callout' do
before do
allow(project.root_ancestor).to receive(:free_plan?).and_return(true)
allow(helper).to receive(:user_dismissed?).with(Users::CalloutsHelper::MINUTE_LIMIT_BANNER).and_return(false)
end
it 'does not show banner' do
expect(helper.show_minute_limit_banner?(project)).to eq(false)
end
end
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