diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/api/entities.rb | 5 | ||||
| -rw-r--r-- | lib/api/groups.rb | 6 | ||||
| -rw-r--r-- | lib/api/v3/entities.rb | 5 | ||||
| -rw-r--r-- | lib/api/v3/groups.rb | 6 | ||||
| -rw-r--r-- | lib/gitlab/group_hierarchy.rb | 6 | ||||
| -rw-r--r-- | lib/gitlab/project_authorizations/with_nested_groups.rb | 3 |
6 files changed, 24 insertions, 7 deletions
diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 3fc2b453eb6..e3692a58119 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -152,7 +152,10 @@ module API expose :web_url expose :request_access_enabled expose :full_name, :full_path - expose :parent_id + + if ::Group.supports_nested_groups? + expose :parent_id + end expose :statistics, if: :statistics do with_options format_with: -> (value) { value.to_i } do diff --git a/lib/api/groups.rb b/lib/api/groups.rb index 3da7d735da8..ee85b777aff 100644 --- a/lib/api/groups.rb +++ b/lib/api/groups.rb @@ -70,7 +70,11 @@ module API params do requires :name, type: String, desc: 'The name of the group' requires :path, type: String, desc: 'The path of the group' - optional :parent_id, type: Integer, desc: 'The parent group id for creating nested group' + + if ::Group.supports_nested_groups? + optional :parent_id, type: Integer, desc: 'The parent group id for creating nested group' + end + use :optional_params end post do diff --git a/lib/api/v3/entities.rb b/lib/api/v3/entities.rb index 56a9b019f1b..101f566f1dd 100644 --- a/lib/api/v3/entities.rb +++ b/lib/api/v3/entities.rb @@ -137,7 +137,10 @@ module API expose :web_url expose :request_access_enabled expose :full_name, :full_path - expose :parent_id + + if ::Group.supports_nested_groups? + expose :parent_id + end expose :statistics, if: :statistics do with_options format_with: -> (value) { value.to_i } do diff --git a/lib/api/v3/groups.rb b/lib/api/v3/groups.rb index 6187445fc8d..2c52d21fa1c 100644 --- a/lib/api/v3/groups.rb +++ b/lib/api/v3/groups.rb @@ -74,7 +74,11 @@ module API params do requires :name, type: String, desc: 'The name of the group' requires :path, type: String, desc: 'The path of the group' - optional :parent_id, type: Integer, desc: 'The parent group id for creating nested group' + + if ::Group.supports_nested_groups? + optional :parent_id, type: Integer, desc: 'The parent group id for creating nested group' + end + use :optional_params end post do diff --git a/lib/gitlab/group_hierarchy.rb b/lib/gitlab/group_hierarchy.rb index 50e057892a6..e9d5d52cabb 100644 --- a/lib/gitlab/group_hierarchy.rb +++ b/lib/gitlab/group_hierarchy.rb @@ -15,12 +15,16 @@ module Gitlab # Returns a relation that includes the base set of groups and all their # ancestors (recursively). def base_and_ancestors + return model.none unless Group.supports_nested_groups? + base_and_ancestors_cte.apply_to(model.all) end # Returns a relation that includes the base set of groups and all their # descendants (recursively). def base_and_descendants + return model.none unless Group.supports_nested_groups? + base_and_descendants_cte.apply_to(model.all) end @@ -45,6 +49,8 @@ module Gitlab # Using this approach allows us to further add criteria to the relation with # Rails thinking it's selecting data the usual way. def all_groups + return base unless Group.supports_nested_groups? + ancestors = base_and_ancestors_cte descendants = base_and_descendants_cte diff --git a/lib/gitlab/project_authorizations/with_nested_groups.rb b/lib/gitlab/project_authorizations/with_nested_groups.rb index 79c082c08fd..bb0df1e3dad 100644 --- a/lib/gitlab/project_authorizations/with_nested_groups.rb +++ b/lib/gitlab/project_authorizations/with_nested_groups.rb @@ -19,9 +19,6 @@ module Gitlab projects = Project.arel_table links = ProjectGroupLink.arel_table - # These queries don't directly use the user object so they don't depend - # on the state of said object, ensuring the produced queries are always - # the same. relations = [ # The project a user has direct access to. user.projects.select_for_project_authorization, |
