Commit 34f6830c authored by Stan Hu's avatar Stan Hu

Add license breakdown to admin pages

Closes #653
parent dab9481b
......@@ -3,5 +3,6 @@ class Admin::DashboardController < Admin::ApplicationController
@projects = Project.limit(10)
@users = User.limit(10)
@groups = Group.limit(10)
@license = License.current
end
end
......@@ -2,6 +2,9 @@
= render "admin/dashboard/head"
%div{ class: container_class }
- if @license
= render "admin/licenses/breakdown", license: @license
.admin-dashboard.prepend-top-default
.row
.col-md-4
......
- if license.restricted?(:active_user_count)
- restricted = license.restrictions[:active_user_count]
- licensed_users = number_with_delimiter(restricted)
- else
- licensed_users = 'Unlimited'
- date_range = (Date.today - 1.year)..Date.today
- historical = HistoricalData.during(date_range).maximum(:active_user_count) || 0
- if historical && restricted && historical > restricted
- users_over_license = historical - restricted
- else
- users_over_license = 0
.license-panel.prepend-top-default
.row
.col-sm-4
.light-well
%h4 Users in License
.data
%h1.center= licensed_users
%hr
- if @license.will_expire?
Your license is valid from
%strong
#{@license.starts_at} to
%strong<>
#{@license.expires_at}
\.
The
%a{href: 'https://about.gitlab.com/license-faq/'}true-up model
allows having more users, and additional users will incur a retroactive charge on renewal.
.col-sm-4
.light-well
%h4 Maximum Users
.data
%h1.center= number_with_delimiter historical
%hr
This is the highest peak of users on your installation since the license started, and this is the minimum
number you need to purchase when you renew your license.
.col-sm-4
.light-well
%h4 Users over License
.data
%h1.center= number_with_delimiter users_over_license
%hr
The
%a{href: 'https://about.gitlab.com/license-faq/'}true-up model
has a retroactive charge for these users at the next renewal. If you want to update your
license sooner to prevent this, please contact
#{mail_to 'sales@gitlab.com'}.
......@@ -42,42 +42,6 @@
%span.label.label-danger.pull-right
%strong Expired
.panel.panel-default
.panel-heading
Users
%ul.well-list
%li
%span.light License limit:
%strong
- if @license.restricted?(:active_user_count)
- restricted = @license.restrictions[:active_user_count]
#{number_with_delimiter restricted} #{"users".pluralize(restricted)}
- else
Unlimited
%li
%span.light Current active users:
%strong
- current = User.active.count
#{number_with_delimiter current} #{"users".pluralize(current)}
- if restricted && current > restricted
%span.label.label-danger.pull-right
%strong
Exceeds license limit
- date_range = (Date.today - 1.year)..Date.today
- historical = HistoricalData.during(date_range).maximum(:active_user_count)
- if historical
%li
%span.light Maximum active users:
%strong
#{number_with_delimiter historical} #{"users".pluralize(historical)}
- if restricted && historical > restricted
%span.label.label-danger.pull-right
%strong
Exceeds license limit
.col-md-6
.panel.panel-info
.panel-heading
......@@ -98,6 +62,8 @@
%br
= link_to 'Remove license', admin_license_path, data: { confirm: "Are you sure you want to remove the license?" }, method: :delete, class: "btn btn-remove"
= render "breakdown", license: @license
- if @previous_licenses.any?
%h4 License History
......
require 'spec_helper'
feature "License Admin", feature: true do
before do
login_as :admin
end
describe '#show' do
it 'shows a valid license' do
visit admin_license_path
expect(page).to have_content('Your license is valid')
page.within '.license-panel' do
expect(page).to have_content('Unlimited')
end
end
describe 'limited users' do
it 'shows panel counts' do
restrictions = { active_user_count: 2000 }
allow_any_instance_of(Gitlab::License).to receive(:restrictions).and_return(restrictions)
visit admin_license_path
page.within '.license-panel' do
expect(page).to have_content('2,000')
end
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