debian-mirror-gitlab/app/controllers/admin/projects_controller.rb

89 lines
2.6 KiB
Ruby
Raw Normal View History

2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
2014-09-02 18:07:02 +05:30
class Admin::ProjectsController < Admin::ApplicationController
2018-03-17 18:26:18 +05:30
include MembersPresentation
2019-09-04 21:01:54 +05:30
before_action :project, only: [:show, :transfer, :repository_check, :destroy]
2015-09-11 14:41:01 +05:30
before_action :group, only: [:show, :transfer]
2014-09-02 18:07:02 +05:30
2021-01-03 14:25:43 +05:30
feature_category :projects, [:index, :show, :transfer, :destroy]
feature_category :source_code_management, [:repository_check]
2014-09-02 18:07:02 +05:30
def index
2018-03-17 18:26:18 +05:30
params[:sort] ||= 'latest_activity_desc'
@sort = params[:sort]
2020-04-22 19:07:51 +05:30
if params[:last_repository_check_failed].present? && params[:archived].nil?
params[:archived] = true
end
2018-03-17 18:26:18 +05:30
@projects = Admin::ProjectsFinder.new(params: params, current_user: current_user).execute
2017-08-17 22:00:37 +05:30
respond_to do |format|
format.html
format.json do
render json: {
2019-07-07 11:18:12 +05:30
html: view_to_html_string("admin/projects/_projects", projects: @projects)
2017-08-17 22:00:37 +05:30
}
end
end
2014-09-02 18:07:02 +05:30
end
2018-12-05 23:21:45 +05:30
# rubocop: disable CodeReuse/ActiveRecord
2014-09-02 18:07:02 +05:30
def show
if @group
2018-03-17 18:26:18 +05:30
@group_members = present_members(
@group.members.order("access_level DESC").page(params[:group_members_page]))
2014-09-02 18:07:02 +05:30
end
2018-03-17 18:26:18 +05:30
@project_members = present_members(
@project.members.page(params[:project_members_page]))
@requesters = present_members(
AccessRequestsFinder.new(@project).execute(current_user))
2014-09-02 18:07:02 +05:30
end
2018-12-05 23:21:45 +05:30
# rubocop: enable CodeReuse/ActiveRecord
2014-09-02 18:07:02 +05:30
2019-09-04 21:01:54 +05:30
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-12-26 22:10:19 +05:30
redirect_to admin_projects_path, status: :found, alert: ex.message
2019-09-04 21:01:54 +05:30
end
2018-12-05 23:21:45 +05:30
# rubocop: disable CodeReuse/ActiveRecord
2014-09-02 18:07:02 +05:30
def transfer
2015-09-11 14:41:01 +05:30
namespace = Namespace.find_by(id: params[:new_namespace_id])
::Projects::TransferService.new(@project, current_user, params.dup).execute(namespace)
2014-09-02 18:07:02 +05:30
2019-07-31 22:56:46 +05:30
@project.reset
2017-09-10 17:25:29 +05:30
redirect_to admin_project_path(@project)
2014-09-02 18:07:02 +05:30
end
2018-12-05 23:21:45 +05:30
# rubocop: enable CodeReuse/ActiveRecord
2014-09-02 18:07:02 +05:30
2016-06-02 11:05:42 +05:30
def repository_check
2020-03-13 15:44:24 +05:30
RepositoryCheck::SingleRepositoryWorker.perform_async(@project.id) # rubocop:disable CodeReuse/Worker
2016-06-02 11:05:42 +05:30
redirect_to(
2017-09-10 17:25:29 +05:30
admin_project_path(@project),
2019-07-07 11:18:12 +05:30
notice: _('Repository check was triggered.')
2016-06-02 11:05:42 +05:30
)
end
2014-09-02 18:07:02 +05:30
protected
def project
2017-08-17 22:00:37 +05:30
@project = Project.find_by_full_path(
2015-04-26 12:48:37 +05:30
[params[:namespace_id], '/', params[:id]].join('')
)
2014-09-02 18:07:02 +05:30
@project || render_404
end
def group
2015-04-26 12:48:37 +05:30
@group ||= @project.group
2014-09-02 18:07:02 +05:30
end
end
2019-12-04 20:38:33 +05:30
Admin::ProjectsController.prepend_if_ee('EE::Admin::ProjectsController')