Commit a60cae41 authored by Alexandru Croitor's avatar Alexandru Croitor

Unify the jira issues import feature flag check

Add a project method to check if jira issues import feature flag is
enabled. This will help change the feature flag default value later on.
parent f42cb701
...@@ -39,7 +39,7 @@ module Projects ...@@ -39,7 +39,7 @@ module Projects
private private
def jira_import_enabled? 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) redirect_to project_issues_path(@project)
end end
......
...@@ -14,7 +14,7 @@ module Resolvers ...@@ -14,7 +14,7 @@ module Resolvers
end end
def authorized_resource?(project) 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) Ability.allowed?(context[:current_user], :admin_project, project)
end end
......
...@@ -786,6 +786,10 @@ class Project < ApplicationRecord ...@@ -786,6 +786,10 @@ class Project < ApplicationRecord
Feature.enabled?(:context_commits, default_enabled: true) Feature.enabled?(:context_commits, default_enabled: true)
end end
def jira_issues_import_feature_flag_enabled?
Feature.enabled?(:jira_issue_import, self)
end
def team def team
@team ||= ProjectTeam.new(self) @team ||= ProjectTeam.new(self)
end end
...@@ -968,7 +972,7 @@ class Project < ApplicationRecord ...@@ -968,7 +972,7 @@ class Project < ApplicationRecord
end end
def jira_import? 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 end
def gitlab_project_import? def gitlab_project_import?
......
...@@ -44,7 +44,7 @@ module JiraImport ...@@ -44,7 +44,7 @@ module JiraImport
end end
def validate 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(_('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(_('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? return build_error_response(_('Unable to find Jira project to import data from.')) if jira_project_key.blank?
......
- type = local_assigns.fetch(:type, :icon) - type = local_assigns.fetch(:type, :icon)
- if Feature.enabled?(:jira_issue_import, @project) - if @project.jira_issues_import_feature_flag_enabled?
.dropdown.btn-group .dropdown.btn-group
%button.btn.rounded-right.text-center{ class: ('has-tooltip' if type == :icon), title: (_('Import issues') if type == :icon), %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' } data: { toggle: 'dropdown' }, 'aria-label' => _('Import issues'), 'aria-haspopup' => 'true', 'aria-expanded' => 'false' }
......
...@@ -26,7 +26,7 @@ module Gitlab ...@@ -26,7 +26,7 @@ module Gitlab
def can_import?(project) def can_import?(project)
return false unless 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? project.latest_jira_import&.started?
end end
......
...@@ -25,7 +25,7 @@ module Gitlab ...@@ -25,7 +25,7 @@ module Gitlab
def start_import def start_import
return false unless project 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) return true if start(project.latest_jira_import)
Gitlab::Import::Logger.info( Gitlab::Import::Logger.info(
......
...@@ -6,7 +6,7 @@ module Gitlab ...@@ -6,7 +6,7 @@ module Gitlab
attr_reader :project, :client, :formatter, :jira_project_key attr_reader :project, :client, :formatter, :jira_project_key
def initialize(project) 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? raise Projects::ImportService::Error, _('Jira integration not configured.') unless project.jira_service&.active?
@jira_project_key = project.latest_jira_import&.jira_project_key @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