Commit 5428e3ab authored by Małgorzata Ksionek's avatar Małgorzata Ksionek Committed by Jan Provaznik

Do not show unassigned members on admin group page

Update admin views

Add specs for group

Fix little things

Fix

Fix
parent b04dd44f
...@@ -19,7 +19,7 @@ class Admin::GroupsController < Admin::ApplicationController ...@@ -19,7 +19,7 @@ class Admin::GroupsController < Admin::ApplicationController
# the Group with statistics). # the Group with statistics).
@group = Group.with_statistics.find(group&.id) @group = Group.with_statistics.find(group&.id)
@members = present_members( @members = present_members(
@group.members.order("access_level DESC").page(params[:members_page])) group_members.order("access_level DESC").page(params[:members_page]))
@requesters = present_members( @requesters = present_members(
AccessRequestsFinder.new(@group).execute(current_user)) AccessRequestsFinder.new(@group).execute(current_user))
@projects = @group.projects.with_statistics.page(params[:projects_page]) @projects = @group.projects.with_statistics.page(params[:projects_page])
...@@ -82,6 +82,10 @@ class Admin::GroupsController < Admin::ApplicationController ...@@ -82,6 +82,10 @@ class Admin::GroupsController < Admin::ApplicationController
@group ||= Group.find_by_full_path(params[:id]) @group ||= Group.find_by_full_path(params[:id])
end end
def group_members
@group.members.non_unassigned
end
def group_params def group_params
params.require(:group).permit(allowed_group_params) params.require(:group).permit(allowed_group_params)
end end
......
...@@ -397,6 +397,10 @@ class Group < Namespace ...@@ -397,6 +397,10 @@ class Group < Namespace
]) ])
end end
def users_count
members.non_unassigned.count
end
# Returns all users that are members of projects # Returns all users that are members of projects
# belonging to the current group or sub-groups # belonging to the current group or sub-groups
def project_users_with_descendants def project_users_with_descendants
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
%span.gl-ml-5 %span.gl-ml-5
= sprite_icon('users', css_class: 'gl-vertical-align-text-bottom') = sprite_icon('users', css_class: 'gl-vertical-align-text-bottom')
= number_with_delimiter(group.users.count) = number_with_delimiter(group.users_count)
%span.gl-ml-5.visibility-icon.has-tooltip{ data: { container: 'body', placement: 'left' }, title: visibility_icon_description(group) } %span.gl-ml-5.visibility-icon.has-tooltip{ data: { container: 'body', placement: 'left' }, title: visibility_icon_description(group) }
= visibility_level_icon(group.visibility_level) = visibility_level_icon(group.visibility_level)
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
module EE module EE
module GroupMember module GroupMember
extend ActiveSupport::Concern extend ActiveSupport::Concern
extend ::Gitlab::Utils::Override
prepended do prepended do
extend ::Gitlab::Utils::Override extend ::Gitlab::Utils::Override
...@@ -27,8 +26,6 @@ module EE ...@@ -27,8 +26,6 @@ module EE
end end
class_methods do class_methods do
extend ::Gitlab::Utils::Override
def member_of_group?(group, user) def member_of_group?(group, user)
exists?(group: group, user: user) exists?(group: group, user: user)
end end
......
...@@ -13,13 +13,6 @@ module EE ...@@ -13,13 +13,6 @@ module EE
can?(current_user, override_member_permission, member) can?(current_user, override_member_permission, member)
end end
override :valid_level_roles
def valid_level_roles
return super if member.source.is_a?(Project)
super.except("Unassigned")
end
private private
def override_member_permission def override_member_permission
......
...@@ -668,6 +668,34 @@ RSpec.describe Group do ...@@ -668,6 +668,34 @@ RSpec.describe Group do
end end
end end
describe '#unassigned_role_allowed?' do
subject { group.unassigned_role_allowed? }
context 'licensed' do
before do
stub_licensed_features(unassigned_role: true)
end
it 'returns true for licensed instance' do
is_expected.to be true
end
it 'returns false for subgroup in licensed instance' do
expect(create(:group, parent: group).unassigned_role_allowed?).to be false
end
end
context 'unlicensed' do
before do
stub_licensed_features(unassigned_role: false)
end
it 'returns false unlicensed instance' do
is_expected.to be false
end
end
end
describe '#saml_discovery_token' do describe '#saml_discovery_token' do
it 'returns existing tokens' do it 'returns existing tokens' do
group = create(:group, saml_discovery_token: 'existing') group = create(:group, saml_discovery_token: 'existing')
......
...@@ -41,10 +41,10 @@ module Gitlab ...@@ -41,10 +41,10 @@ module Gitlab
def options def options
{ {
"Guest" => GUEST, "Guest" => GUEST,
"Reporter" => REPORTER, "Reporter" => REPORTER,
"Developer" => DEVELOPER, "Developer" => DEVELOPER,
"Maintainer" => MAINTAINER "Maintainer" => MAINTAINER
} }
end end
......
...@@ -112,7 +112,7 @@ RSpec.describe AuthorizedProjectUpdate::ProjectGroupLinkCreateService do ...@@ -112,7 +112,7 @@ RSpec.describe AuthorizedProjectUpdate::ProjectGroupLinkCreateService do
end end
end end
context 'unapproved access requests' do context 'unassigned member' do
before do before do
create(:group_member, :unassigned, user: group_user, group: group) create(:group_member, :unassigned, user: group_user, group: group)
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