Commit e477ad44 authored by Phil Hughes's avatar Phil Hughes

Removes row from dom when deleting

Fixed spacing with buttons
Disables group form when user doesnt have correct permissions
parent 15a3111a
......@@ -29,7 +29,10 @@
const $target = $(e.target);
if ($target.hasClass('btn-remove')) {
$target.closest('.member').fadeOut();
$target.closest('.member')
.fadeOut(function () {
$(this).remove();
});
}
}
......
......@@ -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
......
......@@ -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)
......
......@@ -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')
......@@ -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
......
- 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
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