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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorBob Van Landuyt <bob@vanlanduyt.co>2017-09-13 18:16:30 +0300
committerBob Van Landuyt <bob@vanlanduyt.co>2017-10-04 23:49:41 +0300
commit3a4dc55f2924debcdbb37eb63d8ce57b1358df81 (patch)
tree614d82e8b26b5c2698c564d9e244a86c35d714fe /app
parent39df53ff0aeac24d390eea52a1df6dfe103a4c14 (diff)
Reuse the groups tree for explore and dashboard.
Diffstat (limited to 'app')
-rw-r--r--app/controllers/concerns/group_tree.rb19
-rw-r--r--app/controllers/dashboard/groups_controller.rb20
-rw-r--r--app/controllers/explore/groups_controller.rb16
3 files changed, 26 insertions, 29 deletions
diff --git a/app/controllers/concerns/group_tree.rb b/app/controllers/concerns/group_tree.rb
new file mode 100644
index 00000000000..6d5682ff769
--- /dev/null
+++ b/app/controllers/concerns/group_tree.rb
@@ -0,0 +1,19 @@
+module GroupTree
+ def render_group_tree(groups)
+ # Only show root groups if no parent-id is given
+ @groups = groups.where(parent_id: params[:parent_id])
+ @groups = @groups.search(params[:filter]) if params[:filter].present?
+ @groups = @groups.includes(:route)
+ @groups = @groups.sort(@sort = params[:sort])
+ @groups = @groups.page(params[:page])
+
+ respond_to do |format|
+ format.html
+ format.json do
+ serializer = GroupChildSerializer.new(current_user: current_user)
+ .with_pagination(request, response)
+ render json: serializer.represent(@groups)
+ end
+ end
+ end
+end
diff --git a/app/controllers/dashboard/groups_controller.rb b/app/controllers/dashboard/groups_controller.rb
index 6488e0b6c09..025769f512a 100644
--- a/app/controllers/dashboard/groups_controller.rb
+++ b/app/controllers/dashboard/groups_controller.rb
@@ -1,20 +1,8 @@
class Dashboard::GroupsController < Dashboard::ApplicationController
- def index
- @groups = GroupsFinder.new(current_user, all_available: false).execute
- # Only show root groups if no parent-id is given
- @groups = @groups.where(parent_id: params[:parent_id])
- @groups = @groups.search(params[:filter]) if params[:filter].present?
- @groups = @groups.includes(:route)
- @groups = @groups.sort(@sort = params[:sort])
- @groups = @groups.page(params[:page])
+ include GroupTree
- respond_to do |format|
- format.html
- format.json do
- serializer = GroupChildSerializer.new(current_user: current_user)
- .with_pagination(request, response)
- render json: serializer.represent(@groups)
- end
- end
+ def index
+ groups = GroupsFinder.new(current_user, all_available: false).execute
+ render_group_tree(groups)
end
end
diff --git a/app/controllers/explore/groups_controller.rb b/app/controllers/explore/groups_controller.rb
index 81883c543ba..fa0a0f68fbc 100644
--- a/app/controllers/explore/groups_controller.rb
+++ b/app/controllers/explore/groups_controller.rb
@@ -1,17 +1,7 @@
class Explore::GroupsController < Explore::ApplicationController
- def index
- @groups = GroupsFinder.new(current_user).execute
- @groups = @groups.search(params[:filter_groups]) if params[:filter_groups].present?
- @groups = @groups.sort(@sort = params[:sort])
- @groups = @groups.page(params[:page])
+ include GroupTree
- respond_to do |format|
- format.html
- format.json do
- render json: {
- html: view_to_html_string("explore/groups/_groups", locals: { groups: @groups })
- }
- end
- end
+ def index
+ render_group_tree GroupsFinder.new(current_user).execute
end
end