2018-09-23 19:44:14 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-10-11 16:27:53 +00:00
|
|
|
module Groups
|
|
|
|
class ChildrenController < Groups::ApplicationController
|
2020-11-23 15:09:37 +00:00
|
|
|
extend ::Gitlab::Utils::Override
|
|
|
|
|
2017-10-11 16:27:53 +00:00
|
|
|
before_action :group
|
2017-12-11 14:21:06 +00:00
|
|
|
skip_cross_project_access_check :index
|
2017-10-11 16:27:53 +00:00
|
|
|
|
2020-10-06 12:08:38 +00:00
|
|
|
feature_category :subgroups
|
|
|
|
|
2022-04-19 15:08:32 +00:00
|
|
|
# TODO: Set to higher urgency after resolving https://gitlab.com/gitlab-org/gitlab/-/issues/331494
|
|
|
|
urgency :low, [:index]
|
|
|
|
|
2017-10-11 16:27:53 +00:00
|
|
|
def index
|
2020-11-23 15:09:37 +00:00
|
|
|
params[:sort] ||= @group_projects_sort
|
2017-10-11 16:27:53 +00:00
|
|
|
parent = if params[:parent_id].present?
|
|
|
|
GroupFinder.new(current_user).execute(id: params[:parent_id])
|
|
|
|
else
|
|
|
|
@group
|
|
|
|
end
|
|
|
|
|
|
|
|
if parent.nil?
|
|
|
|
render_404
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
setup_children(parent)
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
format.json do
|
|
|
|
serializer = GroupChildSerializer
|
|
|
|
.new(current_user: current_user)
|
|
|
|
.with_pagination(request, response)
|
|
|
|
serializer.expand_hierarchy(parent) if params[:filter].present?
|
|
|
|
render json: serializer.represent(@children)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
def setup_children(parent)
|
|
|
|
@children = GroupDescendantsFinder.new(current_user: current_user,
|
|
|
|
parent_group: parent,
|
2019-01-02 20:06:55 +00:00
|
|
|
params: params.to_unsafe_h).execute
|
2017-10-11 16:27:53 +00:00
|
|
|
@children = @children.page(params[:page])
|
|
|
|
end
|
2020-11-23 15:09:37 +00:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
override :has_project_list?
|
|
|
|
def has_project_list?
|
|
|
|
true
|
|
|
|
end
|
2017-10-11 16:27:53 +00:00
|
|
|
end
|
|
|
|
end
|