summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2019-01-07 23:15:53 +0000
committerDouwe Maan <douwe@gitlab.com>2019-01-07 23:15:53 +0000
commitcfa7108210490704a8110ee97a26de9ae4d9adaf (patch)
tree4c66dc55df99405b8aba8ed9fa0e3d1fd34eb30e /app/controllers
parent420fb032fc9760395c96bafd3f6600950c2125f4 (diff)
parentf54290de751e365be0928c66bb75fd106bb7aa88 (diff)
downloadgitlab-ce-cfa7108210490704a8110ee97a26de9ae4d9adaf.tar.gz
Merge branch '49231-import-issues-csv' into 'master'
Import issues from CSV Closes #49231 See merge request gitlab-org/gitlab-ce!23532
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/concerns/uploads_actions.rb6
-rw-r--r--app/controllers/projects/issues_controller.rb18
2 files changed, 20 insertions, 4 deletions
diff --git a/app/controllers/concerns/uploads_actions.rb b/app/controllers/concerns/uploads_actions.rb
index 0eea0cdd50f..c114e16edf8 100644
--- a/app/controllers/concerns/uploads_actions.rb
+++ b/app/controllers/concerns/uploads_actions.rb
@@ -7,12 +7,12 @@ module UploadsActions
UPLOAD_MOUNTS = %w(avatar attachment file logo header_logo favicon).freeze
def create
- link_to_file = UploadService.new(model, params[:file], uploader_class).execute
+ uploader = UploadService.new(model, params[:file], uploader_class).execute
respond_to do |format|
- if link_to_file
+ if uploader
format.json do
- render json: { link: link_to_file }
+ render json: { link: uploader.to_h }
end
else
format.json do
diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb
index 5ed46fc0545..21688e54481 100644
--- a/app/controllers/projects/issues_controller.rb
+++ b/app/controllers/projects/issues_controller.rb
@@ -10,7 +10,7 @@ class Projects::IssuesController < Projects::ApplicationController
include SpammableActions
def self.issue_except_actions
- %i[index calendar new create bulk_update]
+ %i[index calendar new create bulk_update import_csv]
end
def self.set_issuables_index_only_actions
@@ -37,6 +37,8 @@ class Projects::IssuesController < Projects::ApplicationController
# Allow create a new branch and empty WIP merge request from current issue
before_action :authorize_create_merge_request_from!, only: [:create_merge_request]
+ before_action :authorize_import_issues!, only: [:import_csv]
+
before_action :set_suggested_issues_feature_flags, only: [:new]
respond_to :html
@@ -175,6 +177,20 @@ class Projects::IssuesController < Projects::ApplicationController
end
end
+ def import_csv
+ return render_404 unless Feature.enabled?(:issues_import_csv)
+
+ if uploader = UploadService.new(project, params[:file]).execute
+ ImportIssuesCsvWorker.perform_async(current_user.id, project.id, uploader.upload.id)
+
+ flash[:notice] = _("Your issues are being imported. Once finished, you'll get a confirmation email.")
+ else
+ flash[:alert] = _("File upload error.")
+ end
+
+ redirect_to project_issues_path(project)
+ end
+
protected
# rubocop: disable CodeReuse/ActiveRecord