Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/projects/import/jira_controller.rb')
-rw-r--r--app/controllers/projects/import/jira_controller.rb54
1 files changed, 12 insertions, 42 deletions
diff --git a/app/controllers/projects/import/jira_controller.rb b/app/controllers/projects/import/jira_controller.rb
index 711e23dc3ce..976ac7df976 100644
--- a/app/controllers/projects/import/jira_controller.rb
+++ b/app/controllers/projects/import/jira_controller.rb
@@ -4,59 +4,29 @@ module Projects
module Import
class JiraController < Projects::ApplicationController
before_action :authenticate_user!
- before_action :check_issues_available!
before_action :authorize_read_project!
- before_action :jira_import_enabled?
- before_action :jira_integration_configured?
- before_action :authorize_admin_project!, only: [:import]
+ before_action :validate_jira_import_settings!
def show
- jira_service = @project.jira_service
-
- if jira_service.present? && !@project.latest_jira_import&.in_progress? && current_user&.can?(:admin_project, @project)
- jira_client = jira_service.client
- jira_projects = jira_client.Project.all
-
- if jira_projects.present?
- @jira_projects = jira_projects.map { |p| ["#{p.name} (#{p.key})", p.key] }
- else
- flash[:alert] = 'No projects have been returned from Jira. Please check your Jira configuration.'
- end
- end
-
- unless Feature.enabled?(:jira_issue_import_vue, @project, default_enabled: true)
- flash[:notice] = _("Import %{status}") % { status: @project.jira_import_status } unless @project.latest_jira_import&.initial?
- end
- end
-
- def import
- 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
- flash[:alert] = 'No Jira project key has been provided.'
- end
-
- redirect_to project_import_jira_path(@project)
end
private
- def jira_import_enabled?
- return if @project.jira_issues_import_feature_flag_enabled?
+ def validate_jira_import_settings!
+ Gitlab::JiraImport.validate_project_settings!(@project, user: current_user, configuration_check: false)
+ true
+ rescue Projects::ImportService::Error => e
+ flash[:notice] = e.message
redirect_to project_issues_path(@project)
- end
- def jira_integration_configured?
- return if Feature.enabled?(:jira_issue_import_vue, @project, default_enabled: true)
- return if @project.jira_service
+ false
+ end
- flash[:notice] = _("Configure the Jira integration first on your project's %{strong_start} Settings > Integrations > Jira%{strong_end} page." %
- { strong_start: '<strong>'.html_safe, strong_end: '</strong>'.html_safe })
- redirect_to project_issues_path(@project)
+ def jira_service
+ strong_memoize(:jira_service) do
+ @project.jira_service
+ end
end
def jira_import_params