Commit 484ef1f2 authored by Lin Jen-Shin's avatar Lin Jen-Shin

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

In-app awareness of Registration Features - Email from GitLab

See merge request gitlab-org/gitlab!74042
parents b4c272ca 657c11fe
...@@ -487,6 +487,10 @@ module ApplicationSettingsHelper ...@@ -487,6 +487,10 @@ module ApplicationSettingsHelper
def pending_user_count def pending_user_count
User.blocked_pending_approval.count User.blocked_pending_approval.count
end end
def registration_features_can_be_prompted?
!Gitlab::CurrentSettings.usage_ping_enabled?
end
end end
ApplicationSettingsHelper.prepend_mod_with('ApplicationSettingsHelper') 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 .top-area.scrolling-tabs-container.inner-page-scroll-tabs
.fade-left .fade-left
= sprite_icon('chevron-lg-left', size: 12) = 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') - 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') - service_ping_settings_path = metrics_and_profiling_admin_application_settings_path(anchor: 'js-usage-settings')
%div %div
%span= s_('RegistrationFeatures|Want to use this feature for free?') %span= sprintf(s_('RegistrationFeatures|Want to %{feature_title} for free?'), { feature_title: feature_title })
- if license.present? - if Gitlab.ee?
= link_to s_('RegistrationFeatures|Enable Service Ping and register for this feature.'), service_ping_settings_path = 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 ...@@ -133,5 +133,10 @@ module EE
prevent_merge_requests_committers_approval prevent_merge_requests_committers_approval
] ]
end end
override :registration_features_can_be_prompted?
def registration_features_can_be_prompted?
!::Gitlab::CurrentSettings.usage_ping_enabled? && !License.current.present?
end
end end
end end
...@@ -11,4 +11,4 @@ ...@@ -11,4 +11,4 @@
- else - else
= form.number_field :disabled_repository_size_limit, value: '', class: 'form-control gl-form-input', disabled: true = form.number_field :disabled_repository_size_limit, value: '', class: 'form-control gl-form-input', disabled: true
%span.form-text.text-muted %span.form-text.text-muted
= render 'shared/registration_features_discovery_message', license: @license = render 'shared/registration_features_discovery_message'
...@@ -14,4 +14,4 @@ ...@@ -14,4 +14,4 @@
- else - else
= form.number_field :disabled_repository_size_limit, value: '', class: 'form-control', disabled: true = form.number_field :disabled_repository_size_limit, value: '', class: 'form-control', disabled: true
%span.form-text.text-muted %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 ...@@ -203,4 +203,37 @@ RSpec.describe "Admin::Users", :js do
end end
end 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 end
...@@ -8,4 +8,48 @@ RSpec.describe EE::ApplicationSettingsHelper do ...@@ -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)) } it { expect(visible_attributes).to include(*%i(max_personal_access_token_lifetime enforce_pat_expiration enforce_ssh_key_expiration)) }
end end
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 end
...@@ -39,30 +39,36 @@ RSpec.describe 'admin/application_settings/general.html.haml' do ...@@ -39,30 +39,36 @@ RSpec.describe 'admin/application_settings/general.html.haml' do
end end
end end
context 'repository size limit' do describe 'prompt user about registration features' do
context 'feature is disabled' 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 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 render
end end
it('renders registration features prompt without activation link') do it 'renders registration features CTA' do
expect(rendered).to have_field('application_setting_disabled_repository_size_limit', disabled: true) expect(rendered).to have_content message
expect(rendered).to have_link 'Registration Features Program' expect(rendered).to have_link s_('RegistrationFeatures|Registration Features Program')
expect(rendered).not_to have_link 'Enable Service Ping and register for this feature.' 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 'user has an active license' do context 'with a valid license and service ping disabled' do
before do before do
assign(:license, create(:license)) license = build(:license)
allow(License).to receive(:current).and_return(license)
stub_application_setting(usage_ping_enabled: false)
render render
end end
it('renders registration features prompt with activation link') do it 'does not render registration features CTA' 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') expect(rendered).not_to have_content message
end
end end
end end
end end
......
...@@ -41,30 +41,36 @@ RSpec.describe 'projects/edit' do ...@@ -41,30 +41,36 @@ RSpec.describe 'projects/edit' do
end end
end end
context 'repository size limit' do describe 'prompt user about registration features' do
context 'feature is disabled' 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 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 render
end 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_field('project_disabled_repository_size_limit', disabled: true)
expect(rendered).to have_link 'Registration Features Program' end
expect(rendered).not_to have_link 'Enable Service Ping and register for this feature.'
end end
context 'user has an active license' do context 'with a valid license and service ping disabled' do
before do before do
assign(:license, create(:license)) license = build(:license)
allow(License).to receive(:current).and_return(license)
stub_application_setting(usage_ping_enabled: false)
render render
end end
it('renders registration features prompt with activation link') do it 'does not render registration features CTA' 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') expect(rendered).not_to have_content(message)
end
end end
end end
end end
......
...@@ -29253,10 +29253,19 @@ msgstr "" ...@@ -29253,10 +29253,19 @@ 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}Registration Features Program%{linkEnd}." msgid "RegistrationFeatures|Read more about the %{linkStart}%{label}%{linkEnd}."
msgstr "" 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 "" msgstr ""
msgid "RegistrationVerification|Are you sure you want to skip this step?" msgid "RegistrationVerification|Are you sure you want to skip this step?"
......
...@@ -57,4 +57,33 @@ RSpec.describe "Admin::Users" do ...@@ -57,4 +57,33 @@ RSpec.describe "Admin::Users" do
expect(page).to have_content("#{Time.now.strftime('%b %Y')} 3 0") expect(page).to have_content("#{Time.now.strftime('%b %Y')} 3 0")
end 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') } }
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 end
...@@ -253,6 +253,32 @@ RSpec.describe ApplicationSettingsHelper do ...@@ -253,6 +253,32 @@ RSpec.describe ApplicationSettingsHelper do
end end
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 describe '#sidekiq_job_limiter_modes_for_select' do
subject { helper.sidekiq_job_limiter_modes_for_select } 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