diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-30 21:08:57 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-30 21:08:57 +0300 |
commit | d8121cb00b8bbd281d7362902590b110639bdeba (patch) | |
tree | 0a0f71b247b232773a46732d9f74aa3cfed0ef1a /lib/api/entities/group_detail.rb | |
parent | 536aa3a1f4b96abc4ca34489bf2cbe503afcded7 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/api/entities/group_detail.rb')
-rw-r--r-- | lib/api/entities/group_detail.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/api/entities/group_detail.rb b/lib/api/entities/group_detail.rb new file mode 100644 index 00000000000..97b98aac585 --- /dev/null +++ b/lib/api/entities/group_detail.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +module API + module Entities + class GroupDetail < Group + expose :runners_token, if: lambda { |group, options| options[:user_can_admin_group] } + expose :projects, using: Entities::Project do |group, options| + projects = GroupProjectsFinder.new( + group: group, + current_user: options[:current_user], + options: { only_owned: true, limit: projects_limit } + ).execute + + Entities::Project.prepare_relation(projects) + end + + expose :shared_projects, using: Entities::Project do |group, options| + projects = GroupProjectsFinder.new( + group: group, + current_user: options[:current_user], + options: { only_shared: true, limit: projects_limit } + ).execute + + Entities::Project.prepare_relation(projects) + end + + def projects_limit + if ::Feature.enabled?(:limit_projects_in_groups_api, default_enabled: true) + GroupProjectsFinder::DEFAULT_PROJECTS_LIMIT + else + nil + end + end + end + end +end |