2015-01-21 00:46:27 +00:00
|
|
|
class RedmineService < IssueTrackerService
|
|
|
|
|
|
|
|
prop_accessor :title, :description, :project_url, :issues_url, :new_issue_url
|
|
|
|
|
|
|
|
def title
|
|
|
|
'Redmine'
|
|
|
|
end
|
|
|
|
|
|
|
|
def description
|
|
|
|
'Redmine issue tracker'
|
|
|
|
end
|
|
|
|
|
|
|
|
def to_param
|
|
|
|
'redmine'
|
|
|
|
end
|
|
|
|
|
|
|
|
def fields
|
|
|
|
[
|
|
|
|
{ type: 'text', name: 'project_url', placeholder: 'Project url' },
|
|
|
|
{ type: 'text', name: 'issues_url', placeholder: 'Issue url'},
|
|
|
|
{ type: 'text', name: 'new_issue_url', placeholder: 'New Issue url'}
|
|
|
|
]
|
|
|
|
end
|
|
|
|
|
|
|
|
def initialize_properties
|
|
|
|
if properties.nil?
|
|
|
|
if enabled_in_gitlab_config
|
|
|
|
self.properties = {
|
|
|
|
title: issues_tracker['title'],
|
2015-01-23 17:14:45 +00:00
|
|
|
project_url: set_project_url,
|
2015-01-21 00:46:27 +00:00
|
|
|
issues_url: issues_tracker['issues_url'],
|
|
|
|
new_issue_url: issues_tracker['new_issue_url']
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def enabled_in_gitlab_config
|
|
|
|
Gitlab.config.issues_tracker &&
|
|
|
|
Gitlab.config.issues_tracker.values.any? &&
|
|
|
|
issues_tracker
|
|
|
|
end
|
|
|
|
|
|
|
|
def issues_tracker
|
|
|
|
Gitlab.config.issues_tracker['redmine']
|
|
|
|
end
|
2015-01-23 17:14:45 +00:00
|
|
|
|
|
|
|
def set_project_url
|
2015-01-23 18:28:38 +00:00
|
|
|
id = self.project.issues_tracker_id
|
2015-01-23 17:14:45 +00:00
|
|
|
if id
|
2015-01-23 18:28:38 +00:00
|
|
|
issues_tracker['project_url'].gsub(":issues_tracker_id", id)
|
2015-01-23 17:14:45 +00:00
|
|
|
else
|
|
|
|
issues_tracker['project_url']
|
|
|
|
end
|
|
|
|
end
|
2015-01-21 00:46:27 +00:00
|
|
|
end
|