Commit 3aa7e9aa authored by Alex Kalderimis's avatar Alex Kalderimis

Merge branch '341949-in-app-awareness-of-registration-features-feature-based-cta' into 'master'

Update Registration Features CTA for repository size limit

See merge request gitlab-org/gitlab!77355
parents 80a8d862 916bbaf1
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
= f.label :max_attachment_size, _('Maximum attachment size (MB)'), class: 'label-bold' = f.label :max_attachment_size, _('Maximum attachment size (MB)'), class: 'label-bold'
= f.number_field :max_attachment_size, class: 'form-control gl-form-input', title: _('Maximum size of individual attachments in comments.'), data: { toggle: 'tooltip', container: 'body' } = f.number_field :max_attachment_size, class: 'form-control gl-form-input', title: _('Maximum size of individual attachments in comments.'), data: { toggle: 'tooltip', container: 'body' }
= render 'admin/application_settings/repository_size_limit_setting_registration_features_cta', form: f
= render_if_exists 'admin/application_settings/repository_size_limit_setting', form: f = render_if_exists 'admin/application_settings/repository_size_limit_setting', form: f
.form-group .form-group
......
- return unless registration_features_can_be_prompted?
.form-group
= form.label :disabled_repository_size_limit, class: 'label-bold' do
= _('Size limit per repository (MB)')
= form.number_field :disabled_repository_size_limit, value: '', class: 'form-control gl-form-input', disabled: true
%span.form-text.text-muted
= render 'shared/registration_features_discovery_message'
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
= f.text_area :description, class: 'form-control', rows: 3, maxlength: 250 = f.text_area :description, class: 'form-control', rows: 3, maxlength: 250
.form-text.text-muted= _('Optional.') .form-text.text-muted= _('Optional.')
= render 'shared/repository_size_limit_setting_registration_features_cta', form: f
= render_if_exists 'shared/repository_size_limit_setting', form: f, type: :group = render_if_exists 'shared/repository_size_limit_setting', form: f, type: :group
.form-group.gl-mt-3.gl-mb-6 .form-group.gl-mt-3.gl-mb-6
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
.row= render_if_exists 'projects/classification_policy_settings', f: f .row= render_if_exists 'projects/classification_policy_settings', f: f
= render 'shared/repository_size_limit_setting_registration_features_cta', form: f
= render_if_exists 'shared/repository_size_limit_setting', form: f, type: :project = render_if_exists 'shared/repository_size_limit_setting', form: f, type: :project
.form-group.gl-mt-3.gl-mb-3 .form-group.gl-mt-3.gl-mb-3
......
- feature_title = local_assigns.fetch(:feature_title, s_('RegistrationFeatures|use this feature')) - feature_title = local_assigns.fetch(:feature_title, s_('RegistrationFeatures|use this feature'))
- registration_features_docs_path = help_page_path('development/service_ping/index.md', anchor: 'registration-features-program') - registration_features_docs_path = help_page_path('development/service_ping/index.md', anchor: 'registration-features-program')
- service_ping_settings_path = metrics_and_profiling_admin_application_settings_path(anchor: 'js-usage-settings') - registration_features_link_start = '<a href="%{url}" target="_blank">'.html_safe % { url: registration_features_docs_path }
%div %div
%span= sprintf(s_('RegistrationFeatures|Want to %{feature_title} for free?'), { feature_title: feature_title }) %span= sprintf(s_('RegistrationFeatures|Want to %{feature_title} for free?'), { feature_title: feature_title })
- if Gitlab.ee? = render_if_exists 'shared/registration_features_discovery_settings_link'
= link_to s_('RegistrationFeatures|Enable Service Ping and register for this feature.'), service_ping_settings_path = html_escape(s_('RegistrationFeatures|Read more about the %{link_start}Registration Features Program%{link_end}.')) % { link_start: registration_features_link_start, link_end: '</a>'.html_safe }
= sprintf(s_('RegistrationFeatures|Read more about the %{linkStart}%{label}%{linkEnd}.') , { linkStart: "<a href=\"#{registration_features_docs_path}\" target=\"_blank\">", label: s_('RegistrationFeatures|Registration Features Program'), linkEnd: "</a>" }).html_safe
- return unless registration_features_can_be_prompted?
.row
.form-group.col-md-9
= form.label :disabled_repository_size_limit, class: 'label-bold' do
= _('Repository size limit (MB)')
= form.number_field :disabled_repository_size_limit, value: '', class: 'form-control', disabled: true
%span.form-text.text-muted
= render 'shared/registration_features_discovery_message'
- return unless repo_size_limit_feature_available?
- form = local_assigns.fetch(:form) - form = local_assigns.fetch(:form)
.form-group .form-group
= form.label :repository_size_limit, class: 'label-bold' do = form.label :repository_size_limit, class: 'label-bold' do
= _('Size limit per repository (MB)') = _('Size limit per repository (MB)')
- if repo_size_limit_feature_available?
= form.number_field :repository_size_limit, value: form.object.repository_size_limit.try(:to_mb), class: 'form-control gl-form-input', min: 0, title: _('Maximum size limit for each repository.'), data: { toggle: 'tooltip', container: 'body' } = form.number_field :repository_size_limit, value: form.object.repository_size_limit.try(:to_mb), class: 'form-control gl-form-input', min: 0, title: _('Maximum size limit for each repository.'), data: { toggle: 'tooltip', container: 'body' }
%span.form-text.text-muted#repository_size_limit_help_block %span.form-text.text-muted#repository_size_limit_help_block
= _('Includes LFS objects. It can be overridden per group, or per project. 0 for unlimited.') = _('Includes LFS objects. It can be overridden per group, or per project. 0 for unlimited.')
= link_to _('Learn more.'), help_page_path('user/admin_area/settings/account_and_limit_settings'), target: '_blank', rel: 'noopener noreferrer' = link_to _('Learn more.'), help_page_path('user/admin_area/settings/account_and_limit_settings'), target: '_blank', rel: 'noopener noreferrer'
- else
= form.number_field :disabled_repository_size_limit, value: '', class: 'form-control gl-form-input', disabled: true
%span.form-text.text-muted
= render 'shared/registration_features_discovery_message'
- return unless current_user.admin?
- service_ping_settings_path = metrics_and_profiling_admin_application_settings_path(anchor: 'js-usage-settings')
= link_to s_('RegistrationFeatures|Enable Service Ping and register for this feature.'), service_ping_settings_path
- return unless current_user.admin? - return unless current_user.admin? && repo_size_limit_feature_available?
- form = local_assigns.fetch(:form) - form = local_assigns.fetch(:form)
- is_project = local_assigns.fetch(:type) == :project - is_project = local_assigns.fetch(:type) == :project
...@@ -6,12 +6,7 @@ ...@@ -6,12 +6,7 @@
.row .row
.form-group.col-md-9 .form-group.col-md-9
= form.label :repository_size_limit, class: 'label-bold' do = form.label :repository_size_limit, class: 'label-bold' do
Repository size limit (MB) = _('Repository size limit (MB)')
- if repo_size_limit_feature_available?
= form.number_field :repository_size_limit, value: form.object.repository_size_limit.try(:to_mb), class: 'form-control', min: 0, data: { qa_selector: 'repository_size_limit_field' } = form.number_field :repository_size_limit, value: form.object.repository_size_limit.try(:to_mb), class: 'form-control', min: 0, data: { qa_selector: 'repository_size_limit_field' }
%span.form-text.text-muted#repository_size_limit_help_block %span.form-text.text-muted#repository_size_limit_help_block
= is_project ? size_limit_message(@project) : size_limit_message_for_group(@group) = is_project ? size_limit_message(@project) : size_limit_message_for_group(@group)
- else
= form.number_field :disabled_repository_size_limit, value: '', class: 'form-control', disabled: true
%span.form-text.text-muted
= render 'shared/registration_features_discovery_message'
# frozen_string_literal: true
RSpec.shared_examples 'renders registration features settings link' do
let_it_be(:admin) { create(:admin) }
let_it_be(:user) { create(:user) }
context 'as regular user' do
before do
allow(view).to receive(:current_user) { user }
end
it 'does not render settings link', :aggregate_failures do
expect(rendered).not_to have_link(s_('RegistrationFeatures|Enable Service Ping and register for this feature.'))
end
end
context 'as admin' do
before do
allow(view).to receive(:current_user) { admin }
end
it 'renders settings link', :aggregate_failures do
render
expect(rendered).to have_link(s_('RegistrationFeatures|Enable Service Ping and register for this feature.'))
end
end
end
...@@ -40,22 +40,14 @@ RSpec.describe 'admin/application_settings/general.html.haml' do ...@@ -40,22 +40,14 @@ RSpec.describe 'admin/application_settings/general.html.haml' do
end end
describe 'prompt user about registration features' do describe 'prompt user about registration features' do
let(:message) { s_("RegistrationFeatures|Want to %{feature_title} for free?") % { feature_title: s_('RegistrationFeatures|use this feature') } }
context 'with no license and service ping disabled' do context 'with no license and service ping disabled' do
before do before do
allow(License).to receive(:current).and_return(nil) allow(License).to receive(:current).and_return(nil)
stub_application_setting(usage_ping_enabled: false) stub_application_setting(usage_ping_enabled: false)
render
end end
it 'renders registration features CTA' do it_behaves_like 'renders registration features prompt', :application_setting_disabled_repository_size_limit
expect(rendered).to have_content message it_behaves_like 'renders registration features settings link'
expect(rendered).to have_link s_('RegistrationFeatures|Registration Features Program')
expect(rendered).to have_link s_('RegistrationFeatures|Enable Service Ping and register for this feature.')
expect(rendered).to have_field 'application_setting_disabled_repository_size_limit', disabled: true
end
end end
context 'with a valid license and service ping disabled' do context 'with a valid license and service ping disabled' do
...@@ -63,13 +55,9 @@ RSpec.describe 'admin/application_settings/general.html.haml' do ...@@ -63,13 +55,9 @@ RSpec.describe 'admin/application_settings/general.html.haml' do
license = build(:license) license = build(:license)
allow(License).to receive(:current).and_return(license) allow(License).to receive(:current).and_return(license)
stub_application_setting(usage_ping_enabled: false) stub_application_setting(usage_ping_enabled: false)
render
end end
it 'does not render registration features CTA' do it_behaves_like 'does not render registration features prompt', :application_setting_disabled_repository_size_limit
expect(rendered).not_to have_content message
end
end end
end end
end end
...@@ -89,14 +89,8 @@ RSpec.describe 'groups/edit.html.haml' do ...@@ -89,14 +89,8 @@ RSpec.describe 'groups/edit.html.haml' do
allow(License).to receive(:current).and_return(nil) allow(License).to receive(:current).and_return(nil)
end end
it 'renders a placeholder input with registration features message' do it_behaves_like 'renders registration features prompt', :group_disabled_ip_restriction_ranges
render it_behaves_like 'renders registration features settings link'
expect(rendered).to have_field(:group_disabled_ip_restriction_ranges, disabled: true)
expect(rendered).to have_content(s_("RegistrationFeatures|Want to %{feature_title} for free?") % { feature_title: s_('RegistrationFeatures|use this feature') })
expect(rendered).to have_link(s_('RegistrationFeatures|Enable Service Ping and register for this feature.'))
expect(rendered).to have_link(s_('RegistrationFeatures|Registration Features Program'))
end
end end
context 'with a valid license' do context 'with a valid license' do
......
...@@ -42,22 +42,14 @@ RSpec.describe 'projects/edit' do ...@@ -42,22 +42,14 @@ RSpec.describe 'projects/edit' do
end end
describe 'prompt user about registration features' do describe 'prompt user about registration features' do
let(:message) { s_("RegistrationFeatures|Want to %{feature_title} for free?") % { feature_title: s_('RegistrationFeatures|use this feature') } }
context 'with no license and service ping disabled' do context 'with no license and service ping disabled' do
before do before do
allow(License).to receive(:current).and_return(nil) allow(License).to receive(:current).and_return(nil)
stub_application_setting(usage_ping_enabled: false) stub_application_setting(usage_ping_enabled: false)
render
end end
it 'renders registration features CTA' do it_behaves_like 'renders registration features prompt', :project_disabled_repository_size_limit
expect(rendered).to have_content(message) it_behaves_like 'renders registration features settings link'
expect(rendered).to have_link(s_('RegistrationFeatures|Registration Features Program'))
expect(rendered).to have_link(s_('RegistrationFeatures|Enable Service Ping and register for this feature.'))
expect(rendered).to have_field('project_disabled_repository_size_limit', disabled: true)
end
end end
context 'with a valid license and service ping disabled' do context 'with a valid license and service ping disabled' do
...@@ -65,13 +57,9 @@ RSpec.describe 'projects/edit' do ...@@ -65,13 +57,9 @@ RSpec.describe 'projects/edit' do
license = build(:license) license = build(:license)
allow(License).to receive(:current).and_return(license) allow(License).to receive(:current).and_return(license)
stub_application_setting(usage_ping_enabled: false) stub_application_setting(usage_ping_enabled: false)
render
end end
it 'does not render registration features CTA' do it_behaves_like 'does not render registration features prompt', :project_disabled_repository_size_limit
expect(rendered).not_to have_content(message)
end
end end
end end
end end
...@@ -29448,7 +29448,7 @@ msgstr "" ...@@ -29448,7 +29448,7 @@ msgstr ""
msgid "RegistrationFeatures|Enable Service Ping and register for this feature." msgid "RegistrationFeatures|Enable Service Ping and register for this feature."
msgstr "" msgstr ""
msgid "RegistrationFeatures|Read more about the %{linkStart}%{label}%{linkEnd}." msgid "RegistrationFeatures|Read more about the %{link_start}Registration Features Program%{link_end}."
msgstr "" msgstr ""
msgid "RegistrationFeatures|Registration Features Program" msgid "RegistrationFeatures|Registration Features Program"
...@@ -30214,6 +30214,9 @@ msgstr "" ...@@ -30214,6 +30214,9 @@ msgstr ""
msgid "Repository size is above the limit." msgid "Repository size is above the limit."
msgstr "" msgstr ""
msgid "Repository size limit (MB)"
msgstr ""
msgid "Repository storage" msgid "Repository storage"
msgstr "" msgstr ""
......
# frozen_string_literal: true # frozen_string_literal: true
RSpec.shared_examples 'renders registration features prompt' do |disabled_field|
it 'renders a placeholder input with registration features message', :aggregate_failures do
render
if disabled_field
expect(rendered).to have_field(disabled_field, disabled: true)
end
expect(rendered).to have_content(s_("RegistrationFeatures|Want to %{feature_title} for free?") % { feature_title: s_('RegistrationFeatures|use this feature') })
expect(rendered).to have_link(s_('RegistrationFeatures|Registration Features Program'))
end
end
RSpec.shared_examples 'does not render registration features prompt' do |disabled_field| RSpec.shared_examples 'does not render registration features prompt' do |disabled_field|
it 'does not render a placeholder input with registration features message' do it 'does not render a placeholder input with registration features message', :aggregate_failures do
render render
if disabled_field if disabled_field
...@@ -9,7 +22,6 @@ RSpec.shared_examples 'does not render registration features prompt' do |disable ...@@ -9,7 +22,6 @@ RSpec.shared_examples 'does not render registration features prompt' do |disable
end end
expect(rendered).not_to have_content(s_("RegistrationFeatures|Want to %{feature_title} for free?") % { feature_title: s_('RegistrationFeatures|use this feature') }) expect(rendered).not_to have_content(s_("RegistrationFeatures|Want to %{feature_title} for free?") % { feature_title: s_('RegistrationFeatures|use this feature') })
expect(rendered).not_to have_link(s_('RegistrationFeatures|Enable Service Ping and register for this feature.'))
expect(rendered).not_to have_link(s_('RegistrationFeatures|Registration Features Program')) expect(rendered).not_to have_link(s_('RegistrationFeatures|Registration Features Program'))
end end
end end
...@@ -33,4 +33,31 @@ RSpec.describe 'admin/application_settings/general.html.haml' do ...@@ -33,4 +33,31 @@ RSpec.describe 'admin/application_settings/general.html.haml' do
end end
end end
end end
describe 'prompt user about registration features' do
before do
assign(:application_setting, app_settings)
allow(view).to receive(:current_user).and_return(user)
end
context 'when service ping is enabled' do
before do
stub_application_setting(usage_ping_enabled: true)
end
it_behaves_like 'does not render registration features prompt', :application_setting_disabled_repository_size_limit
end
context 'with no license and service ping disabled' do
before do
stub_application_setting(usage_ping_enabled: false)
if Gitlab.ee?
allow(License).to receive(:current).and_return(nil)
end
end
it_behaves_like 'renders registration features prompt', :application_setting_disabled_repository_size_limit
end
end
end end
...@@ -139,4 +139,26 @@ RSpec.describe 'projects/edit' do ...@@ -139,4 +139,26 @@ RSpec.describe 'projects/edit' do
end end
end end
end end
describe 'prompt user about registration features' do
context 'when service ping is enabled' do
before do
stub_application_setting(usage_ping_enabled: true)
end
it_behaves_like 'does not render registration features prompt', :project_disabled_repository_size_limit
end
context 'with no license and service ping disabled' do
before do
stub_application_setting(usage_ping_enabled: false)
if Gitlab.ee?
allow(License).to receive(:current).and_return(nil)
end
end
it_behaves_like 'renders registration features prompt', :project_disabled_repository_size_limit
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