Commit 9df72e08 authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch '205513-create-subgroup-without-project-permission' into 'master'

create subgroup without create project permission

See merge request gitlab-org/gitlab!28309
parents 9d870883 53121710
- can_create_subgroups = can?(current_user, :create_subgroup, @group) - can_create_subgroups = can?(current_user, :create_subgroup, @group)
- can_create_projects = can?(current_user, :create_projects, @group)
- emails_disabled = @group.emails_disabled? - emails_disabled = @group.emails_disabled?
.group-home-panel .group-home-panel
...@@ -23,10 +24,9 @@ ...@@ -23,10 +24,9 @@
- if current_user - if current_user
.group-buttons .group-buttons
= render 'shared/notifications/new_button', notification_setting: @notification_setting, btn_class: 'btn', emails_disabled: emails_disabled = render 'shared/notifications/new_button', notification_setting: @notification_setting, btn_class: 'btn', emails_disabled: emails_disabled
- if can? current_user, :create_projects, @group
- new_project_label = _("New project") - new_project_label = _("New project")
- new_subgroup_label = _("New subgroup") - new_subgroup_label = _("New subgroup")
- if can_create_subgroups - if can_create_projects and can_create_subgroups
.btn-group.new-project-subgroup.droplab-dropdown.home-panel-action-button.prepend-top-default.js-new-project-subgroup.qa-new-project-or-subgroup-dropdown{ 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.home-panel-action-button.prepend-top-default.js-new-project-subgroup.qa-new-project-or-subgroup-dropdown{ 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.qa-new-in-group-button{ type: "button", value: new_project_label, data: { action: "new-project" } } %input.btn.btn-success.dropdown-primary.js-new-group-child.qa-new-in-group-button{ type: "button", value: new_project_label, data: { action: "new-project" } }
%button.btn.btn-success.dropdown-toggle.js-dropdown-toggle.qa-new-project-or-subgroup-dropdown-toggle{ type: "button", data: { "dropdown-trigger" => "#new-project-or-subgroup-dropdown", 'display' => 'static' } } %button.btn.btn-success.dropdown-toggle.js-dropdown-toggle.qa-new-project-or-subgroup-dropdown-toggle{ type: "button", data: { "dropdown-trigger" => "#new-project-or-subgroup-dropdown", 'display' => 'static' } }
...@@ -47,8 +47,10 @@ ...@@ -47,8 +47,10 @@
.description .description
%strong= new_subgroup_label %strong= new_subgroup_label
%span= s_("GroupsTree|Create a subgroup in this group.") %span= s_("GroupsTree|Create a subgroup in this group.")
- else - elsif can_create_projects
= link_to new_project_label, new_project_path(namespace_id: @group.id), class: "btn btn-success prepend-top-default" = link_to new_project_label, new_project_path(namespace_id: @group.id), class: "btn btn-success prepend-top-default"
- elsif can_create_subgroups
= link_to new_subgroup_label, new_group_path(parent_id: @group.id), class: "btn btn-success prepend-top-default"
- if @group.description.present? - if @group.description.present?
.group-home-desc.mt-1 .group-home-desc.mt-1
......
---
title: Always display new subgroup button when permission is granted
merge_request: 28309
author: Mattias Michaux
type: fixed
...@@ -262,6 +262,42 @@ describe 'Group' do ...@@ -262,6 +262,42 @@ describe 'Group' do
end end
end end
describe 'new subgroup / project button' do
let(:group) { create(:group, project_creation_level: Gitlab::Access::NO_ONE_PROJECT_ACCESS, subgroup_creation_level: Gitlab::Access::OWNER_SUBGROUP_ACCESS) }
it 'new subgroup button is displayed without project creation permission' do
visit group_path(group)
page.within '.group-buttons' do
expect(page).to have_link('New subgroup')
end
end
it 'new subgroup button is displayed together with new project button when having project creation permission' do
group.update!(project_creation_level: Gitlab::Access::MAINTAINER_PROJECT_ACCESS)
visit group_path(group)
page.within '.group-buttons' do
expect(page).to have_css("li[data-text='New subgroup']", visible: false)
expect(page).to have_css("li[data-text='New project']", visible: false)
end
end
it 'new project button is displayed without subgroup creation permission' do
group.update!(project_creation_level: Gitlab::Access::MAINTAINER_PROJECT_ACCESS)
user = create(:user)
group.add_maintainer(user)
sign_out(:user)
sign_in(user)
visit group_path(group)
page.within '.group-buttons' do
expect(page).to have_link('New project')
end
end
end
def remove_with_confirm(button_text, confirm_with) def remove_with_confirm(button_text, confirm_with)
click_button button_text click_button button_text
fill_in 'confirm_name_input', with: confirm_with fill_in 'confirm_name_input', with: confirm_with
......
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