Merge branch 'dz-nested-group-misc' into 'master'
Miscellaneous improvements to the nested groups feature See merge request !8308
This commit is contained in:
commit
23fc1f666c
6 changed files with 62 additions and 4 deletions
|
@ -42,6 +42,8 @@ class GroupsController < Groups::ApplicationController
|
|||
@notification_setting = current_user.notification_settings_for(group)
|
||||
end
|
||||
|
||||
@nested_groups = group.children
|
||||
|
||||
setup_projects
|
||||
|
||||
respond_to do |format|
|
||||
|
|
|
@ -12,6 +12,13 @@ module Groups
|
|||
return @group
|
||||
end
|
||||
|
||||
if @group.parent && !can?(current_user, :admin_group, @group.parent)
|
||||
@group.parent = nil
|
||||
@group.errors.add(:parent_id, 'manage access required to create subgroup')
|
||||
|
||||
return @group
|
||||
end
|
||||
|
||||
@group.name ||= @group.path.dup
|
||||
@group.save
|
||||
@group.add_owner(current_user)
|
||||
|
|
|
@ -32,6 +32,10 @@
|
|||
%li
|
||||
= link_to "#shared", 'data-toggle' => 'tab' do
|
||||
Shared Projects
|
||||
- if @nested_groups.present?
|
||||
%li
|
||||
= link_to "#groups", 'data-toggle' => 'tab' do
|
||||
Subgroups
|
||||
.nav-controls
|
||||
= form_tag request.path, method: :get, class: 'project-filter-form', id: 'project-filter-form' do |f|
|
||||
= search_field_tag :filter_projects, nil, placeholder: 'Filter by name', class: 'projects-list-filter form-control', spellcheck: false
|
||||
|
@ -47,3 +51,8 @@
|
|||
- if @shared_projects.present?
|
||||
.tab-pane#shared
|
||||
= render "shared_projects", projects: @shared_projects
|
||||
|
||||
- if @nested_groups.present?
|
||||
.tab-pane#groups
|
||||
%ul.content-list
|
||||
= render partial: 'shared/groups/group', collection: @nested_groups
|
||||
|
|
4
changelogs/unreleased/dz-nested-group-misc.yml
Normal file
4
changelogs/unreleased/dz-nested-group-misc.yml
Normal file
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
title: Show nested groups tab on group page
|
||||
merge_request: 8308
|
||||
author:
|
|
@ -107,4 +107,17 @@ feature 'Group', feature: true do
|
|||
expect(page).to have_css('.group-home-desc a[rel]')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'group page with nested groups', js: true do
|
||||
let!(:group) { create(:group) }
|
||||
let!(:nested_group) { create(:group, parent: group) }
|
||||
let!(:path) { group_path(group) }
|
||||
|
||||
it 'has nested groups tab with nested groups inside' do
|
||||
visit path
|
||||
click_link 'Subgroups'
|
||||
|
||||
expect(page).to have_content(nested_group.full_name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Groups::CreateService, services: true do
|
||||
let!(:user) { create(:user) }
|
||||
describe Groups::CreateService, '#execute', services: true do
|
||||
let!(:user) { create(:user) }
|
||||
let!(:group_params) { { path: "group_path", visibility_level: Gitlab::VisibilityLevel::PUBLIC } }
|
||||
|
||||
describe "execute" do
|
||||
let!(:service) { described_class.new(user, group_params ) }
|
||||
describe 'visibility level restrictions' do
|
||||
let!(:service) { described_class.new(user, group_params) }
|
||||
|
||||
subject { service.execute }
|
||||
|
||||
context "create groups without restricted visibility level" do
|
||||
|
@ -14,7 +15,29 @@ describe Groups::CreateService, services: true do
|
|||
|
||||
context "cannot create group with restricted visibility level" do
|
||||
before { allow_any_instance_of(ApplicationSetting).to receive(:restricted_visibility_levels).and_return([Gitlab::VisibilityLevel::PUBLIC]) }
|
||||
|
||||
it { is_expected.not_to be_persisted }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'creating subgroup' do
|
||||
let!(:group) { create(:group) }
|
||||
let!(:service) { described_class.new(user, group_params.merge(parent_id: group.id)) }
|
||||
|
||||
subject { service.execute }
|
||||
|
||||
context 'as group owner' do
|
||||
before { group.add_owner(user) }
|
||||
|
||||
it { is_expected.to be_persisted }
|
||||
end
|
||||
|
||||
context 'as guest' do
|
||||
it 'does not save group and returns an error' do
|
||||
is_expected.not_to be_persisted
|
||||
expect(subject.errors[:parent_id].first).to eq('manage access required to create subgroup')
|
||||
expect(subject.parent_id).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue