Class: Projects::ForksController

Inherits:
ApplicationController show all
Includes:
ContinueParams
Defined in:
app/controllers/projects/forks_controller.rb

Instance Method Summary collapse

Methods included from ContinueParams

#continue_params

Methods inherited from ApplicationController

#redirect_back_or_default

Methods included from PageLayoutHelper

#blank_container, #container_class, #fluid_layout, #header_title, #nav, #page_card_attributes, #page_card_meta_tags, #page_description, #page_image, #page_title, #sidebar

Methods included from GitlabRoutingHelper

#activity_project_path, #edit_project_path, #edit_project_url, #issue_path, #issue_url, #merge_request_path, #merge_request_url, #milestone_path, #project_builds_path, #project_commits_path, #project_files_path, #project_path, #project_pipelines_path, #project_snippet_url, #project_url, #runner_path, #runners_path, #toggle_subscription_path

Methods included from Gitlab::GonHelper

#add_gon_variables

Methods included from Gitlab::CurrentSettings

#current_application_settings, #fake_application_settings

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Projects::ApplicationController

Instance Method Details

#createObject


36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'app/controllers/projects/forks_controller.rb', line 36

def create
  namespace = Namespace.find(params[:namespace_key])

  @forked_project = namespace.projects.find_by(path: project.path)
  @forked_project = nil unless @forked_project && @forked_project.forked_from_project == project

  @forked_project ||= ::Projects::ForkService.new(project, current_user, namespace: namespace).execute

  if @forked_project.saved? && @forked_project.forked?
    if @forked_project.import_in_progress?
      redirect_to namespace_project_import_path(@forked_project.namespace, @forked_project, continue: continue_params)
    else
      if continue_params
        redirect_to continue_params[:to], notice: continue_params[:notice]
      else
        redirect_to namespace_project_path(@forked_project.namespace, @forked_project), notice: "The project '#{@forked_project.name}' was successfully forked."
      end
    end
  else
    render :error
  end
end

#indexObject


8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/projects/forks_controller.rb', line 8

def index
  base_query = project.forks.includes(:creator)

  @forks               = base_query.merge(ProjectsFinder.new.execute(current_user))
  @total_forks_count   = base_query.size
  @private_forks_count = @total_forks_count - @forks.size
  @public_forks_count  = @total_forks_count - @private_forks_count

  @sort  = params[:sort] || 'id_desc'
  @forks = @forks.search(params[:filter_projects]) if params[:filter_projects].present?
  @forks = @forks.order_by(@sort).page(params[:page])

  respond_to do |format|
    format.html

    format.json do
      render json: {
        html: view_to_html_string("projects/forks/_projects", projects: @forks)
      }
    end
  end
end

#newObject


31
32
33
34
# File 'app/controllers/projects/forks_controller.rb', line 31

def new
  @namespaces = current_user.manageable_namespaces
  @namespaces.delete(@project.namespace)
end