2020-01-30 13:08:57 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module API
|
|
|
|
module Entities
|
|
|
|
class GroupDetail < Group
|
2020-06-09 14:08:28 -04:00
|
|
|
expose :shared_with_groups do |group, options|
|
2022-01-16 19:14:49 -05:00
|
|
|
SharedGroupWithGroup.represent(group.shared_with_group_links_visible_to_user(options[:current_user]))
|
2020-06-09 14:08:28 -04:00
|
|
|
end
|
2022-06-21 23:08:59 -04:00
|
|
|
expose :runners_token, if: ->(_, options) { options[:user_can_admin_group] }
|
2022-07-28 20:10:57 -04:00
|
|
|
expose :prevent_sharing_groups_outside_hierarchy,
|
|
|
|
if: ->(group) { group.root? && group.namespace_settings.present? }
|
2020-07-09 11:08:59 -04:00
|
|
|
|
2022-06-21 23:08:59 -04:00
|
|
|
expose :projects,
|
|
|
|
if: ->(_, options) { options[:with_projects] },
|
|
|
|
using: Entities::Project do |group, options|
|
2020-01-30 13:08:57 -05:00
|
|
|
projects = GroupProjectsFinder.new(
|
|
|
|
group: group,
|
|
|
|
current_user: options[:current_user],
|
|
|
|
options: { only_owned: true, limit: projects_limit }
|
|
|
|
).execute
|
|
|
|
|
2021-10-05 11:12:53 -04:00
|
|
|
Entities::Project.prepare_relation(projects, options)
|
2020-01-30 13:08:57 -05:00
|
|
|
end
|
|
|
|
|
2022-06-21 23:08:59 -04:00
|
|
|
expose :shared_projects,
|
|
|
|
if: ->(_, options) { options[:with_projects] },
|
|
|
|
using: Entities::Project do |group, options|
|
2020-01-30 13:08:57 -05:00
|
|
|
projects = GroupProjectsFinder.new(
|
|
|
|
group: group,
|
|
|
|
current_user: options[:current_user],
|
|
|
|
options: { only_shared: true, limit: projects_limit }
|
|
|
|
).execute
|
|
|
|
|
2021-10-05 11:12:53 -04:00
|
|
|
Entities::Project.prepare_relation(projects, options)
|
2020-01-30 13:08:57 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def projects_limit
|
2021-05-25 20:11:07 -04:00
|
|
|
GroupProjectsFinder::DEFAULT_PROJECTS_LIMIT
|
2020-01-30 13:08:57 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2020-02-17 07:09:20 -05:00
|
|
|
|
2021-05-11 17:10:21 -04:00
|
|
|
API::Entities::GroupDetail.prepend_mod_with('API::Entities::GroupDetail')
|