summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2016-09-02 09:25:53 +0100
committerPhil Hughes <me@iamphill.com>2016-09-13 08:44:59 +0100
commite477ad44565dbe69e3f0200f4f4f7bebbd48cb15 (patch)
tree9300603b45ad3168be44abf045f59a1ac1fbfd29 /app
parent15a3111a6663894d952103e7395f2f56408f88ce (diff)
downloadgitlab-ce-e477ad44565dbe69e3f0200f4f4f7bebbd48cb15.tar.gz
Removes row from dom when deleting
Fixed spacing with buttons Disables group form when user doesnt have correct permissions
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/project_members.js.es65
-rw-r--r--app/controllers/projects/project_members_controller.rb7
-rw-r--r--app/models/project_team.rb8
-rw-r--r--app/views/shared/members/_group.html.haml21
-rw-r--r--app/views/shared/members/_member.html.haml10
-rw-r--r--app/views/shared/members/_requests.html.haml2
6 files changed, 27 insertions, 26 deletions
diff --git a/app/assets/javascripts/project_members.js.es6 b/app/assets/javascripts/project_members.js.es6
index f525bdbb1ea..56bc98d1076 100644
--- a/app/assets/javascripts/project_members.js.es6
+++ b/app/assets/javascripts/project_members.js.es6
@@ -29,7 +29,10 @@
const $target = $(e.target);
if ($target.hasClass('btn-remove')) {
- $target.closest('.member').fadeOut();
+ $target.closest('.member')
+ .fadeOut(function () {
+ $(this).remove();
+ });
}
}
diff --git a/app/controllers/projects/project_members_controller.rb b/app/controllers/projects/project_members_controller.rb
index abb92938211..cd31653698c 100644
--- a/app/controllers/projects/project_members_controller.rb
+++ b/app/controllers/projects/project_members_controller.rb
@@ -5,11 +5,9 @@ class Projects::ProjectMembersController < Projects::ApplicationController
before_action :authorize_admin_project_member!, except: [:index, :leave, :request_access]
def index
- @groups = @project.project_group_links.all
- @project_members = @project.team.members.all
+ @groups = @project.project_group_links
+ @project_members = @project.team.members(can?(current_user, :admin_project, @project))
@project_members_size = @project_members.size
- @group_members = @project.group.group_members
- @project_members = @project_members.non_invite unless can?(current_user, :admin_project, @project)
if params[:search].present?
@project_members = @project_members.search(params[:search])
@@ -20,7 +18,6 @@ class Projects::ProjectMembersController < Projects::ApplicationController
@requesters = @project.requesters if can?(current_user, :admin_project, @project)
@project_member = @project.project_members.new
- @project_group_links = @project.project_group_links
end
def create
diff --git a/app/models/project_team.rb b/app/models/project_team.rb
index ab6ea2aae36..57925a0861a 100644
--- a/app/models/project_team.rb
+++ b/app/models/project_team.rb
@@ -52,8 +52,8 @@ class ProjectTeam
ProjectMember.truncate_team(project)
end
- def members
- @members ||= fetch_members
+ def members(non_invite)
+ @members ||= fetch_members(nil, non_invite)
end
alias_method :users, :members
@@ -197,7 +197,7 @@ class ProjectTeam
access.each { |key, value| access[key] = [value, capped_access_level].min }
end
- def fetch_members(level = nil)
+ def fetch_members(level = nil, non_invite = false)
project_members = project.members
group_members = group ? group.members : []
invited_members = []
@@ -236,7 +236,7 @@ class ProjectTeam
end
user_ids = project_members.pluck(:user_id)
- user_ids.push(*invited_members.map(&:user_id)) if invited_members.any?
+ user_ids.push(*invited_members.map(&:user_id)) if invited_members.any? && !non_invite
user_ids.push(*group_members.pluck(:user_id)) if group
User.where(id: user_ids)
diff --git a/app/views/shared/members/_group.html.haml b/app/views/shared/members/_group.html.haml
index e545aec80a9..19b58ef20ae 100644
--- a/app/views/shared/members/_group.html.haml
+++ b/app/views/shared/members/_group.html.haml
@@ -13,14 +13,15 @@
Expires in #{distance_of_time_in_words_to_now(group_link.expires_at)}
.controls.member-controls
= form_tag namespace_project_group_link_path(@project.namespace, @project, group_link), method: :put, remote: true, class: 'form-horizontal js-edit-member-form' do
- = select_tag 'group_link[group_access]', options_for_select(ProjectGroupLink.access_options, group_link.group_access), class: 'form-control member-form-control append-right-5 js-member-update-control', id: "member_access_level_#{group.id}"
- .prepend-left-5.append-right-10.clearable-input.member-form-control
- = text_field_tag 'group_link[expires_at]', group_link.expires_at, class: 'form-control js-access-expiration-date js-member-update-control', placeholder: 'Expiration date', id: "member_expires_at_#{group.id}"
+ = select_tag 'group_link[group_access]', options_for_select(ProjectGroupLink.access_options, group_link.group_access), class: 'form-control member-form-control append-right-5 js-member-update-control', id: "member_access_level_#{group.id}", disabled: !can?(current_user, action_member_permission(:admin, group), group)
+ .prepend-left-5.clearable-input.member-form-control
+ = text_field_tag 'group_link[expires_at]', group_link.expires_at, class: 'form-control js-access-expiration-date js-member-update-control', placeholder: 'Expiration date', id: "member_expires_at_#{group.id}", disabled: !can?(current_user, action_member_permission(:admin, group), group)
%i.clear-icon.js-clear-input
- = link_to namespace_project_group_link_path(@project.namespace, @project, group_link),
- remote: true,
- method: :delete,
- class: 'btn btn-remove' do
- %span.visible-xs-block
- Delete
- = icon('trash', class: 'hidden-xs')
+ - if can?(current_user, action_member_permission(:admin, group), group)
+ = link_to namespace_project_group_link_path(@project.namespace, @project, group_link),
+ remote: true,
+ method: :delete,
+ class: 'btn btn-remove prepend-left-10' do
+ %span.visible-xs-block
+ Delete
+ = icon('trash', class: 'hidden-xs')
diff --git a/app/views/shared/members/_member.html.haml b/app/views/shared/members/_member.html.haml
index ab4f1f1382b..2d4853eef92 100644
--- a/app/views/shared/members/_member.html.haml
+++ b/app/views/shared/members/_member.html.haml
@@ -47,7 +47,7 @@
- if user != current_user
= form_for member, remote: true, html: { class: 'form-horizontal js-edit-member-form' } do |f|
= f.select :access_level, options_for_select(member.class.access_level_roles, member.access_level), {}, class: 'form-control member-form-control append-right-5 js-member-update-control', id: "member_access_level_#{member.id}", disabled: !can?(current_user, action_member_permission(:update, member), member)
- .prepend-left-5.append-right-10.clearable-input.member-form-control
+ .prepend-left-5.clearable-input.member-form-control
= f.text_field :expires_at, class: 'form-control js-access-expiration-date js-member-update-control', placeholder: 'Expiration date', id: "member_expires_at_#{member.id}", disabled: !can?(current_user, action_member_permission(:update, member), member)
%i.clear-icon.js-clear-input
- else
@@ -55,12 +55,12 @@
- if !user && can?(current_user, action_member_permission(:admin, member), member.source)
= link_to 'Resend invite', polymorphic_path([:resend_invite, member]),
method: :post,
- class: 'btn'
+ class: 'btn btn-default prepend-left-10'
- if member.request? && can?(current_user, action_member_permission(:update, member), member)
= link_to icon('check inverse'), polymorphic_path([:approve_access_request, member]),
method: :post,
- class: 'btn btn-success',
+ class: 'btn btn-success prepend-left-10',
title: 'Grant access'
- if can?(current_user, action_member_permission(:destroy, member), member)
@@ -68,13 +68,13 @@
= link_to icon('sign-out', text: 'Leave'), polymorphic_path([:leave, member.source, :members]),
method: :delete,
data: { confirm: leave_confirmation_message(member.source) },
- class: 'btn btn-remove'
+ class: 'btn btn-remove prepend-left-10'
- else
= link_to member,
remote: true,
method: :delete,
data: { confirm: remove_member_message(member) },
- class: 'btn btn-remove',
+ class: 'btn btn-remove prepend-left-10',
title: remove_member_title(member) do
%span.visible-xs-block
Delete
diff --git a/app/views/shared/members/_requests.html.haml b/app/views/shared/members/_requests.html.haml
index 40b39e850b0..10050adfda5 100644
--- a/app/views/shared/members/_requests.html.haml
+++ b/app/views/shared/members/_requests.html.haml
@@ -1,8 +1,8 @@
- if requesters.any?
.panel.panel-default
.panel-heading
+ Users requesting access to
%strong= membership_source.name
- access requests
%span.badge= requesters.size
%ul.content-list
= render partial: 'shared/members/member', collection: requesters, as: :member