Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-09-20 16:18:24 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-09-20 16:18:24 +0300
commit0653e08efd039a5905f3fa4f6e9cef9f5d2f799c (patch)
tree4dcc884cf6d81db44adae4aa99f8ec1233a41f55 /app/serializers/group_child_entity.rb
parent744144d28e3e7fddc117924fef88de5d9674fe4c (diff)
Add latest changes from gitlab-org/gitlab@14-3-stable-eev14.3.0-rc42
Diffstat (limited to 'app/serializers/group_child_entity.rb')
-rw-r--r--app/serializers/group_child_entity.rb14
1 files changed, 9 insertions, 5 deletions
diff --git a/app/serializers/group_child_entity.rb b/app/serializers/group_child_entity.rb
index 619ca0b5f82..0ca6e7b40d9 100644
--- a/app/serializers/group_child_entity.rb
+++ b/app/serializers/group_child_entity.rb
@@ -37,9 +37,13 @@ class GroupChildEntity < Grape::Entity
if: lambda { |_instance, _options| project? }
# Group only attributes
- expose :children_count, :parent_id, :project_count, :subgroup_count,
+ expose :children_count, :parent_id,
unless: lambda { |_instance, _options| project? }
+ expose :subgroup_count, if: lambda { |group| access_group_counts?(group) }
+
+ expose :project_count, if: lambda { |group| access_group_counts?(group) }
+
expose :leave_path, unless: lambda { |_instance, _options| project? } do |instance|
leave_group_members_path(instance)
end
@@ -52,10 +56,6 @@ class GroupChildEntity < Grape::Entity
end
end
- expose :number_projects_with_delimiter, unless: lambda { |_instance, _options| project? } do |instance|
- number_with_delimiter(instance.project_count)
- end
-
expose :number_users_with_delimiter, unless: lambda { |_instance, _options| project? } do |instance|
number_with_delimiter(instance.member_count)
end
@@ -66,6 +66,10 @@ class GroupChildEntity < Grape::Entity
private
+ def access_group_counts?(group)
+ !project? && can?(request.current_user, :read_counts, group)
+ end
+
# rubocop: disable CodeReuse/ActiveRecord
def membership
return unless request.current_user