Commit 17efce6c authored by Vitaly Slobodin's avatar Vitaly Slobodin Committed by Kamil Trzciński

Show license overage warning on admin dashboard

parent 7d2fe1bd
...@@ -21,18 +21,19 @@ module LicenseMonitoringHelper ...@@ -21,18 +21,19 @@ module LicenseMonitoringHelper
current_user&.admin? && active_user_count_threshold_reached? current_user&.admin? && active_user_count_threshold_reached?
end end
private
def license_not_available_or_trial?
current_license.nil? || current_license.trial?
end
def license_is_over_capacity? def license_is_over_capacity?
return if ::Gitlab.com?
return if license_not_available_or_trial? return if license_not_available_or_trial?
current_license_overage > 0 current_license_overage > 0
end end
private
def license_not_available_or_trial?
current_license.nil? || current_license.trial?
end
def active_user_count_threshold_reached? def active_user_count_threshold_reached?
return if current_active_users_count <= 1 return if current_active_users_count <= 1
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
- max_user_count = maximum_user_count - max_user_count = maximum_user_count
- if restricted && max_user_count > restricted - if license_is_over_capacity?
- users_over_license = max_user_count - restricted - users_over_license = current_license_overage
- else - else
- users_over_license = 0 - users_over_license = 0
...@@ -74,5 +74,9 @@ ...@@ -74,5 +74,9 @@
= _('Users over License:') = _('Users over License:')
= number_with_delimiter users_over_license = number_with_delimiter users_over_license
%hr %hr
- support_link_start = '<a href="%{url}">'.html_safe % { url: ::EE::CUSTOMER_SUPPORT_URL } - if license_is_over_capacity?
= _('The %{true_up_link_start}true-up model%{link_end} has a retroactive charge for these users at the next renewal. If you want to update your license sooner to prevent this, %{support_link_start}please contact our Support team%{link_end}.').html_safe % { support_link_start: support_link_start, true_up_link_start: true_up_link_start, link_end: link_end } .gl-alert.gl-alert-info.gl-mb-3{ role: 'alert' }
= sprite_icon('information-o', css_class: 'gl-icon gl-alert-icon gl-alert-icon-no-title')
.gl-alert-body
= s_('Your instance has exceeded your subscription\'s licensed user count.')
= _('You\'ll be charged for %{true_up_link_start}users over license%{link_end} on a quartely or annual basis, depending on the terms of your agreement.').html_safe % { true_up_link_start: true_up_link_start, link_end: link_end }
---
title: Show license overage warning on admin dashboard
merge_request: 39704
author:
type: added
...@@ -10,29 +10,47 @@ RSpec.describe 'Admin Dashboard' do ...@@ -10,29 +10,47 @@ RSpec.describe 'Admin Dashboard' do
sign_in(create(:admin)) sign_in(create(:admin))
end end
context 'for tooltip' do describe 'license' do
before do before do
allow(License).to receive(:current).and_return(license) allow(License).to receive(:current).and_return(license)
visit admin_dashboard_stats_path
end end
context 'when license is empty' do context 'for tooltip' do
let(:license) { nil } before do
visit admin_dashboard_stats_path
end
it { expect(page).not_to have_css('span.has-tooltip') } context 'when license is empty' do
end let(:license) { nil }
it { expect(page).not_to have_css('span.has-tooltip') }
end
context 'when license is on a plan Ultimate' do
let(:license) { create(:license, plan: License::ULTIMATE_PLAN) }
context 'when license is on a plan Ultimate' do it { expect(page).to have_css('span.has-tooltip') }
let(:license) { create(:license, plan: License::ULTIMATE_PLAN) } end
it { expect(page).to have_css('span.has-tooltip') } context 'when license is on a plan other than Ultimate' do
let(:license) { create(:license, plan: License::PREMIUM_PLAN) }
it { expect(page).not_to have_css('span.has-tooltip') }
end
end end
context 'when license is on a plan other than Ultimate' do context 'when user count over license maximum' do
let(:license) { create(:license, plan: License::PREMIUM_PLAN) } let_it_be(:license_seats_limit) { 5 }
let(:license) { create(:license, restrictions: { active_user_count: license_seats_limit }) }
before do
create(:historical_data, date: license.created_at, active_user_count: license_seats_limit + 1)
visit admin_root_path
end
it { expect(page).not_to have_css('span.has-tooltip') } it { expect(page).to have_content("Your instance has exceeded your subscription\'s licensed user count.") }
end end
end end
......
...@@ -24367,9 +24367,6 @@ msgstr "" ...@@ -24367,9 +24367,6 @@ msgstr ""
msgid "The %{link_start}true-up model%{link_end} allows having more users, and additional users will incur a retroactive charge on renewal." msgid "The %{link_start}true-up model%{link_end} allows having more users, and additional users will incur a retroactive charge on renewal."
msgstr "" msgstr ""
msgid "The %{true_up_link_start}true-up model%{link_end} has a retroactive charge for these users at the next renewal. If you want to update your license sooner to prevent this, %{support_link_start}please contact our Support team%{link_end}."
msgstr ""
msgid "The %{type} contains the following error:" msgid "The %{type} contains the following error:"
msgid_plural "The %{type} contains the following errors:" msgid_plural "The %{type} contains the following errors:"
msgstr[0] "" msgstr[0] ""
...@@ -28494,6 +28491,9 @@ msgstr "" ...@@ -28494,6 +28491,9 @@ msgstr ""
msgid "You won't be able to pull or push project code via SSH until you add an SSH key to your profile" msgid "You won't be able to pull or push project code via SSH until you add an SSH key to your profile"
msgstr "" msgstr ""
msgid "You'll be charged for %{true_up_link_start}users over license%{link_end} on a quartely or annual basis, depending on the terms of your agreement."
msgstr ""
msgid "You'll be signed out from your current account automatically." msgid "You'll be signed out from your current account automatically."
msgstr "" msgstr ""
...@@ -28686,6 +28686,9 @@ msgstr "" ...@@ -28686,6 +28686,9 @@ msgstr ""
msgid "Your instance has %{remaining_user_count} users remaining of the %{total_user_count} included in your subscription. You can add more users than the number included in your license, and we will include the overage in your next bill." msgid "Your instance has %{remaining_user_count} users remaining of the %{total_user_count} included in your subscription. You can add more users than the number included in your license, and we will include the overage in your next bill."
msgstr "" msgstr ""
msgid "Your instance has exceeded your subscription's licensed user count."
msgstr ""
msgid "Your instance is approaching its licensed user count" msgid "Your instance is approaching its licensed user count"
msgstr "" msgstr ""
......
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