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
current_user&.admin? && active_user_count_threshold_reached?
end
private
def license_not_available_or_trial?
current_license.nil? || current_license.trial?
end
def license_is_over_capacity?
return if ::Gitlab.com?
return if license_not_available_or_trial?
current_license_overage > 0
end
private
def license_not_available_or_trial?
current_license.nil? || current_license.trial?
end
def active_user_count_threshold_reached?
return if current_active_users_count <= 1
......
......@@ -6,8 +6,8 @@
- max_user_count = maximum_user_count
- if restricted && max_user_count > restricted
- users_over_license = max_user_count - restricted
- if license_is_over_capacity?
- users_over_license = current_license_overage
- else
- users_over_license = 0
......@@ -74,5 +74,9 @@
= _('Users over License:')
= number_with_delimiter users_over_license
%hr
- support_link_start = '<a href="%{url}">'.html_safe % { url: ::EE::CUSTOMER_SUPPORT_URL }
= _('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 }
- if license_is_over_capacity?
.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,10 +10,13 @@ RSpec.describe 'Admin Dashboard' do
sign_in(create(:admin))
end
context 'for tooltip' do
describe 'license' do
before do
allow(License).to receive(:current).and_return(license)
end
context 'for tooltip' do
before do
visit admin_dashboard_stats_path
end
......@@ -36,6 +39,21 @@ RSpec.describe 'Admin Dashboard' do
end
end
context 'when user count over license maximum' do
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).to have_content("Your instance has exceeded your subscription\'s licensed user count.") }
end
end
it 'shows correct amounts of users', :aggregate_failures do
visit admin_dashboard_stats_path
......
......@@ -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."
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_plural "The %{type} contains the following errors:"
msgstr[0] ""
......@@ -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"
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."
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."
msgstr ""
msgid "Your instance has exceeded your subscription's licensed user count."
msgstr ""
msgid "Your instance is approaching its licensed user count"
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