Commit cb0f94b1 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch '213554-unify-jira-import-feature-flag-checks' into 'master'

Unify the jira issues import feature flag check

See merge request gitlab-org/gitlab!29182
parents a7e111f3 a60cae41
......@@ -40,7 +40,7 @@ module Projects
private
def jira_import_enabled?
return if Feature.enabled?(:jira_issue_import, @project)
return if @project.jira_issues_import_feature_flag_enabled?
redirect_to project_issues_path(@project)
end
......
......@@ -14,7 +14,7 @@ module Resolvers
end
def authorized_resource?(project)
return false unless Feature.enabled?(:jira_issue_import, project)
return false unless project.jira_issues_import_feature_flag_enabled?
Ability.allowed?(context[:current_user], :admin_project, project)
end
......
......@@ -786,6 +786,10 @@ class Project < ApplicationRecord
Feature.enabled?(:context_commits, default_enabled: true)
end
def jira_issues_import_feature_flag_enabled?
Feature.enabled?(:jira_issue_import, self)
end
def team
@team ||= ProjectTeam.new(self)
end
......@@ -968,7 +972,7 @@ class Project < ApplicationRecord
end
def jira_import?
import_type == 'jira' && latest_jira_import.present? && Feature.enabled?(:jira_issue_import, self)
import_type == 'jira' && latest_jira_import.present? && jira_issues_import_feature_flag_enabled?
end
def gitlab_project_import?
......
......@@ -44,7 +44,7 @@ module JiraImport
end
def validate
return build_error_response(_('Jira import feature is disabled.')) unless Feature.enabled?(:jira_issue_import, project)
return build_error_response(_('Jira import feature is disabled.')) unless project.jira_issues_import_feature_flag_enabled?
return build_error_response(_('You do not have permissions to run the import.')) unless user.can?(:admin_project, project)
return build_error_response(_('Jira integration not configured.')) unless project.jira_service&.active?
return build_error_response(_('Unable to find Jira project to import data from.')) if jira_project_key.blank?
......
- type = local_assigns.fetch(:type, :icon)
- if Feature.enabled?(:jira_issue_import, @project)
- if @project.jira_issues_import_feature_flag_enabled?
.dropdown.btn-group
%button.btn.rounded-right.text-center{ class: ('has-tooltip' if type == :icon), title: (_('Import issues') if type == :icon),
data: { toggle: 'dropdown' }, 'aria-label' => _('Import issues'), 'aria-haspopup' => 'true', 'aria-expanded' => 'false' }
......
......@@ -26,7 +26,7 @@ module Gitlab
def can_import?(project)
return false unless project
return false if Feature.disabled?(:jira_issue_import, project)
return false unless project.jira_issues_import_feature_flag_enabled?
project.latest_jira_import&.started?
end
......
......@@ -25,7 +25,7 @@ module Gitlab
def start_import
return false unless project
return false if Feature.disabled?(:jira_issue_import, project)
return false unless project.jira_issues_import_feature_flag_enabled?
return true if start(project.latest_jira_import)
Gitlab::Import::Logger.info(
......
......@@ -6,7 +6,7 @@ module Gitlab
attr_reader :project, :client, :formatter, :jira_project_key
def initialize(project)
raise Projects::ImportService::Error, _('Jira import feature is disabled.') unless Feature.enabled?(:jira_issue_import, project)
raise Projects::ImportService::Error, _('Jira import feature is disabled.') unless project.jira_issues_import_feature_flag_enabled?
raise Projects::ImportService::Error, _('Jira integration not configured.') unless project.jira_service&.active?
@jira_project_key = project.latest_jira_import&.jira_project_key
......
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