BigW Consortium Gitlab

projects_controller.rb 1.61 KB
Newer Older
1
class Admin::ProjectsController < Admin::ApplicationController
2 3
  include MembersPresentation

4
  before_action :project, only: [:show, :transfer, :repository_check]
5
  before_action :group, only: [:show, :transfer]
gitlabhq committed
6 7

  def index
8 9 10
    params[:sort] ||= 'latest_activity_desc'
    @sort = params[:sort]
    @projects = Admin::ProjectsFinder.new(params: params, current_user: current_user).execute
11 12 13 14 15 16 17 18 19

    respond_to do |format|
      format.html
      format.json do
        render json: {
          html: view_to_html_string("admin/projects/_projects", locals: { projects: @projects })
        }
      end
    end
gitlabhq committed
20 21 22
  end

  def show
23
    if @group
24 25
      @group_members = present_members(
        @group.members.order("access_level DESC").page(params[:group_members_page]))
26 27
    end

28 29 30 31
    @project_members = present_members(
      @project.members.page(params[:project_members_page]))
    @requesters = present_members(
      AccessRequestsFinder.new(@project).execute(current_user))
32 33 34
  end

  def transfer
35 36
    namespace = Namespace.find_by(id: params[:new_namespace_id])
    ::Projects::TransferService.new(@project, current_user, params.dup).execute(namespace)
37

Vinnie Okada committed
38
    @project.reload
39
    redirect_to admin_project_path(@project)
gitlabhq committed
40 41
  end

42
  def repository_check
43
    RepositoryCheck::SingleRepositoryWorker.perform_async(@project.id)
Jacob Vosmaer committed
44 45

    redirect_to(
46
      admin_project_path(@project),
Jacob Vosmaer committed
47
      notice: 'Repository check was triggered.'
Jacob Vosmaer committed
48 49 50
    )
  end

51 52 53
  protected

  def project
54
    @project = Project.find_by_full_path(
Vinnie Okada committed
55 56
      [params[:namespace_id], '/', params[:id]].join('')
    )
57 58
    @project || render_404
  end
59 60

  def group
61
    @group ||= @project.group
62
  end
gitlabhq committed
63
end