Commit 224187ff authored by Douwe Maan's avatar Douwe Maan

Move group members index from `/members` to `/group_members`.

parent 75aff0f7
...@@ -73,7 +73,7 @@ class Dispatcher ...@@ -73,7 +73,7 @@ class Dispatcher
new Activities() new Activities()
shortcut_handler = new ShortcutsNavigation() shortcut_handler = new ShortcutsNavigation()
new ProjectsList() new ProjectsList()
when 'groups:members' when 'groups:group_members:index'
new GroupMembers() new GroupMembers()
new UsersSelect() new UsersSelect()
when 'groups:new', 'groups:edit', 'admin:groups:edit' when 'groups:new', 'groups:edit', 'admin:groups:edit'
......
...@@ -2,9 +2,27 @@ class Groups::ApplicationController < ApplicationController ...@@ -2,9 +2,27 @@ class Groups::ApplicationController < ApplicationController
private private
def authorize_read_group!
unless @group and can?(current_user, :read_group, @group)
if current_user.nil?
return authenticate_user!
else
return render_404
end
end
end
def authorize_admin_group! def authorize_admin_group!
unless can?(current_user, :manage_group, group) unless can?(current_user, :manage_group, group)
return render_404 return render_404
end end
end end
def determine_layout
if current_user
'group'
else
'public_group'
end
end
end end
class Groups::GroupMembersController < Groups::ApplicationController class Groups::GroupMembersController < Groups::ApplicationController
skip_before_filter :authenticate_user!, only: [:index]
before_filter :group before_filter :group
# Authorize # Authorize
before_filter :authorize_admin_group! before_filter :authorize_read_group!
before_filter :authorize_admin_group!, except: [:index, :leave]
layout 'group' layout :determine_layout
def index
@project = @group.projects.find(params[:project_id]) if params[:project_id]
@members = @group.group_members
if params[:search].present?
users = @group.users.search(params[:search]).to_a
@members = @members.where(user_id: users)
end
@members = @members.order('access_level DESC').page(params[:page]).per(50)
@group_member = GroupMember.new
end
def create def create
@group.add_users(params[:user_ids].split(','), params[:access_level]) @group.add_users(params[:user_ids].split(','), params[:access_level])
redirect_to members_group_path(@group), notice: 'Users were successfully added.' redirect_to group_group_members_path(@group), notice: 'Users were successfully added.'
end end
def update def update
...@@ -23,7 +38,7 @@ class Groups::GroupMembersController < Groups::ApplicationController ...@@ -23,7 +38,7 @@ class Groups::GroupMembersController < Groups::ApplicationController
if can?(current_user, :destroy_group_member, @group_member) # May fail if last owner. if can?(current_user, :destroy_group_member, @group_member) # May fail if last owner.
@group_member.destroy @group_member.destroy
respond_to do |format| respond_to do |format|
format.html { redirect_to members_group_path(@group), notice: 'User was successfully removed from group.' } format.html { redirect_to group_group_members_path(@group), notice: 'User was successfully removed from group.' }
format.js { render nothing: true } format.js { render nothing: true }
end end
else else
......
class GroupsController < Groups::ApplicationController class GroupsController < Groups::ApplicationController
skip_before_filter :authenticate_user!, only: [:show, :issues, :members, :merge_requests] skip_before_filter :authenticate_user!, only: [:show, :issues, :merge_requests]
respond_to :html respond_to :html
before_filter :group, except: [:new, :create] before_filter :group, except: [:new, :create]
...@@ -67,19 +67,6 @@ class GroupsController < Groups::ApplicationController ...@@ -67,19 +67,6 @@ class GroupsController < Groups::ApplicationController
end end
end end
def members
@project = group.projects.find(params[:project_id]) if params[:project_id]
@members = group.group_members
if params[:search].present?
users = group.users.search(params[:search]).to_a
@members = @members.where(user_id: users)
end
@members = @members.order('access_level DESC').page(params[:page]).per(50)
@users_group = GroupMember.new
end
def edit def edit
end end
......
= form_for @users_group, url: group_group_members_path(@group), html: { class: 'form-horizontal users-group-form' } do |f| = form_for @group_member, url: group_group_members_path(@group), html: { class: 'form-horizontal users-group-form' } do |f|
.form-group .form-group
= f.label :user_ids, "People", class: 'control-label' = f.label :user_ids, "People", class: 'control-label'
.col-sm-10= users_select_tag(:user_ids, multiple: true, class: 'input-large') .col-sm-10= users_select_tag(:user_ids, multiple: true, class: 'input-large')
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
.form-group .form-group
= f.label :access_level, "Group Access", class: 'control-label' = f.label :access_level, "Group Access", class: 'control-label'
.col-sm-10 .col-sm-10
= select_tag :access_level, options_for_select(GroupMember.access_level_roles, @users_group.access_level), class: "project-access-select select2" = select_tag :access_level, options_for_select(GroupMember.access_level_roles, @group_member.access_level), class: "project-access-select select2"
.help-block .help-block
Read more about role permissions Read more about role permissions
%strong= link_to "here", help_page_path("permissions", "permissions"), class: "vlink" %strong= link_to "here", help_page_path("permissions", "permissions"), class: "vlink"
......
- show_roles = should_user_see_group_roles?(current_user, @group) - show_roles = should_user_see_group_roles?(current_user, @group)
%h3.page-title %h3.page-title
Group members Group members
- if show_roles - if show_roles
...@@ -10,7 +11,7 @@ ...@@ -10,7 +11,7 @@
%hr %hr
.clearfix.js-toggle-container .clearfix.js-toggle-container
= form_tag members_group_path(@group), method: :get, class: 'form-inline member-search-form' do = form_tag group_group_members_path(@group), method: :get, class: 'form-inline member-search-form' do
.form-group .form-group
= search_field_tag :search, params[:search], { placeholder: 'Find existing member by name', class: 'form-control search-text-input input-mn-300' } = search_field_tag :search, params[:search], { placeholder: 'Find existing member by name', class: 'form-control search-text-input input-mn-300' }
= button_tag 'Search', class: 'btn' = button_tag 'Search', class: 'btn'
...@@ -33,6 +34,7 @@ ...@@ -33,6 +34,7 @@
%ul.well-list %ul.well-list
- @members.each do |member| - @members.each do |member|
= render 'groups/group_members/group_member', member: member, show_roles: show_roles, show_controls: true = render 'groups/group_members/group_member', member: member, show_roles: show_roles, show_controls: true
= paginate @members, theme: 'gitlab' = paginate @members, theme: 'gitlab'
:coffeescript :coffeescript
......
...@@ -24,8 +24,8 @@ ...@@ -24,8 +24,8 @@
Merge Requests Merge Requests
- if current_user - if current_user
%span.count= MergeRequest.opened.of_group(@group).count %span.count= MergeRequest.opened.of_group(@group).count
= nav_link(path: 'groups#members') do = nav_link(controller: [:group_members]) do
= link_to members_group_path(@group), title: 'Members' do = link_to group_group_members_path(@group), title: 'Members' do
%i.fa.fa-users %i.fa.fa-users
%span %span
Members Members
......
...@@ -236,12 +236,13 @@ Gitlab::Application.routes.draw do ...@@ -236,12 +236,13 @@ Gitlab::Application.routes.draw do
member do member do
get :issues get :issues
get :merge_requests get :merge_requests
get :members
get :projects get :projects
end end
scope module: :groups do scope module: :groups do
resources :group_members, only: [:create, :update, :destroy] resources :group_members, only: [:index, :create, :update, :destroy] do
end
resource :avatar, only: [:destroy] resource :avatar, only: [:destroy]
resources :milestones, only: [:index, :show, :update] resources :milestones, only: [:index, :show, :update]
end end
......
...@@ -35,7 +35,7 @@ class Spinach::Features::ExploreGroups < Spinach::FeatureSteps ...@@ -35,7 +35,7 @@ class Spinach::Features::ExploreGroups < Spinach::FeatureSteps
end end
step 'I visit group "TestGroup" members page' do step 'I visit group "TestGroup" members page' do
visit members_group_path(Group.find_by(name: "TestGroup")) visit group_group_members_path(Group.find_by(name: "TestGroup"))
end end
step 'I should not see project "Enterprise" items' do step 'I should not see project "Enterprise" items' do
......
...@@ -32,7 +32,7 @@ module SharedPaths ...@@ -32,7 +32,7 @@ module SharedPaths
end end
step 'I visit group "Owned" members page' do step 'I visit group "Owned" members page' do
visit members_group_path(Group.find_by(name:"Owned")) visit group_group_members_path(Group.find_by(name:"Owned"))
end end
step 'I visit group "Owned" settings page' do step 'I visit group "Owned" settings page' do
...@@ -52,7 +52,7 @@ module SharedPaths ...@@ -52,7 +52,7 @@ module SharedPaths
end end
step 'I visit group "Guest" members page' do step 'I visit group "Guest" members page' do
visit members_group_path(Group.find_by(name:"Guest")) visit group_group_members_path(Group.find_by(name:"Guest"))
end end
step 'I visit group "Guest" settings page' do step 'I visit group "Guest" settings page' do
......
...@@ -59,8 +59,8 @@ describe "Group access", feature: true do ...@@ -59,8 +59,8 @@ describe "Group access", feature: true do
it { is_expected.to be_denied_for :visitor } it { is_expected.to be_denied_for :visitor }
end end
describe "GET /groups/:path/members" do describe "GET /groups/:path/group_members" do
subject { members_group_path(group) } subject { group_group_members_path(group) }
it { is_expected.to be_allowed_for owner } it { is_expected.to be_allowed_for owner }
it { is_expected.to be_allowed_for master } it { is_expected.to be_allowed_for master }
......
...@@ -55,8 +55,8 @@ describe "Group with internal project access", feature: true do ...@@ -55,8 +55,8 @@ describe "Group with internal project access", feature: true do
it { is_expected.to be_denied_for :visitor } it { is_expected.to be_denied_for :visitor }
end end
describe "GET /groups/:path/members" do describe "GET /groups/:path/group_members" do
subject { members_group_path(group) } subject { group_group_members_path(group) }
it { is_expected.to be_allowed_for owner } it { is_expected.to be_allowed_for owner }
it { is_expected.to be_allowed_for master } it { is_expected.to be_allowed_for master }
......
...@@ -56,8 +56,8 @@ describe "Group access", feature: true do ...@@ -56,8 +56,8 @@ describe "Group access", feature: true do
it { is_expected.to be_allowed_for :visitor } it { is_expected.to be_allowed_for :visitor }
end end
describe "GET /groups/:path/members" do describe "GET /groups/:path/group_members" do
subject { members_group_path(group) } subject { group_group_members_path(group) }
it { is_expected.to be_allowed_for owner } it { is_expected.to be_allowed_for owner }
it { is_expected.to be_allowed_for master } it { is_expected.to be_allowed_for master }
......
...@@ -55,8 +55,8 @@ describe "Group with public project access", feature: true do ...@@ -55,8 +55,8 @@ describe "Group with public project access", feature: true do
it { is_expected.to be_allowed_for :visitor } it { is_expected.to be_allowed_for :visitor }
end end
describe "GET /groups/:path/members" do describe "GET /groups/:path/group_members" do
subject { members_group_path(group) } subject { group_group_members_path(group) }
it { is_expected.to be_allowed_for owner } it { is_expected.to be_allowed_for owner }
it { is_expected.to be_allowed_for master } it { is_expected.to be_allowed_for master }
......
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