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
def index
@sort = params[:sort] || 'id_desc'
@groups =
if params[:parent_id] && Group.supports_nested_groups?
parent = Group.find_by(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 = 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)
......
......@@ -64,7 +64,6 @@ class GroupChildrenFinder
else
base_groups
end
groups = groups
groups.sort(params[:sort]).includes(:route)
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