2018-09-14 01:42:05 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2013-01-20 06:20:50 -05:00
|
|
|
class Admin::ProjectsController < Admin::ApplicationController
|
2017-12-05 09:03:16 -05:00
|
|
|
include MembersPresentation
|
|
|
|
|
2019-05-29 16:18:40 -04:00
|
|
|
before_action :project, only: [:show, :transfer, :repository_check, :destroy]
|
2015-04-16 08:03:37 -04:00
|
|
|
before_action :group, only: [:show, :transfer]
|
2011-10-08 17:36:38 -04:00
|
|
|
|
|
|
|
def index
|
2017-08-11 05:09:07 -04:00
|
|
|
params[:sort] ||= 'latest_activity_desc'
|
|
|
|
@sort = params[:sort]
|
|
|
|
@projects = Admin::ProjectsFinder.new(params: params, current_user: current_user).execute
|
2017-03-03 05:13:03 -05:00
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
format.html
|
|
|
|
format.json do
|
|
|
|
render json: {
|
2019-03-18 20:01:49 -04:00
|
|
|
html: view_to_html_string("admin/projects/_projects", projects: @projects)
|
2017-03-03 05:13:03 -05:00
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|
|
|
|
|
2018-08-27 11:31:01 -04:00
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2011-10-08 17:36:38 -04:00
|
|
|
def show
|
2014-06-02 14:25:01 -04:00
|
|
|
if @group
|
2017-12-05 09:03:16 -05:00
|
|
|
@group_members = present_members(
|
|
|
|
@group.members.order("access_level DESC").page(params[:group_members_page]))
|
2014-06-02 14:25:01 -04:00
|
|
|
end
|
|
|
|
|
2017-12-05 09:03:16 -05:00
|
|
|
@project_members = present_members(
|
|
|
|
@project.members.page(params[:project_members_page]))
|
|
|
|
@requesters = present_members(
|
|
|
|
AccessRequestsFinder.new(@project).execute(current_user))
|
2013-11-15 08:25:37 -05:00
|
|
|
end
|
2018-08-27 11:31:01 -04:00
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2013-11-15 08:25:37 -05:00
|
|
|
|
2019-05-29 16:18:40 -04: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
|
|
|
|
redirect_to admin_projects_path, status: 302, alert: ex.message
|
|
|
|
end
|
|
|
|
|
2018-08-27 11:31:01 -04:00
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2013-11-15 08:25:37 -05:00
|
|
|
def transfer
|
2015-07-02 08:31:25 -04:00
|
|
|
namespace = Namespace.find_by(id: params[:new_namespace_id])
|
|
|
|
::Projects::TransferService.new(@project, current_user, params.dup).execute(namespace)
|
2013-11-15 08:25:37 -05:00
|
|
|
|
2019-04-08 09:33:36 -04:00
|
|
|
@project.reset
|
2017-06-29 13:06:35 -04:00
|
|
|
redirect_to admin_project_path(@project)
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|
2018-08-27 11:31:01 -04:00
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2011-10-08 17:36:38 -04:00
|
|
|
|
2016-04-06 07:47:05 -04:00
|
|
|
def repository_check
|
2016-04-13 09:56:05 -04:00
|
|
|
RepositoryCheck::SingleRepositoryWorker.perform_async(@project.id)
|
2016-04-04 11:23:43 -04:00
|
|
|
|
|
|
|
redirect_to(
|
2017-06-29 13:06:35 -04:00
|
|
|
admin_project_path(@project),
|
2019-03-21 09:31:05 -04:00
|
|
|
notice: _('Repository check was triggered.')
|
2016-04-04 11:23:43 -04:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2012-11-23 15:25:28 -05:00
|
|
|
protected
|
|
|
|
|
|
|
|
def project
|
2017-02-02 18:43:19 -05:00
|
|
|
@project = Project.find_by_full_path(
|
2015-01-24 13:02:58 -05:00
|
|
|
[params[:namespace_id], '/', params[:id]].join('')
|
|
|
|
)
|
2012-11-23 15:25:28 -05:00
|
|
|
@project || render_404
|
|
|
|
end
|
2013-11-15 08:25:37 -05:00
|
|
|
|
|
|
|
def group
|
2014-10-19 17:20:55 -04:00
|
|
|
@group ||= @project.group
|
2013-11-15 08:25:37 -05:00
|
|
|
end
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|