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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

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
2023-03-04 22:38:38 +05:30
params[:archived] = true if params[:last_repository_check_failed].present? && params[:archived].nil?
2020-04-22 19:07:51 +05:30
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
2023-03-17 16:20:25 +05:30
flash[:notice] = format(_("Project '%{project_name}' is in the process of being deleted."), project_name: @project.full_name)
2019-09-04 21:01:54 +05:30
redirect_to admin_projects_path, status: :found
2022-08-27 11:52:29 +05:30
rescue Projects::DestroyService::DestroyError => e
redirect_to admin_projects_path, status: :found, alert: e.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
2023-03-04 22:38:38 +05:30
flash[:alert] = @project.errors[:new_namespace].first if @project.errors[:new_namespace].present?
2021-03-08 18:12:59 +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
2021-06-08 01:23:25 +05:30
Admin::ProjectsController.prepend_mod_with('Admin::ProjectsController')