2018-09-14 05:42:05 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2013-01-20 11:20:50 +00:00
|
|
|
class Admin::ProjectsController < Admin::ApplicationController
|
2017-12-05 14:03:16 +00:00
|
|
|
include MembersPresentation
|
|
|
|
|
2019-05-29 20:18:40 +00:00
|
|
|
before_action :project, only: [:show, :transfer, :repository_check, :destroy]
|
2015-04-16 12:03:37 +00:00
|
|
|
before_action :group, only: [:show, :transfer]
|
2011-10-08 21:36:38 +00:00
|
|
|
|
2020-10-05 21:08:47 +00:00
|
|
|
feature_category :projects, [:index, :show, :transfer, :destroy]
|
|
|
|
feature_category :source_code_management, [:repository_check]
|
|
|
|
|
2011-10-08 21:36:38 +00:00
|
|
|
def index
|
2017-08-11 09:09:07 +00:00
|
|
|
params[:sort] ||= 'latest_activity_desc'
|
|
|
|
@sort = params[:sort]
|
2020-03-27 18:07:48 +00:00
|
|
|
|
|
|
|
if params[:last_repository_check_failed].present? && params[:archived].nil?
|
|
|
|
params[:archived] = true
|
|
|
|
end
|
|
|
|
|
2017-08-11 09:09:07 +00:00
|
|
|
@projects = Admin::ProjectsFinder.new(params: params, current_user: current_user).execute
|
2017-03-03 10:13:03 +00:00
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
format.html
|
|
|
|
format.json do
|
|
|
|
render json: {
|
2019-03-19 00:01:49 +00:00
|
|
|
html: view_to_html_string("admin/projects/_projects", projects: @projects)
|
2017-03-03 10:13:03 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
2011-10-08 21:36:38 +00:00
|
|
|
end
|
|
|
|
|
2018-08-27 15:31:01 +00:00
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2011-10-08 21:36:38 +00:00
|
|
|
def show
|
2014-06-02 18:25:01 +00:00
|
|
|
if @group
|
2017-12-05 14:03:16 +00:00
|
|
|
@group_members = present_members(
|
|
|
|
@group.members.order("access_level DESC").page(params[:group_members_page]))
|
2014-06-02 18:25:01 +00:00
|
|
|
end
|
|
|
|
|
2017-12-05 14:03:16 +00:00
|
|
|
@project_members = present_members(
|
|
|
|
@project.members.page(params[:project_members_page]))
|
|
|
|
@requesters = present_members(
|
|
|
|
AccessRequestsFinder.new(@project).execute(current_user))
|
2013-11-15 13:25:37 +00:00
|
|
|
end
|
2018-08-27 15:31:01 +00:00
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2013-11-15 13:25:37 +00:00
|
|
|
|
2019-05-29 20:18:40 +00:00
|
|
|
def destroy
|
|
|
|
::Projects::DestroyService.new(@project, current_user, {}).async_execute
|
|
|
|
flash[:notice] = _("Project '%{project_name}' is in the process of being deleted.") % { project_name: @project.full_name }
|
|
|
|
|
|
|
|
redirect_to admin_projects_path, status: :found
|
|
|
|
rescue Projects::DestroyService::DestroyError => ex
|
2019-11-17 12:06:19 +00:00
|
|
|
redirect_to admin_projects_path, status: :found, alert: ex.message
|
2019-05-29 20:18:40 +00:00
|
|
|
end
|
|
|
|
|
2018-08-27 15:31:01 +00:00
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2013-11-15 13:25:37 +00:00
|
|
|
def transfer
|
2015-07-02 12:31:25 +00:00
|
|
|
namespace = Namespace.find_by(id: params[:new_namespace_id])
|
|
|
|
::Projects::TransferService.new(@project, current_user, params.dup).execute(namespace)
|
2013-11-15 13:25:37 +00:00
|
|
|
|
2021-01-14 15:10:46 +00:00
|
|
|
if @project.errors[:new_namespace].present?
|
|
|
|
flash[:alert] = @project.errors[:new_namespace].first
|
|
|
|
end
|
|
|
|
|
2019-04-08 13:33:36 +00:00
|
|
|
@project.reset
|
2017-06-29 17:06:35 +00:00
|
|
|
redirect_to admin_project_path(@project)
|
2011-10-08 21:36:38 +00:00
|
|
|
end
|
2018-08-27 15:31:01 +00:00
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2011-10-08 21:36:38 +00:00
|
|
|
|
2016-04-06 11:47:05 +00:00
|
|
|
def repository_check
|
2020-02-14 21:09:08 +00:00
|
|
|
RepositoryCheck::SingleRepositoryWorker.perform_async(@project.id) # rubocop:disable CodeReuse/Worker
|
2016-04-04 15:23:43 +00:00
|
|
|
|
|
|
|
redirect_to(
|
2017-06-29 17:06:35 +00:00
|
|
|
admin_project_path(@project),
|
2019-03-21 13:31:05 +00:00
|
|
|
notice: _('Repository check was triggered.')
|
2016-04-04 15:23:43 +00:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2012-11-23 20:25:28 +00:00
|
|
|
protected
|
|
|
|
|
|
|
|
def project
|
2017-02-02 23:43:19 +00:00
|
|
|
@project = Project.find_by_full_path(
|
2015-01-24 18:02:58 +00:00
|
|
|
[params[:namespace_id], '/', params[:id]].join('')
|
|
|
|
)
|
2012-11-23 20:25:28 +00:00
|
|
|
@project || render_404
|
|
|
|
end
|
2013-11-15 13:25:37 +00:00
|
|
|
|
|
|
|
def group
|
2014-10-19 21:20:55 +00:00
|
|
|
@group ||= @project.group
|
2013-11-15 13:25:37 +00:00
|
|
|
end
|
2011-10-08 21:36:38 +00:00
|
|
|
end
|
2019-09-13 13:26:31 +00:00
|
|
|
|
|
|
|
Admin::ProjectsController.prepend_if_ee('EE::Admin::ProjectsController')
|