2019-02-18 12:08:36 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class YoutrackService < IssueTrackerService
|
2019-02-21 05:39:44 -05:00
|
|
|
validates :project_url, :issues_url, presence: true, public_url: true, if: :activated?
|
2019-02-18 12:08:36 -05:00
|
|
|
|
2019-02-22 03:57:27 -05:00
|
|
|
prop_accessor :description, :project_url, :issues_url
|
2019-02-18 12:08:36 -05:00
|
|
|
|
|
|
|
# {PROJECT-KEY}-{NUMBER} Examples: YT-1, PRJ-1
|
|
|
|
def self.reference_pattern(only_long: false)
|
|
|
|
if only_long
|
2019-02-20 11:00:55 -05:00
|
|
|
/(?<issue>\b[A-Z][A-Za-z0-9_]*-\d+)/
|
2019-02-18 12:08:36 -05:00
|
|
|
else
|
2019-02-20 11:00:55 -05:00
|
|
|
/(?<issue>\b[A-Z][A-Za-z0-9_]*-\d+)|(#{Issue.reference_prefix}(?<issue>\d+))/
|
2019-02-18 12:08:36 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def title
|
2019-02-21 05:39:44 -05:00
|
|
|
'YouTrack'
|
2019-02-18 12:08:36 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def description
|
|
|
|
if self.properties && self.properties['description'].present?
|
|
|
|
self.properties['description']
|
|
|
|
else
|
|
|
|
'YouTrack issue tracker'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.to_param
|
|
|
|
'youtrack'
|
|
|
|
end
|
2019-02-21 05:39:44 -05:00
|
|
|
|
|
|
|
def fields
|
|
|
|
[
|
|
|
|
{ type: 'text', name: 'description', placeholder: description },
|
|
|
|
{ type: 'text', name: 'project_url', placeholder: 'Project url', required: true },
|
|
|
|
{ type: 'text', name: 'issues_url', placeholder: 'Issue url', required: true }
|
|
|
|
]
|
|
|
|
end
|
2019-02-18 12:08:36 -05:00
|
|
|
end
|