Commit 657c11fe authored by Axel García's avatar Axel García Committed by Lin Jen-Shin

Registration features info for sending emails

Changelog: added
MR: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/74042
EE: true
parent b081e678
......@@ -487,6 +487,10 @@ module ApplicationSettingsHelper
def pending_user_count
User.blocked_pending_approval.count
end
def registration_features_can_be_prompted?
!Gitlab::CurrentSettings.usage_ping_enabled?
end
end
ApplicationSettingsHelper.prepend_mod_with('ApplicationSettingsHelper')
......
- if registration_features_can_be_prompted?
= render 'shared/global_alert',
variant: :tip,
alert_class: 'gl-my-5',
dismissible: false do
.gl-alert-body
= render 'shared/registration_features_discovery_message', feature_title: s_('RegistrationFeatures|send emails to users')
.top-area.scrolling-tabs-container.inner-page-scroll-tabs
.fade-left
= sprite_icon('chevron-lg-left', size: 12)
......
- license = local_assigns.fetch(:license)
- 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')
- service_ping_settings_path = metrics_and_profiling_admin_application_settings_path(anchor: 'js-usage-settings')
%div
%span= s_('RegistrationFeatures|Want to use this feature for free?')
- if license.present?
%span= sprintf(s_('RegistrationFeatures|Want to %{feature_title} for free?'), { feature_title: feature_title })
- if Gitlab.ee?
= link_to s_('RegistrationFeatures|Enable Service Ping and register for this feature.'), service_ping_settings_path
= sprintf(s_('RegistrationFeatures|Read more about the %{linkStart}Registration Features Program%{linkEnd}.') , { linkStart: "<a href=\"#{registration_features_docs_path}\" target=\"_blank\">", linkEnd: "</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
......@@ -133,5 +133,10 @@ module EE
prevent_merge_requests_committers_approval
]
end
override :registration_features_can_be_prompted?
def registration_features_can_be_prompted?
!::Gitlab::CurrentSettings.usage_ping_enabled? && !License.current.present?
end
end
end
......@@ -11,4 +11,4 @@
- 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', license: @license
= render 'shared/registration_features_discovery_message'
......@@ -14,4 +14,4 @@
- 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', license: @license
= render 'shared/registration_features_discovery_message'
......@@ -203,4 +203,37 @@ RSpec.describe "Admin::Users", :js do
end
end
end
describe 'prompt user about registration features' do
let(:message) { s_("RegistrationFeatures|Want to %{feature_title} for free?") % { feature_title: s_('RegistrationFeatures|send emails to users') } }
context 'with no license and service ping disabled' do
before do
allow(License).to receive(:current).and_return(nil)
stub_application_setting(usage_ping_enabled: false)
end
it 'renders registration features CTA' do
visit admin_users_path
expect(page).to have_content(message)
expect(page).to have_link(s_('RegistrationFeatures|Registration Features Program'))
expect(page).to have_link(s_('RegistrationFeatures|Enable Service Ping and register for this feature.'))
end
end
context 'with a valid license and service ping disabled' do
before do
license = build(:license)
allow(License).to receive(:current).and_return(license)
stub_application_setting(usage_ping_enabled: false)
end
it 'does not render registration features CTA' do
visit admin_users_path
expect(page).not_to have_content(message)
end
end
end
end
......@@ -8,4 +8,48 @@ RSpec.describe EE::ApplicationSettingsHelper do
it { expect(visible_attributes).to include(*%i(max_personal_access_token_lifetime enforce_pat_expiration enforce_ssh_key_expiration)) }
end
end
describe '.registration_features_can_be_prompted?' do
subject { helper.registration_features_can_be_prompted? }
context 'without a valid license' do
before do
allow(License).to receive(:current).and_return(nil)
end
context 'when service ping is enabled' do
before do
stub_application_setting(usage_ping_enabled: true)
end
it { is_expected.to be_falsey }
end
context 'when service ping is disabled' do
before do
stub_application_setting(usage_ping_enabled: false)
end
it { is_expected.to be_truthy }
end
end
context 'with a license' do
let(:license) { build(:license) }
before do
allow(License).to receive(:current).and_return(license)
end
it { is_expected.to be_falsey }
context 'when service ping is disabled' do
before do
stub_application_setting(usage_ping_enabled: false)
end
it { is_expected.to be_falsey }
end
end
end
end
......@@ -39,30 +39,36 @@ RSpec.describe 'admin/application_settings/general.html.haml' do
end
end
context 'repository size limit' do
context 'feature is disabled' 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
before do
stub_licensed_features(repository_size_limit: false)
allow(License).to receive(:current).and_return(nil)
stub_application_setting(usage_ping_enabled: false)
render
end
it('renders registration features prompt without activation link') do
expect(rendered).to have_field('application_setting_disabled_repository_size_limit', disabled: true)
expect(rendered).to have_link 'Registration Features Program'
expect(rendered).not_to have_link 'Enable Service Ping and register for this feature.'
it 'renders registration features CTA' do
expect(rendered).to have_content message
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
context 'user has an active license' do
before do
assign(:license, create(:license))
context 'with a valid license and service ping disabled' do
before do
license = build(:license)
allow(License).to receive(:current).and_return(license)
stub_application_setting(usage_ping_enabled: false)
render
end
render
end
it('renders registration features prompt with activation link') do
expect(rendered).to have_link 'Enable Service Ping and register for this feature.', href: metrics_and_profiling_admin_application_settings_path(anchor: 'js-usage-settings')
end
it 'does not render registration features CTA' do
expect(rendered).not_to have_content message
end
end
end
......
......@@ -41,30 +41,36 @@ RSpec.describe 'projects/edit' do
end
end
context 'repository size limit' do
context 'feature is disabled' 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
before do
stub_licensed_features(repository_size_limit: false)
allow(License).to receive(:current).and_return(nil)
stub_application_setting(usage_ping_enabled: false)
render
end
it('renders registration features prompt without activation link') do
it 'renders registration features CTA' do
expect(rendered).to have_content(message)
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)
expect(rendered).to have_link 'Registration Features Program'
expect(rendered).not_to have_link 'Enable Service Ping and register for this feature.'
end
end
context 'user has an active license' do
before do
assign(:license, create(:license))
context 'with a valid license and service ping disabled' do
before do
license = build(:license)
allow(License).to receive(:current).and_return(license)
stub_application_setting(usage_ping_enabled: false)
render
end
render
end
it('renders registration features prompt with activation link') do
expect(rendered).to have_link 'Enable Service Ping and register for this feature.', href: metrics_and_profiling_admin_application_settings_path(anchor: 'js-usage-settings')
end
it 'does not render registration features CTA' do
expect(rendered).not_to have_content(message)
end
end
end
......
......@@ -29250,10 +29250,19 @@ msgstr ""
msgid "RegistrationFeatures|Enable Service Ping and register for this feature."
msgstr ""
msgid "RegistrationFeatures|Read more about the %{linkStart}Registration Features Program%{linkEnd}."
msgid "RegistrationFeatures|Read more about the %{linkStart}%{label}%{linkEnd}."
msgstr ""
msgid "RegistrationFeatures|Want to use this feature for free?"
msgid "RegistrationFeatures|Registration Features Program"
msgstr ""
msgid "RegistrationFeatures|Want to %{feature_title} for free?"
msgstr ""
msgid "RegistrationFeatures|send emails to users"
msgstr ""
msgid "RegistrationFeatures|use this feature"
msgstr ""
msgid "RegistrationVerification|Are you sure you want to skip this step?"
......
......@@ -57,4 +57,33 @@ RSpec.describe "Admin::Users" do
expect(page).to have_content("#{Time.now.strftime('%b %Y')} 3 0")
end
end
describe 'prompt user about registration features' do
let(:message) { s_("RegistrationFeatures|Want to %{feature_title} for free?") % { feature_title: s_('RegistrationFeatures|send emails to users') } }
it 'does not render registration features CTA when service ping is enabled' do
stub_application_setting(usage_ping_enabled: true)
visit admin_users_path
expect(page).not_to have_content(message)
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 'renders registration features CTA' do
visit admin_users_path
expect(page).to have_content(message)
expect(page).to have_link(s_('RegistrationFeatures|Registration Features Program'))
end
end
end
end
......@@ -253,6 +253,32 @@ RSpec.describe ApplicationSettingsHelper do
end
end
describe '.registration_features_can_be_prompted?' do
subject { helper.registration_features_can_be_prompted? }
before do
if Gitlab.ee?
allow(License).to receive(:current).and_return(nil)
end
end
context 'when service ping is enabled' do
before do
stub_application_setting(usage_ping_enabled: true)
end
it { is_expected.to be_falsey }
end
context 'when service ping is disabled' do
before do
stub_application_setting(usage_ping_enabled: false)
end
it { is_expected.to be_truthy }
end
end
describe '#sidekiq_job_limiter_modes_for_select' do
subject { helper.sidekiq_job_limiter_modes_for_select }
......
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