2019-02-18 17:08:36 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class YoutrackService < IssueTrackerService
|
2021-04-23 09:10:03 +00:00
|
|
|
include ActionView::Helpers::UrlHelper
|
|
|
|
|
2019-02-21 10:39:44 +00:00
|
|
|
validates :project_url, :issues_url, presence: true, public_url: true, if: :activated?
|
2019-02-18 17:08:36 +00:00
|
|
|
|
2019-06-03 12:52:54 +00:00
|
|
|
# {PROJECT-KEY}-{NUMBER} Examples: YT-1, PRJ-1, gl-030
|
2019-02-18 17:08:36 +00:00
|
|
|
def self.reference_pattern(only_long: false)
|
|
|
|
if only_long
|
2020-02-14 12:09:03 +00:00
|
|
|
/(?<issue>\b[A-Za-z][A-Za-z0-9_]*-\d+\b)/
|
2019-02-18 17:08:36 +00:00
|
|
|
else
|
2020-02-18 12:09:15 +00:00
|
|
|
/(?<issue>\b[A-Za-z][A-Za-z0-9_]*-\d+\b)|(#{Issue.reference_prefix}#{Gitlab::Regex.issue})/
|
2019-02-18 17:08:36 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-06-22 12:08:47 +00:00
|
|
|
def title
|
2019-02-21 10:39:44 +00:00
|
|
|
'YouTrack'
|
2019-02-18 17:08:36 +00:00
|
|
|
end
|
|
|
|
|
2020-06-22 12:08:47 +00:00
|
|
|
def description
|
2021-04-23 09:10:03 +00:00
|
|
|
s_("IssueTracker|Use YouTrack as this project's issue tracker.")
|
|
|
|
end
|
|
|
|
|
|
|
|
def help
|
|
|
|
docs_link = link_to _('Learn more.'), Rails.application.routes.url_helpers.help_page_url('user/project/integrations/youtrack'), target: '_blank', rel: 'noopener noreferrer'
|
|
|
|
s_("IssueTracker|Use YouTrack as this project's issue tracker. %{docs_link}").html_safe % { docs_link: docs_link.html_safe }
|
2019-02-18 17:08:36 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def self.to_param
|
|
|
|
'youtrack'
|
|
|
|
end
|
2019-02-21 10:39:44 +00:00
|
|
|
|
|
|
|
def fields
|
|
|
|
[
|
2021-03-25 12:09:19 +00:00
|
|
|
{ type: 'text', name: 'project_url', title: _('Project URL'), required: true },
|
|
|
|
{ type: 'text', name: 'issues_url', title: s_('ProjectService|Issue URL'), required: true }
|
2019-02-21 10:39:44 +00:00
|
|
|
]
|
|
|
|
end
|
2019-02-18 17:08:36 +00:00
|
|
|
end
|