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:
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