diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-20 16:18:24 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-20 16:18:24 +0300 |
commit | 0653e08efd039a5905f3fa4f6e9cef9f5d2f799c (patch) | |
tree | 4dcc884cf6d81db44adae4aa99f8ec1233a41f55 /app/serializers | |
parent | 744144d28e3e7fddc117924fef88de5d9674fe4c (diff) |
Add latest changes from gitlab-org/gitlab@14-3-stable-eev14.3.0-rc42
Diffstat (limited to 'app/serializers')
-rw-r--r-- | app/serializers/group_child_entity.rb | 14 | ||||
-rw-r--r-- | app/serializers/group_entity.rb | 4 | ||||
-rw-r--r-- | app/serializers/issuable_sidebar_extras_entity.rb | 17 |
3 files changed, 9 insertions, 26 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 diff --git a/app/serializers/group_entity.rb b/app/serializers/group_entity.rb index 0e1bc9a6b3d..66919c49320 100644 --- a/app/serializers/group_entity.rb +++ b/app/serializers/group_entity.rb @@ -40,10 +40,6 @@ class GroupEntity < Grape::Entity GroupsFinder.new(request.current_user, parent: group).execute.any? end - expose :number_projects_with_delimiter do |group| - number_with_delimiter(GroupProjectsFinder.new(group: group, current_user: request.current_user).execute.count) - end - expose :number_users_with_delimiter do |group| number_with_delimiter(group.users.count) end diff --git a/app/serializers/issuable_sidebar_extras_entity.rb b/app/serializers/issuable_sidebar_extras_entity.rb index 77f2e34fa5d..68c71cd5cf3 100644 --- a/app/serializers/issuable_sidebar_extras_entity.rb +++ b/app/serializers/issuable_sidebar_extras_entity.rb @@ -3,23 +3,6 @@ class IssuableSidebarExtrasEntity < Grape::Entity include RequestAwareEntity include TimeTrackableEntity - include NotificationsHelper - - expose :participants, using: ::API::Entities::UserBasic do |issuable| - issuable.participants(request.current_user) - end - - expose :project_emails_disabled do |issuable| - issuable.project.emails_disabled? - end - - expose :subscribe_disabled_description do |issuable| - notification_description(:owner_disabled) - end - - expose :subscribed do |issuable| - issuable.subscribed?(request.current_user, issuable.project) - end expose :assignees, using: ::API::Entities::UserBasic end |