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 @@ ...@@ -29,7 +29,10 @@
const $target = $(e.target); const $target = $(e.target);
if ($target.hasClass('btn-remove')) { 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 ...@@ -5,11 +5,9 @@ class Projects::ProjectMembersController < Projects::ApplicationController
before_action :authorize_admin_project_member!, except: [:index, :leave, :request_access] before_action :authorize_admin_project_member!, except: [:index, :leave, :request_access]
def index def index
@groups = @project.project_group_links.all @groups = @project.project_group_links
@project_members = @project.team.members.all @project_members = @project.team.members(can?(current_user, :admin_project, @project))
@project_members_size = @project_members.size @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? if params[:search].present?
@project_members = @project_members.search(params[:search]) @project_members = @project_members.search(params[:search])
...@@ -20,7 +18,6 @@ class Projects::ProjectMembersController < Projects::ApplicationController ...@@ -20,7 +18,6 @@ class Projects::ProjectMembersController < Projects::ApplicationController
@requesters = @project.requesters if can?(current_user, :admin_project, @project) @requesters = @project.requesters if can?(current_user, :admin_project, @project)
@project_member = @project.project_members.new @project_member = @project.project_members.new
@project_group_links = @project.project_group_links
end end
def create def create
......
...@@ -52,8 +52,8 @@ class ProjectTeam ...@@ -52,8 +52,8 @@ class ProjectTeam
ProjectMember.truncate_team(project) ProjectMember.truncate_team(project)
end end
def members def members(non_invite)
@members ||= fetch_members @members ||= fetch_members(nil, non_invite)
end end
alias_method :users, :members alias_method :users, :members
...@@ -197,7 +197,7 @@ class ProjectTeam ...@@ -197,7 +197,7 @@ class ProjectTeam
access.each { |key, value| access[key] = [value, capped_access_level].min } access.each { |key, value| access[key] = [value, capped_access_level].min }
end end
def fetch_members(level = nil) def fetch_members(level = nil, non_invite = false)
project_members = project.members project_members = project.members
group_members = group ? group.members : [] group_members = group ? group.members : []
invited_members = [] invited_members = []
...@@ -236,7 +236,7 @@ class ProjectTeam ...@@ -236,7 +236,7 @@ class ProjectTeam
end end
user_ids = project_members.pluck(:user_id) 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_ids.push(*group_members.pluck(:user_id)) if group
User.where(id: user_ids) User.where(id: user_ids)
......
...@@ -13,14 +13,15 @@ ...@@ -13,14 +13,15 @@
Expires in #{distance_of_time_in_words_to_now(group_link.expires_at)} Expires in #{distance_of_time_in_words_to_now(group_link.expires_at)}
.controls.member-controls .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 = 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}" = 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.append-right-10.clearable-input.member-form-control .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}" = 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 %i.clear-icon.js-clear-input
- if can?(current_user, action_member_permission(:admin, group), group)
= link_to namespace_project_group_link_path(@project.namespace, @project, group_link), = link_to namespace_project_group_link_path(@project.namespace, @project, group_link),
remote: true, remote: true,
method: :delete, method: :delete,
class: 'btn btn-remove' do class: 'btn btn-remove prepend-left-10' do
%span.visible-xs-block %span.visible-xs-block
Delete Delete
= icon('trash', class: 'hidden-xs') = icon('trash', class: 'hidden-xs')
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
- if user != current_user - if user != current_user
= form_for member, remote: true, html: { class: 'form-horizontal js-edit-member-form' } do |f| = 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) = 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) = 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 %i.clear-icon.js-clear-input
- else - else
...@@ -55,12 +55,12 @@ ...@@ -55,12 +55,12 @@
- if !user && can?(current_user, action_member_permission(:admin, member), member.source) - if !user && can?(current_user, action_member_permission(:admin, member), member.source)
= link_to 'Resend invite', polymorphic_path([:resend_invite, member]), = link_to 'Resend invite', polymorphic_path([:resend_invite, member]),
method: :post, method: :post,
class: 'btn' class: 'btn btn-default prepend-left-10'
- if member.request? && can?(current_user, action_member_permission(:update, member), member) - if member.request? && can?(current_user, action_member_permission(:update, member), member)
= link_to icon('check inverse'), polymorphic_path([:approve_access_request, member]), = link_to icon('check inverse'), polymorphic_path([:approve_access_request, member]),
method: :post, method: :post,
class: 'btn btn-success', class: 'btn btn-success prepend-left-10',
title: 'Grant access' title: 'Grant access'
- if can?(current_user, action_member_permission(:destroy, member), member) - if can?(current_user, action_member_permission(:destroy, member), member)
...@@ -68,13 +68,13 @@ ...@@ -68,13 +68,13 @@
= link_to icon('sign-out', text: 'Leave'), polymorphic_path([:leave, member.source, :members]), = link_to icon('sign-out', text: 'Leave'), polymorphic_path([:leave, member.source, :members]),
method: :delete, method: :delete,
data: { confirm: leave_confirmation_message(member.source) }, data: { confirm: leave_confirmation_message(member.source) },
class: 'btn btn-remove' class: 'btn btn-remove prepend-left-10'
- else - else
= link_to member, = link_to member,
remote: true, remote: true,
method: :delete, method: :delete,
data: { confirm: remove_member_message(member) }, data: { confirm: remove_member_message(member) },
class: 'btn btn-remove', class: 'btn btn-remove prepend-left-10',
title: remove_member_title(member) do title: remove_member_title(member) do
%span.visible-xs-block %span.visible-xs-block
Delete Delete
......
- if requesters.any? - if requesters.any?
.panel.panel-default .panel.panel-default
.panel-heading .panel-heading
Users requesting access to
%strong= membership_source.name %strong= membership_source.name
access requests
%span.badge= requesters.size %span.badge= requesters.size
%ul.content-list %ul.content-list
= render partial: 'shared/members/member', collection: requesters, as: :member = 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