diff options
author | Douwe Maan <douwe@gitlab.com> | 2017-10-17 10:03:03 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2017-10-17 10:03:03 +0000 |
commit | 79e889122b9f1cb41eb75ee33e94e625a8c679e2 (patch) | |
tree | eb8bba9933b3241b3ca80574bc47fc40d4f3950f /app/controllers/concerns | |
parent | 3fa410c831dac1dd1a74a14260ed99a5920218f8 (diff) | |
parent | 893402d477436d36b48c2fd0244576a0d16e9425 (diff) | |
download | gitlab-ce-79e889122b9f1cb41eb75ee33e94e625a8c679e2.tar.gz |
Merge branch 'bvl-group-trees' into 'master'
Show collapsible tree on the project show page
Closes #30343
See merge request gitlab-org/gitlab-ce!14055
Diffstat (limited to 'app/controllers/concerns')
-rw-r--r-- | app/controllers/concerns/group_tree.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/app/controllers/concerns/group_tree.rb b/app/controllers/concerns/group_tree.rb new file mode 100644 index 00000000000..9d4f97aa443 --- /dev/null +++ b/app/controllers/concerns/group_tree.rb @@ -0,0 +1,24 @@ +module GroupTree + 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 + end +end |