Commit 4e88ca12 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Hide "New subgroup" links when subgroups are not supported

parent 17dccc35
- @no_container = true - @no_container = true
- breadcrumb_title "Details" - breadcrumb_title "Details"
- can_create_subgroups = can?(current_user, :create_subgroup, @group)
= content_for :meta_tags do = content_for :meta_tags do
= auto_discovery_link_tag(:atom, group_url(@group, rss_url_options), title: "#{@group.name} activity") = auto_discovery_link_tag(:atom, group_url(@group, rss_url_options), title: "#{@group.name} activity")
...@@ -16,8 +17,9 @@ ...@@ -16,8 +17,9 @@
- new_subgroup_label = _("New subgroup") - new_subgroup_label = _("New subgroup")
.btn-group.new-project-subgroup.droplab-dropdown.js-new-project-subgroup{ data: { project_path: new_project_path(namespace_id: @group.id), subgroup_path: new_group_path(parent_id: @group.id) } } .btn-group.new-project-subgroup.droplab-dropdown.js-new-project-subgroup{ data: { project_path: new_project_path(namespace_id: @group.id), subgroup_path: new_group_path(parent_id: @group.id) } }
%input.btn.btn-success.dropdown-primary.js-new-group-child{ type: "button", value: new_project_label, data: { action: "new-project" } } %input.btn.btn-success.dropdown-primary.js-new-group-child{ type: "button", value: new_project_label, data: { action: "new-project" } }
%button.btn.btn-success.dropdown-toggle.js-dropdown-toggle{ type: "button", data: { "dropdown-trigger" => "#new-project-or-subgroup-dropdown" } } - if can_create_subgroups
= icon("caret-down", class: "dropdown-btn-icon") %button.btn.btn-success.dropdown-toggle.js-dropdown-toggle{ type: "button", data: { "dropdown-trigger" => "#new-project-or-subgroup-dropdown" } }
= icon("caret-down", class: "dropdown-btn-icon")
%ul#new-project-or-subgroup-dropdown.dropdown-menu.dropdown-menu-align-right{ data: { dropdown: true } } %ul#new-project-or-subgroup-dropdown.dropdown-menu.dropdown-menu-align-right{ data: { dropdown: true } }
%li.droplab-item-selected{ role: "button", data: { value: "new-project", text: new_project_label } } %li.droplab-item-selected{ role: "button", data: { value: "new-project", text: new_project_label } }
.menu-item .menu-item
...@@ -26,14 +28,15 @@ ...@@ -26,14 +28,15 @@
.description .description
%strong= new_project_label %strong= new_project_label
%span= s_("GroupsTree|Create project under this group.") %span= s_("GroupsTree|Create project under this group.")
%li.divider.droplap-item-ignore - if can_create_subgroups
%li{ role: "button", data: { value: "new-subgroup", text: new_subgroup_label } } %li.divider.droplap-item-ignore
.menu-item %li{ role: "button", data: { value: "new-subgroup", text: new_subgroup_label } }
.icon-container .menu-item
= icon("check", class: "list-item-checkmark") .icon-container
.description = icon("check", class: "list-item-checkmark")
%strong= new_subgroup_label .description
%span= s_("GroupsTree|Create a subgroup under this group.") %strong= new_subgroup_label
%span= s_("GroupsTree|Create a subgroup under this group.")
- if params[:filter].blank? && @children.empty? - if params[:filter].blank? && @children.empty?
= render "shared/groups/empty_state" = render "shared/groups/empty_state"
......
...@@ -24,4 +24,34 @@ feature 'Group show page' do ...@@ -24,4 +24,34 @@ feature 'Group show page' do
it_behaves_like "an autodiscoverable RSS feed without an RSS token" it_behaves_like "an autodiscoverable RSS feed without an RSS token"
end end
context 'subgroup support' do
let(:user) { create(:user) }
before do
group.add_owner(user)
sign_in(user)
end
context 'when subgroups are supported', :js do
before do
allow(Group).to receive(:supports_nested_groups?) { true }
visit path
end
it 'allows creating subgroups' do
expect(page).to have_css("li[data-text='New subgroup']", visible: false)
end
end
context 'when subgroups are not supported' do
before do
allow(Group).to receive(:supports_nested_groups?) { false }
visit path
end
it 'allows creating subgroups' do
expect(page).not_to have_selector("li[data-text='New subgroup']", visible: false)
end
end
end
end 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