2020-03-13 08:09:22 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Projects
|
|
|
|
module Import
|
|
|
|
class JiraController < Projects::ApplicationController
|
2020-04-14 08:09:26 -04:00
|
|
|
before_action :authenticate_user!
|
|
|
|
before_action :check_issues_available!
|
|
|
|
before_action :authorize_read_project!
|
|
|
|
before_action :authorize_admin_project!, only: [:import]
|
2020-03-13 08:09:22 -04:00
|
|
|
|
|
|
|
def show
|
|
|
|
end
|
|
|
|
|
|
|
|
def import
|
2020-04-06 20:09:33 -04:00
|
|
|
jira_project_key = jira_import_params[:jira_project_key]
|
|
|
|
|
|
|
|
if jira_project_key.present?
|
|
|
|
response = ::JiraImport::StartImportService.new(current_user, @project, jira_project_key).execute
|
|
|
|
flash[:notice] = response.message if response.message.present?
|
|
|
|
else
|
2020-04-21 11:21:10 -04:00
|
|
|
flash[:alert] = 'No Jira project key has been provided.'
|
2020-04-06 20:09:33 -04:00
|
|
|
end
|
2020-03-13 08:09:22 -04:00
|
|
|
|
|
|
|
redirect_to project_import_jira_path(@project)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def jira_import_params
|
|
|
|
params.permit(:jira_project_key)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|