debian-mirror-gitlab/lib/api/entities/group_detail.rb

45 lines
1.4 KiB
Ruby
Raw Normal View History

2020-03-13 15:44:24 +05:30
# frozen_string_literal: true
module API
module Entities
class GroupDetail < Group
2020-06-23 00:09:42 +05:30
expose :shared_with_groups do |group, options|
2022-03-02 08:16:31 +05:30
SharedGroupWithGroup.represent(group.shared_with_group_links_visible_to_user(options[:current_user]))
2020-06-23 00:09:42 +05:30
end
2022-08-13 15:12:31 +05:30
expose :runners_token, if: ->(_, options) { options[:user_can_admin_group] }
2022-08-27 11:52:29 +05:30
expose :prevent_sharing_groups_outside_hierarchy,
if: ->(group) { group.root? && group.namespace_settings.present? }
2020-07-28 23:09:34 +05:30
2022-08-13 15:12:31 +05:30
expose :projects,
if: ->(_, options) { options[:with_projects] },
using: Entities::Project do |group, options|
2020-03-13 15:44:24 +05:30
projects = GroupProjectsFinder.new(
group: group,
current_user: options[:current_user],
options: { only_owned: true, limit: projects_limit }
).execute
2021-11-18 22:05:49 +05:30
Entities::Project.prepare_relation(projects, options)
2020-03-13 15:44:24 +05:30
end
2022-08-13 15:12:31 +05:30
expose :shared_projects,
if: ->(_, options) { options[:with_projects] },
using: Entities::Project do |group, options|
2020-03-13 15:44:24 +05:30
projects = GroupProjectsFinder.new(
group: group,
current_user: options[:current_user],
options: { only_shared: true, limit: projects_limit }
).execute
2021-11-18 22:05:49 +05:30
Entities::Project.prepare_relation(projects, options)
2020-03-13 15:44:24 +05:30
end
def projects_limit
2021-09-04 01:27:46 +05:30
GroupProjectsFinder::DEFAULT_PROJECTS_LIMIT
2020-03-13 15:44:24 +05:30
end
end
end
end
2021-06-08 01:23:25 +05:30
API::Entities::GroupDetail.prepend_mod_with('API::Entities::GroupDetail')