Commit c8e7b39d authored by Lin Jen-Shin's avatar Lin Jen-Shin

Merge branch 'ee-reduce-imports_controller-diff-with-ce' into 'master'

Reduce diff with CE in Projects::ImportsController

See merge request gitlab-org/gitlab-ee!8894
parents 0ae053a1 17b65a0e
......@@ -2,7 +2,6 @@
class Projects::ImportsController < Projects::ApplicationController
include ContinueParams
include SafeMirrorParams
# Authorize
before_action :authorize_admin_project!
......@@ -14,7 +13,7 @@ class Projects::ImportsController < Projects::ApplicationController
end
def create
if @project.update(safe_import_params)
if @project.update(import_params)
@project.import_state.reload.schedule
end
......@@ -67,13 +66,13 @@ class Projects::ImportsController < Projects::ApplicationController
end
end
def import_params
params.require(:project).permit(:import_url, :mirror, :mirror_user_id)
def import_params_attributes
[:import_url]
end
def safe_import_params
return import_params if valid_mirror_user?(import_params)
import_params.merge(mirror_user_id: current_user.id)
def import_params
params.require(:project).permit(import_params_attributes)
end
end
Projects::ImportsController.prepend(::EE::Projects::ImportsController)
# frozen_string_literal: true
module EE
module Projects
module ImportsController
extend ActiveSupport::Concern
extend ::Gitlab::Utils::Override
prepended do
include SafeMirrorParams
end
private
override :import_params_attributes
def import_params_attributes
super + [:mirror, :mirror_user_id]
end
override :import_params
def import_params
base_import_params = super
return base_import_params if valid_mirror_user?(base_import_params)
base_import_params.merge(mirror_user_id: current_user.id)
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment