Commit 103a1bb0 authored by Marin Jankovski's avatar Marin Jankovski

Use service settings instead of config file settings to present issues.

parent 737f6516
......@@ -16,7 +16,7 @@ module IssuesHelper
def url_for_project_issues(project = @project)
return '' if project.nil?
if project.used_default_issues_tracker? || !external_issues_tracker_enabled?
if project.used_default_issues_tracker? || !project.external_issues_tracker_enabled?
project_issues_path(project)
else
url = Gitlab.config.issues_tracker[project.issues_tracker]['project_url']
......@@ -28,7 +28,7 @@ module IssuesHelper
def url_for_new_issue(project = @project)
return '' if project.nil?
if project.used_default_issues_tracker? || !external_issues_tracker_enabled?
if project.used_default_issues_tracker? || !project.external_issues_tracker_enabled?
url = new_project_issue_path project_id: project
else
issues_tracker = Gitlab.config.issues_tracker[project.issues_tracker]
......@@ -41,7 +41,7 @@ module IssuesHelper
def url_for_issue(issue_iid, project = @project)
return '' if project.nil?
if project.used_default_issues_tracker? || !external_issues_tracker_enabled?
if project.used_default_issues_tracker? || !project.external_issues_tracker_enabled?
url = project_issue_url project_id: project, id: issue_iid
else
url = Gitlab.config.issues_tracker[project.issues_tracker]['issues_url']
......@@ -77,11 +77,6 @@ module IssuesHelper
ts.html_safe
end
# Checks if issues_tracker setting exists in gitlab.yml
def external_issues_tracker_enabled?
Gitlab.config.issues_tracker && Gitlab.config.issues_tracker.values.any?
end
def bulk_update_milestone_options
options_for_select(['None (backlog)']) +
options_from_collection_for_select(project_active_milestones, 'id',
......
......@@ -309,6 +309,18 @@ class Project < ActiveRecord::Base
self.issues_tracker == Project.issues_tracker.default_value
end
def external_issues_tracker_enabled?
external_issues_trackers.any?
end
def external_issues_trackers
services.select { |service| service.category == :issue_tracker }
end
def external_issue_tracker
@external_issues_tracker ||= external_issues_trackers.select(&:activated?).first
end
def can_have_issues_tracker_id?
self.issues_enabled && !self.used_default_issues_tracker?
end
......
class IssueTrackerService < Service
def category
:issue_tracker
end
def project_url
# implement inside child
end
......
......@@ -48,9 +48,9 @@ class RedmineService < IssueTrackerService
end
def set_project_url
id = self.project.issue_tracker_id
id = self.project.issues_tracker_id
if id
issues_tracker['project_url'].gsub(":issue_tracker_id", id)
issues_tracker['project_url'].gsub(":issues_tracker_id", id)
else
issues_tracker['project_url']
end
......
......@@ -208,7 +208,7 @@ module Gitlab
end
def reference_issue(identifier, project = @project, prefix_text = nil)
if project.used_default_issues_tracker? || !external_issues_tracker_enabled?
if project.used_default_issues_tracker? || !project.external_issues_tracker_enabled?
if project.issue_exists? identifier
url = url_for_issue(identifier, project)
title = title_for_issue(identifier, project)
......@@ -220,8 +220,7 @@ module Gitlab
link_to("#{prefix_text}##{identifier}", url, options)
end
else
config = Gitlab.config
external_issue_tracker = config.issues_tracker[project.issues_tracker]
external_issue_tracker = project.external_issue_tracker
if external_issue_tracker.present?
reference_external_issue(identifier, external_issue_tracker, project,
prefix_text)
......@@ -270,7 +269,7 @@ module Gitlab
def reference_external_issue(identifier, issue_tracker, project = @project,
prefix_text = nil)
url = url_for_issue(identifier, project)
title = issue_tracker['title']
title = issue_tracker.title
options = html_options.merge(
title: "Issue in #{title}",
......
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