blob: 6cdd1c0bc8cf20c22de261eb1ac9f76d198047e0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# frozen_string_literal: true
class Projects::ImportsController < Projects::ApplicationController
include ContinueParams
include ImportUrlParams
# Authorize
before_action :authorize_admin_project!, except: :show
before_action :require_namespace_project_creation_permission, only: :show
before_action :require_no_repo, except: :show
before_action :redirect_if_progress, except: :show
before_action :redirect_if_no_import, only: :show
feature_category :importers
def new
end
def create
if @project.update(import_params)
@project.import_state.reset.schedule
end
redirect_to project_import_path(@project)
end
def show
if @project.import_finished?
if continue_params[:to]
redirect_to continue_params[:to], notice: continue_params[:notice]
else
redirect_to project_path(@project), notice: finished_notice
end
elsif @project.import_failed?
redirect_to new_project_import_path(@project)
else
flash.now[:notice] = continue_params[:notice_now]
end
end
private
def finished_notice
if @project.forked?
_('The project was successfully forked.')
else
_('The project was successfully imported.')
end
end
def require_no_repo
if @project.repository_exists?
redirect_to project_path(@project)
end
end
def require_namespace_project_creation_permission
render_404 unless current_user.can?(:admin_project, @project) || current_user.can?(:create_projects, @project.namespace)
end
def redirect_if_progress
if @project.import_in_progress?
redirect_to project_import_path(@project)
end
end
def redirect_if_no_import
if @project.repository_exists? && @project.no_import?
redirect_to project_path(@project)
end
end
def import_params_attributes
[]
end
def import_params
params.require(:project)
.permit(import_params_attributes)
.merge(import_url_params)
end
end
Projects::ImportsController.prepend_if_ee('EE::Projects::ImportsController')
|