Commit 34974258 authored by Yorick Peterse's avatar Yorick Peterse

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
...@@ -64,6 +64,8 @@ class GroupsController < Groups::ApplicationController ...@@ -64,6 +64,8 @@ class GroupsController < Groups::ApplicationController
end end
def subgroups def subgroups
return not_found unless Group.supports_nested_groups?
@nested_groups = GroupsFinder.new(current_user, parent: group).execute @nested_groups = GroupsFinder.new(current_user, parent: group).execute
@nested_groups = @nested_groups.search(params[:filter_groups]) if params[:filter_groups].present? @nested_groups = @nested_groups.search(params[:filter_groups]) if params[:filter_groups].present?
end end
......
...@@ -178,7 +178,7 @@ class Namespace < ActiveRecord::Base ...@@ -178,7 +178,7 @@ class Namespace < ActiveRecord::Base
# Returns all the ancestors of the current namespaces. # Returns all the ancestors of the current namespaces.
def ancestors def ancestors
return self.class.none if !Group.supports_nested_groups? || !parent_id return self.class.none unless parent_id
Gitlab::GroupHierarchy. Gitlab::GroupHierarchy.
new(self.class.where(id: parent_id)). new(self.class.where(id: parent_id)).
...@@ -187,8 +187,6 @@ class Namespace < ActiveRecord::Base ...@@ -187,8 +187,6 @@ class Namespace < ActiveRecord::Base
# Returns all the descendants of the current namespace. # Returns all the descendants of the current namespace.
def descendants def descendants
return self.class.none unless Group.supports_nested_groups?
Gitlab::GroupHierarchy. Gitlab::GroupHierarchy.
new(self.class.where(parent_id: id)). new(self.class.where(parent_id: id)).
base_and_descendants base_and_descendants
......
...@@ -509,8 +509,6 @@ class User < ActiveRecord::Base ...@@ -509,8 +509,6 @@ class User < ActiveRecord::Base
# Returns a relation of groups the user has access to, including their parent # Returns a relation of groups the user has access to, including their parent
# and child groups (recursively). # and child groups (recursively).
def all_expanded_groups def all_expanded_groups
return groups unless Group.supports_nested_groups?
Gitlab::GroupHierarchy.new(groups).all_groups Gitlab::GroupHierarchy.new(groups).all_groups
end end
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
= nav_link(page: group_path(@group)) do = nav_link(page: group_path(@group)) do
= link_to group_path(@group) do = link_to group_path(@group) do
Projects Projects
- if Group.supports_nested_groups?
= nav_link(page: subgroups_group_path(@group)) do = nav_link(page: subgroups_group_path(@group)) do
= link_to subgroups_group_path(@group) do = link_to subgroups_group_path(@group) do
Subgroups Subgroups
...@@ -152,7 +152,10 @@ module API ...@@ -152,7 +152,10 @@ module API
expose :web_url expose :web_url
expose :request_access_enabled expose :request_access_enabled
expose :full_name, :full_path expose :full_name, :full_path
if ::Group.supports_nested_groups?
expose :parent_id expose :parent_id
end
expose :statistics, if: :statistics do expose :statistics, if: :statistics do
with_options format_with: -> (value) { value.to_i } do with_options format_with: -> (value) { value.to_i } do
......
...@@ -70,7 +70,11 @@ module API ...@@ -70,7 +70,11 @@ module API
params do params do
requires :name, type: String, desc: 'The name of the group' requires :name, type: String, desc: 'The name of the group'
requires :path, type: String, desc: 'The path of the group' requires :path, type: String, desc: 'The path of the group'
if ::Group.supports_nested_groups?
optional :parent_id, type: Integer, desc: 'The parent group id for creating nested group' optional :parent_id, type: Integer, desc: 'The parent group id for creating nested group'
end
use :optional_params use :optional_params
end end
post do post do
......
...@@ -137,7 +137,10 @@ module API ...@@ -137,7 +137,10 @@ module API
expose :web_url expose :web_url
expose :request_access_enabled expose :request_access_enabled
expose :full_name, :full_path expose :full_name, :full_path
if ::Group.supports_nested_groups?
expose :parent_id expose :parent_id
end
expose :statistics, if: :statistics do expose :statistics, if: :statistics do
with_options format_with: -> (value) { value.to_i } do with_options format_with: -> (value) { value.to_i } do
......
...@@ -74,7 +74,11 @@ module API ...@@ -74,7 +74,11 @@ module API
params do params do
requires :name, type: String, desc: 'The name of the group' requires :name, type: String, desc: 'The name of the group'
requires :path, type: String, desc: 'The path of the group' requires :path, type: String, desc: 'The path of the group'
if ::Group.supports_nested_groups?
optional :parent_id, type: Integer, desc: 'The parent group id for creating nested group' optional :parent_id, type: Integer, desc: 'The parent group id for creating nested group'
end
use :optional_params use :optional_params
end end
post do post do
......
...@@ -15,12 +15,16 @@ module Gitlab ...@@ -15,12 +15,16 @@ module Gitlab
# Returns a relation that includes the base set of groups and all their # Returns a relation that includes the base set of groups and all their
# ancestors (recursively). # ancestors (recursively).
def base_and_ancestors def base_and_ancestors
return model.none unless Group.supports_nested_groups?
base_and_ancestors_cte.apply_to(model.all) base_and_ancestors_cte.apply_to(model.all)
end end
# Returns a relation that includes the base set of groups and all their # Returns a relation that includes the base set of groups and all their
# descendants (recursively). # descendants (recursively).
def base_and_descendants def base_and_descendants
return model.none unless Group.supports_nested_groups?
base_and_descendants_cte.apply_to(model.all) base_and_descendants_cte.apply_to(model.all)
end end
...@@ -45,6 +49,8 @@ module Gitlab ...@@ -45,6 +49,8 @@ module Gitlab
# Using this approach allows us to further add criteria to the relation with # Using this approach allows us to further add criteria to the relation with
# Rails thinking it's selecting data the usual way. # Rails thinking it's selecting data the usual way.
def all_groups def all_groups
return base unless Group.supports_nested_groups?
ancestors = base_and_ancestors_cte ancestors = base_and_ancestors_cte
descendants = base_and_descendants_cte descendants = base_and_descendants_cte
......
...@@ -19,9 +19,6 @@ module Gitlab ...@@ -19,9 +19,6 @@ module Gitlab
projects = Project.arel_table projects = Project.arel_table
links = ProjectGroupLink.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 = [ relations = [
# The project a user has direct access to. # The project a user has direct access to.
user.projects.select_for_project_authorization, user.projects.select_for_project_authorization,
......
...@@ -26,7 +26,7 @@ describe GroupsController do ...@@ -26,7 +26,7 @@ describe GroupsController do
end end
end end
describe 'GET #subgroups' do describe 'GET #subgroups', :nested_groups do
let!(:public_subgroup) { create(:group, :public, parent: group) } let!(:public_subgroup) { create(:group, :public, parent: group) }
let!(:private_subgroup) { create(:group, :private, parent: group) } let!(:private_subgroup) { create(:group, :private, parent: group) }
......
...@@ -95,7 +95,7 @@ RSpec.configure do |config| ...@@ -95,7 +95,7 @@ RSpec.configure do |config|
end end
config.around(:each, :nested_groups) do |example| config.around(:each, :nested_groups) do |example|
example.run if Gitlab::GroupHierarchy.supports_nested_groups? example.run if Group.supports_nested_groups?
end end
config.around(:each, :postgresql) do |example| config.around(:each, :postgresql) do |example|
......
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