2018-12-05 23:21:45 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
class Projects::ProjectMembersController < Projects::ApplicationController
|
2016-06-16 23:09:34 +05:30
|
|
|
include MembershipActions
|
2018-03-17 18:26:18 +05:30
|
|
|
include MembersPresentation
|
2017-08-17 22:00:37 +05:30
|
|
|
include SortingHelper
|
2016-06-16 23:09:34 +05:30
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
# Authorize
|
2016-06-16 23:09:34 +05:30
|
|
|
before_action :authorize_admin_project_member!, except: [:index, :leave, :request_access]
|
2015-04-26 12:48:37 +05:30
|
|
|
|
2018-12-05 23:21:45 +05:30
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2015-04-26 12:48:37 +05:30
|
|
|
def index
|
2017-09-10 17:25:29 +05:30
|
|
|
@sort = params[:sort].presence || sort_value_name
|
|
|
|
@group_links = @project.project_group_links
|
|
|
|
|
|
|
|
@skip_groups = @group_links.pluck(:group_id)
|
|
|
|
@skip_groups << @project.namespace_id unless @project.personal?
|
|
|
|
@skip_groups += @project.group.ancestors.pluck(:id) if @project.group
|
|
|
|
|
|
|
|
@project_members = MembersFinder.new(@project, current_user).execute
|
|
|
|
|
|
|
|
if params[:search].present?
|
|
|
|
@project_members = @project_members.joins(:user).merge(User.search(params[:search]))
|
|
|
|
@group_links = @group_links.where(group_id: @project.invited_groups.search(params[:search]).select(:id))
|
|
|
|
end
|
|
|
|
|
2018-05-09 12:01:36 +05:30
|
|
|
@project_members = present_members(@project_members.sort_by_attribute(@sort).page(params[:page]))
|
2018-03-17 18:26:18 +05:30
|
|
|
@requesters = present_members(AccessRequestsFinder.new(@project).execute(current_user))
|
2017-09-10 17:25:29 +05:30
|
|
|
@project_member = @project.project_members.new
|
2015-04-26 12:48:37 +05:30
|
|
|
end
|
2018-12-05 23:21:45 +05:30
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2015-04-26 12:48:37 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
def import
|
|
|
|
@projects = current_user.authorized_projects.order_id_desc
|
|
|
|
end
|
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
def apply_import
|
2016-06-02 11:05:42 +05:30
|
|
|
source_project = Project.find(params[:source_project_id])
|
|
|
|
|
|
|
|
if can?(current_user, :read_project_member, source_project)
|
|
|
|
status = @project.team.import(source_project, current_user)
|
|
|
|
notice = status ? "Successfully imported" : "Import failed"
|
|
|
|
else
|
|
|
|
return render_404
|
|
|
|
end
|
2015-04-26 12:48:37 +05:30
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
redirect_to(project_project_members_path(project),
|
2015-04-26 12:48:37 +05:30
|
|
|
notice: notice)
|
|
|
|
end
|
|
|
|
|
2016-06-16 23:09:34 +05:30
|
|
|
# MembershipActions concern
|
|
|
|
alias_method :membershipable, :project
|
2015-04-26 12:48:37 +05:30
|
|
|
end
|