debian-mirror-gitlab/app/controllers/projects/project_members_controller.rb

93 lines
2.3 KiB
Ruby
Raw Normal View History

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
include MembershipActions
2018-03-17 18:26:18 +05:30
include MembersPresentation
2017-08-17 22:00:37 +05:30
include SortingHelper
2015-04-26 12:48:37 +05:30
# Authorize
before_action :authorize_admin_project_member!, except: [:index, :leave, :request_access]
2015-04-26 12:48:37 +05:30
2021-01-03 14:25:43 +05:30
feature_category :authentication_and_authorization
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
2020-03-13 15:44:24 +05:30
2022-04-04 11:22:00 +05:30
@skip_groups = @project.related_group_ids
2020-03-13 15:44:24 +05:30
2017-09-10 17:25:29 +05:30
@group_links = @project.project_group_links
2021-03-08 18:12:59 +05:30
@group_links = @group_links.search(params[:search_groups]) if params[:search_groups].present?
2017-09-10 17:25:29 +05:30
2021-10-27 15:23:28 +05:30
if can?(current_user, :admin_project_member, @project)
2021-11-18 22:05:49 +05:30
@invited_members = present_members(invited_members)
2021-03-08 18:12:59 +05:30
@requesters = present_members(AccessRequestsFinder.new(@project).execute(current_user))
end
2017-09-10 17:25:29 +05:30
2021-11-18 22:05:49 +05:30
@project_members = present_members(non_invited_members.page(params[:page]))
2017-09-10 17:25:29 +05:30
@project_member = @project.project_members.new
2015-04-26 12:48:37 +05:30
end
2018-03-17 18:26:18 +05:30
def import
2021-09-30 23:02:18 +05:30
@projects = Project.visible_to_user_and_access_level(current_user, Gitlab::Access::MAINTAINER).order_id_desc
2018-03-17 18:26:18 +05:30
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])
2021-09-30 23:02:18 +05:30
if can?(current_user, :admin_project_member, source_project)
2016-06-02 11:05:42 +05:30
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
2020-05-24 23:13:21 +05:30
redirect_to(project_project_members_path(project), notice: notice)
2015-04-26 12:48:37 +05:30
end
# MembershipActions concern
alias_method :membershipable, :project
2020-05-24 23:13:21 +05:30
private
2021-11-18 22:05:49 +05:30
def members
@members ||= MembersFinder
.new(@project, current_user, params: filter_params)
.execute(include_relations: requested_relations)
end
def invited_members
members.invite.with_invited_user_state
end
def non_invited_members
members.non_invite
end
2020-05-24 23:13:21 +05:30
def filter_params
params.permit(:search).merge(sort: @sort)
end
2021-01-03 14:25:43 +05:30
def membershipable_members
project.members
end
2021-09-04 01:27:46 +05:30
def plain_source_type
'project'
end
def source_type
_("project")
end
def members_page_url
project_project_members_path(project)
end
def root_params_key
:project_member
end
2015-04-26 12:48:37 +05:30
end
2019-12-04 20:38:33 +05:30
2021-06-08 01:23:25 +05:30
Projects::ProjectMembersController.prepend_mod_with('Projects::ProjectMembersController')