Skip to content
代码片段 群组 项目
未验证 提交 170c36fc 编辑于 作者: Vijay Hawoldar's avatar Vijay Hawoldar 提交者: GitLab
浏览文件

Merge branch...

Merge branch 'ag/458369-users-without-a-group-or-project-incorrectly-displayed-as-billable-users' into 'master' 

Conditionally show Users without a group or project in correct section

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/172028



Merged-by: default avatarVijay Hawoldar <vhawoldar@gitlab.com>
Approved-by: default avatarCorinna Gogolok <cgogolok@gitlab.com>
Approved-by: default avatarVijay Hawoldar <vhawoldar@gitlab.com>
Reviewed-by: default avatarCorinna Gogolok <cgogolok@gitlab.com>
Reviewed-by: default avatarVijay Hawoldar <vhawoldar@gitlab.com>
Reviewed-by: default avatarAngelo Gulina <agulina@gitlab.com>
Reviewed-by: default avatarKos Palchyk <kpalchyk@gitlab.com>
Co-authored-by: default avatarAngelo Gulina <agulina@gitlab.com>
No related branches found
No related tags found
无相关合并请求
...@@ -10,7 +10,9 @@ def billable ...@@ -10,7 +10,9 @@ def billable
end end
def non_billable def non_billable
bots + non_billable_guests return base_non_billable + without_groups_and_projects if exclude_guests_from_active_count?
base_non_billable
end end
def non_billable_guests def non_billable_guests
...@@ -24,6 +26,10 @@ def active ...@@ -24,6 +26,10 @@ def active
private private
def base_non_billable
bots + non_billable_guests
end
def base_billable_users def base_billable_users
[ [
with_highest_role_reporter, with_highest_role_reporter,
...@@ -34,13 +40,17 @@ def base_billable_users ...@@ -34,13 +40,17 @@ def base_billable_users
end end
def guest_billable_users def guest_billable_users
if License.current&.exclude_guests_from_active_count? if exclude_guests_from_active_count?
[with_highest_role_guest_with_custom_role] [with_highest_role_guest_with_custom_role]
else else
[without_groups_and_projects, with_highest_role_guest, with_highest_role_minimal_access] [without_groups_and_projects, with_highest_role_guest, with_highest_role_minimal_access]
end end
end end
def exclude_guests_from_active_count?
License.current&.exclude_guests_from_active_count?
end
class_methods do class_methods do
extend ::Gitlab::Utils::Override extend ::Gitlab::Utils::Override
......
- exclude_guests_from_active_count = License.current&.exclude_guests_from_active_count?
%p.gl-font-bold.gl-mt-7 %p.gl-font-bold.gl-mt-7
= s_('AdminArea|Breakdown of Billable users') = s_('AdminArea|Breakdown of Billable users')
%table.gl-table.gl-text-gray-500.gl-w-full %table.gl-table.gl-text-gray-500.gl-w-full
%tr = render_if_exists 'admin/dashboard/without_group_or_project_row', users_statistics: @users_statistics unless exclude_guests_from_active_count
%td{ class: '!gl-p-5' }
= s_('AdminArea|Users without a Group and Project')
= render_if_exists 'admin/dashboard/included_free_in_license_tooltip'
%td.gl-text-right{ class: '!gl-p-5' }
= @users_statistics&.without_groups_and_projects
= render_if_exists 'admin/dashboard/minimal_access_stats_row', users_statistics: @users_statistics = render_if_exists 'admin/dashboard/minimal_access_stats_row', users_statistics: @users_statistics
= render_if_exists 'admin/dashboard/elevated_role_stats_row', users_statistics: @users_statistics = render_if_exists 'admin/dashboard/elevated_role_stats_row', users_statistics: @users_statistics
%tr %tr
...@@ -43,6 +40,7 @@ ...@@ -43,6 +40,7 @@
%p.gl-font-bold.gl-mt-8 %p.gl-font-bold.gl-mt-8
= s_('AdminArea|Breakdown of Non-Billable users') = s_('AdminArea|Breakdown of Non-Billable users')
%table.gl-table.gl-text-gray-500.gl-w-full %table.gl-table.gl-text-gray-500.gl-w-full
= render_if_exists 'admin/dashboard/without_group_or_project_row', users_statistics: @users_statistics if exclude_guests_from_active_count
%tr %tr
%td{ class: '!gl-p-5' } %td{ class: '!gl-p-5' }
= s_('AdminArea|Users with highest role') = s_('AdminArea|Users with highest role')
......
- users_statistics = local_assigns.fetch(:users_statistics)
%tr
%td{ class: '!gl-p-5' }
= s_('AdminArea|Users without a Group and Project')
= render 'admin/dashboard/included_free_in_license_tooltip'
%td.gl-text-right{ class: '!gl-p-5' }
= users_statistics&.without_groups_and_projects
...@@ -14,8 +14,7 @@ ...@@ -14,8 +14,7 @@
context 'when there is an ultimate license' do context 'when there is an ultimate license' do
before do before do
license = create(:license, plan: License::ULTIMATE_PLAN) create_current_license(plan: License::ULTIMATE_PLAN)
allow(License).to receive(:current).and_return(license)
end end
it 'excludes blocked users, bots, guest users, users without a group or project and minimal access users' do it 'excludes blocked users, bots, guest users, users without a group or project and minimal access users' do
...@@ -34,6 +33,16 @@ ...@@ -34,6 +33,16 @@
it 'sums bots and guests values' do it 'sums bots and guests values' do
expect(users_statistics.non_billable).to eq(5) expect(users_statistics.non_billable).to eq(5)
end end
context 'when there is an ultimate license' do
before do
create_current_license(plan: License::ULTIMATE_PLAN)
end
it 'includes users without a group or project' do
expect(users_statistics.non_billable).to eq(28)
end
end
end end
describe '#non_billable_guests' do describe '#non_billable_guests' do
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册