debian-mirror-gitlab/lib/api/entities/group_detail.rb
2022-03-02 08:16:31 +05:30

39 lines
1.3 KiB
Ruby

# frozen_string_literal: true
module API
module Entities
class GroupDetail < Group
expose :shared_with_groups do |group, options|
SharedGroupWithGroup.represent(group.shared_with_group_links_visible_to_user(options[:current_user]))
end
expose :runners_token, if: lambda { |group, options| options[:user_can_admin_group] }
expose :prevent_sharing_groups_outside_hierarchy, if: ->(group) { group.root? }
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, options)
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, options)
end
def projects_limit
GroupProjectsFinder::DEFAULT_PROJECTS_LIMIT
end
end
end
end
API::Entities::GroupDetail.prepend_mod_with('API::Entities::GroupDetail')