gitlab-org--gitlab-foss/app/controllers/admin/projects_controller.rb

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

93 lines
2.7 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
class Admin::ProjectsController < Admin::ApplicationController
include MembersPresentation
before_action :project, only: [:show, :transfer, :repository_check, :destroy]
before_action :group, only: [:show, :transfer]
2011-10-08 17:36:38 -04:00
feature_category :projects, [:index, :show, :transfer, :destroy]
feature_category :source_code_management, [:repository_check]
2011-10-08 17:36:38 -04:00
def index
params[:sort] ||= 'latest_activity_desc'
@sort = params[:sort]
if params[:last_repository_check_failed].present? && params[:archived].nil?
params[:archived] = true
end
@projects = Admin::ProjectsFinder.new(params: params, current_user: current_user).execute
respond_to do |format|
format.html
format.json do
render json: {
html: view_to_html_string("admin/projects/_projects", projects: @projects)
}
end
end
2011-10-08 17:36:38 -04:00
end
# rubocop: disable CodeReuse/ActiveRecord
2011-10-08 17:36:38 -04:00
def show
if @group
@group_members = present_members(
@group.members.order("access_level DESC").page(params[:group_members_page]))
end
@project_members = present_members(
@project.members.page(params[:project_members_page]))
@requesters = present_members(
AccessRequestsFinder.new(@project).execute(current_user))
end
# rubocop: enable CodeReuse/ActiveRecord
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
redirect_to admin_projects_path, status: :found, alert: ex.message
end
# rubocop: disable CodeReuse/ActiveRecord
def transfer
namespace = Namespace.find_by(id: params[:new_namespace_id])
::Projects::TransferService.new(@project, current_user, params.dup).execute(namespace)
if @project.errors[:new_namespace].present?
flash[:alert] = @project.errors[:new_namespace].first
end
@project.reset
redirect_to admin_project_path(@project)
2011-10-08 17:36:38 -04:00
end
# rubocop: enable CodeReuse/ActiveRecord
2011-10-08 17:36:38 -04:00
2016-04-06 07:47:05 -04:00
def repository_check
RepositoryCheck::SingleRepositoryWorker.perform_async(@project.id) # rubocop:disable CodeReuse/Worker
2016-04-04 11:23:43 -04:00
redirect_to(
admin_project_path(@project),
notice: _('Repository check was triggered.')
2016-04-04 11:23:43 -04:00
)
end
protected
def project
@project = Project.find_by_full_path(
[params[:namespace_id], '/', params[:id]].join('')
)
@project || render_404
end
def group
@group ||= @project.group
end
2011-10-08 17:36:38 -04:00
end
Admin::ProjectsController.prepend_mod_with('Admin::ProjectsController')