Commit d2ca34d3 authored by Thiago Presa's avatar Thiago Presa Committed by Sean McGivern

Show if a user is using a license seat

Adds a field to the admin user view that shows whether that user is
using a license seat.
parent 2793c4f8
......@@ -124,6 +124,8 @@
%strong
= Gitlab::Access.human_access_with_none(@user.highest_role)
= render_if_exists 'admin/users/using_license_seat', user: @user
- if @user.ldap_user?
%li
%span.light LDAP uid:
......
......@@ -217,6 +217,16 @@ module EE
License.current.present?
end
def using_license_seat?
return false unless active?
if License.current&.exclude_guests_from_active_count?
highest_role > ::Gitlab::Access::GUEST
else
highest_role > ::Gitlab::Access::NO_ACCESS
end
end
def group_sso?(group)
return false unless group
......
%li
%span.light= _("Is using license seat:")
%strong
= @user.using_license_seat? ? _("Yes") : _("No")
---
title: Show if user is using a license seat on admin user page
merge_request: 11449
author:
type: added
......@@ -565,4 +565,36 @@ describe User do
end
end
end
describe '#using_license_seat?' do
let(:user) { create(:user) }
context 'when user is inactive' do
before do
user.block
end
it 'returns false' do
expect(user.using_license_seat?).to eq false
end
end
context 'when user is active' do
let(:project_guest_user) { create(:project_member, :guest).user }
context 'user is guest' do
it 'returns false if license is ultimate' do
create(:license, plan: License::ULTIMATE_PLAN)
expect(project_guest_user.using_license_seat?).to eq false
end
it 'returns true if license is not ultimate' do
create(:license, plan: License::STARTER_PLAN)
expect(project_guest_user.using_license_seat?).to eq true
end
end
end
end
end
......@@ -7000,6 +7000,9 @@ msgstr ""
msgid "Invoke Time"
msgstr ""
msgid "Is using license seat:"
msgstr ""
msgid "IssuableStatus|Closed (%{moved_link_start}moved%{moved_link_end})"
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