Skip to content
Snippets Groups Projects
Verified Commit 34974258 authored by Yorick Peterse's avatar Yorick Peterse
Browse files

Hide nested group UI/API support for MySQL

This hides/disables some UI elements and API parameters related to
nested groups when MySQL is used, since nested groups are not supported
for MySQL.
parent ac382b56
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -64,6 +64,8 @@ class GroupsController < Groups::ApplicationController
end
 
def subgroups
return not_found unless Group.supports_nested_groups?
@nested_groups = GroupsFinder.new(current_user, parent: group).execute
@nested_groups = @nested_groups.search(params[:filter_groups]) if params[:filter_groups].present?
end
Loading
Loading
Loading
Loading
@@ -178,7 +178,7 @@ class Namespace < ActiveRecord::Base
 
# Returns all the ancestors of the current namespaces.
def ancestors
return self.class.none if !Group.supports_nested_groups? || !parent_id
return self.class.none unless parent_id
 
Gitlab::GroupHierarchy.
new(self.class.where(id: parent_id)).
Loading
Loading
@@ -187,8 +187,6 @@ class Namespace < ActiveRecord::Base
 
# Returns all the descendants of the current namespace.
def descendants
return self.class.none unless Group.supports_nested_groups?
Gitlab::GroupHierarchy.
new(self.class.where(parent_id: id)).
base_and_descendants
Loading
Loading
Loading
Loading
@@ -509,8 +509,6 @@ class User < ActiveRecord::Base
# Returns a relation of groups the user has access to, including their parent
# and child groups (recursively).
def all_expanded_groups
return groups unless Group.supports_nested_groups?
Gitlab::GroupHierarchy.new(groups).all_groups
end
 
Loading
Loading
Loading
Loading
@@ -2,6 +2,7 @@
= nav_link(page: group_path(@group)) do
= link_to group_path(@group) do
Projects
= nav_link(page: subgroups_group_path(@group)) do
= link_to subgroups_group_path(@group) do
Subgroups
- if Group.supports_nested_groups?
= nav_link(page: subgroups_group_path(@group)) do
= link_to subgroups_group_path(@group) do
Subgroups
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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
 
Loading
Loading
@@ -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
 
Loading
Loading
Loading
Loading
@@ -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,
Loading
Loading
Loading
Loading
@@ -26,7 +26,7 @@ describe GroupsController do
end
end
 
describe 'GET #subgroups' do
describe 'GET #subgroups', :nested_groups do
let!(:public_subgroup) { create(:group, :public, parent: group) }
let!(:private_subgroup) { create(:group, :private, parent: group) }
 
Loading
Loading
Loading
Loading
@@ -95,7 +95,7 @@ RSpec.configure do |config|
end
 
config.around(:each, :nested_groups) do |example|
example.run if Gitlab::GroupHierarchy.supports_nested_groups?
example.run if Group.supports_nested_groups?
end
 
config.around(:each, :postgresql) do |example|
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment