Commit 1fb49b87 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Only show root groups on the dashboard

The children are lazy-loaded when expanding
parent 3299a970
...@@ -2,19 +2,9 @@ class Dashboard::GroupsController < Dashboard::ApplicationController ...@@ -2,19 +2,9 @@ class Dashboard::GroupsController < Dashboard::ApplicationController
def index def index
@sort = params[:sort] || 'id_desc' @sort = params[:sort] || 'id_desc'
@groups = @groups = GroupsFinder.new(current_user, all_available: false).execute
if params[:parent_id] && Group.supports_nested_groups? # Only show root groups if no parent-id is given
parent = Group.find_by(id: params[:parent_id]) @groups = @groups.where(parent_id: params[:parent_id])
if can?(current_user, :read_group, parent)
GroupsFinder.new(current_user, parent: parent).execute
else
Group.none
end
else
current_user.groups
end
@groups = @groups.search(params[:filter]) if params[:filter].present? @groups = @groups.search(params[:filter]) if params[:filter].present?
@groups = @groups.includes(:route) @groups = @groups.includes(:route)
@groups = @groups.sort(@sort) @groups = @groups.sort(@sort)
......
...@@ -64,7 +64,6 @@ class GroupChildrenFinder ...@@ -64,7 +64,6 @@ class GroupChildrenFinder
else else
base_groups base_groups
end end
groups = groups
groups.sort(params[:sort]).includes(:route) groups.sort(params[:sort]).includes(:route)
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment