Welcome to mirror list, hosted at ThFree Co, Russian Federation.

group_tree.rb « concerns « controllers « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b569029283fe03ecb8e70ca891121ab9bd518990 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
module GroupTree
  # rubocop:disable Gitlab/ModuleWithInstanceVariables
  def render_group_tree(groups)
    @groups = if params[:filter].present?
                Gitlab::GroupHierarchy.new(groups.search(params[:filter]))
                  .base_and_ancestors
              else
                # Only show root groups if no parent-id is given
                groups.where(parent_id: params[:parent_id])
              end

    @groups = @groups.with_selects_for_list(archived: params[:archived])
                .sort(@sort = params[:sort])
                .page(params[:page])

    respond_to do |format|
      format.html
      format.json do
        serializer = GroupChildSerializer.new(current_user: current_user)
                       .with_pagination(request, response)
        serializer.expand_hierarchy if params[:filter].present?
        render json: serializer.represent(@groups)
      end
    end
    # rubocop:enable Gitlab/ModuleWithInstanceVariables
  end
end