Module: GroupTree
- Includes:
- Gitlab::Utils::StrongMemoize
- Included in:
- Dashboard::GroupsController, Explore::GroupsController
- Defined in:
- app/controllers/concerns/group_tree.rb
Instance Method Summary collapse
-
#render_group_tree(groups) ⇒ Object
rubocop:disable Gitlab/ModuleWithInstanceVariables rubocop: disable CodeReuse/ActiveRecord.
Instance Method Details
#render_group_tree(groups) ⇒ Object
rubocop:disable Gitlab/ModuleWithInstanceVariables rubocop: disable CodeReuse/ActiveRecord
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/controllers/concerns/group_tree.rb', line 8 def render_group_tree(groups) groups = groups.sort_by_attribute(@sort = safe_params[:sort]) groups = if search_descendants? filtered_groups_with_ancestors(groups) elsif safe_params[:parent_id].present? groups.where(parent_id: safe_params[:parent_id]).page(safe_params[:page]) else # If `safe_params[:parent_id]` is `nil`, we will only show root-groups groups.by_parent(nil).page(safe_params[:page]) end @groups = groups.with_selects_for_list(archived: safe_params[:archived], active: safe_params[:active]) respond_to do |format| format.html format.json do serializer = GroupChildSerializer.new(current_user: current_user) .with_pagination(request, response) serializer. if search_descendants? render json: serializer.represent(@groups, { upto_preloaded_ancestors_only: inactive? }) end end # rubocop:enable Gitlab/ModuleWithInstanceVariables end |