diff options
author | Jarka Kadlecová <jarka@gitlab.com> | 2018-01-24 09:06:24 +0300 |
---|---|---|
committer | Jarka Kadlecová <jarka@gitlab.com> | 2018-02-01 09:04:37 +0300 |
commit | 7f0ebeff1affcd4f5155790cc5a5884b052695af (patch) | |
tree | a5ecccef5c658686b022a284087e71ba541e923f /app | |
parent | 8f5d1d1371b47ab810a9e5ddff483f669d149363 (diff) |
Include subgroup issuables on the group page
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/concerns/issuable_collections.rb | 1 | ||||
-rw-r--r-- | app/finders/group_projects_finder.rb | 11 | ||||
-rw-r--r-- | app/finders/issuable_finder.rb | 4 |
3 files changed, 14 insertions, 2 deletions
diff --git a/app/controllers/concerns/issuable_collections.rb b/app/controllers/concerns/issuable_collections.rb index b25e753a5ad..755e324a53f 100644 --- a/app/controllers/concerns/issuable_collections.rb +++ b/app/controllers/concerns/issuable_collections.rb @@ -84,6 +84,7 @@ module IssuableCollections @filter_params[:project_id] = @project.id elsif @group @filter_params[:group_id] = @group.id + @filter_params[:include_subgroups] = true else # TODO: this filter ignore issues/mr created in public or # internal repos where you are not a member. Enable this filter diff --git a/app/finders/group_projects_finder.rb b/app/finders/group_projects_finder.rb index f2d3b90b8e2..f73cf8adb4d 100644 --- a/app/finders/group_projects_finder.rb +++ b/app/finders/group_projects_finder.rb @@ -87,8 +87,17 @@ class GroupProjectsFinder < ProjectsFinder options.fetch(:only_shared, false) end + # subgroups are supported only for owned projects not for shared + def include_subgroups? + options.fetch(:include_subgroups, false) + end + def owned_projects - group.projects + if include_subgroups? + Project.where(namespace_id: group.self_and_descendants.select(:id)) + else + group.projects + end end def shared_projects diff --git a/app/finders/issuable_finder.rb b/app/finders/issuable_finder.rb index 493e7985d75..0fe3000ca01 100644 --- a/app/finders/issuable_finder.rb +++ b/app/finders/issuable_finder.rb @@ -43,6 +43,7 @@ class IssuableFinder search sort state + include_subgroups ].freeze ARRAY_PARAMS = { label_name: [], iids: [], assignee_username: [] }.freeze @@ -148,7 +149,8 @@ class IssuableFinder if current_user && params[:authorized_only].presence && !current_user_related? current_user.authorized_projects elsif group - GroupProjectsFinder.new(group: group, current_user: current_user).execute + finder_options = { include_subgroups: params[:include_subgroups], only_owned: true } + GroupProjectsFinder.new(group: group, current_user: current_user, options: finder_options).execute else ProjectsFinder.new(current_user: current_user, project_ids_relation: item_project_ids(items)).execute end |