2019-07-07 11:18:12 +05:30
# frozen_string_literal: true
class YoutrackService < IssueTrackerService
2021-06-08 01:23:25 +05:30
include ActionView :: Helpers :: UrlHelper
2019-07-07 11:18:12 +05:30
validates :project_url , :issues_url , presence : true , public_url : true , if : :activated?
2019-09-04 21:01:54 +05:30
# {PROJECT-KEY}-{NUMBER} Examples: YT-1, PRJ-1, gl-030
2019-07-07 11:18:12 +05:30
def self . reference_pattern ( only_long : false )
if only_long
2020-03-13 15:44:24 +05:30
/ (?<issue> \ b[A-Za-z][A-Za-z0-9_]*- \ d+ \ b) /
2019-07-07 11:18:12 +05:30
else
2020-04-08 14:13:33 +05:30
/ (?<issue> \ b[A-Za-z][A-Za-z0-9_]*- \ d+ \ b)|( #{ Issue . reference_prefix } #{ Gitlab :: Regex . issue } ) /
2019-07-07 11:18:12 +05:30
end
end
2020-07-28 23:09:34 +05:30
def title
2019-07-07 11:18:12 +05:30
'YouTrack'
end
2020-07-28 23:09:34 +05:30
def description
2021-06-08 01:23:25 +05:30
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-07-07 11:18:12 +05:30
end
def self . to_param
'youtrack'
end
def fields
[
2021-06-08 01:23:25 +05:30
{ type : 'text' , name : 'project_url' , title : _ ( 'Project URL' ) , help : s_ ( 'IssueTracker|The URL to the project in YouTrack.' ) , required : true } ,
{ type : 'text' , name : 'issues_url' , title : s_ ( 'ProjectService|Issue URL' ) , help : s_ ( 'IssueTracker|The URL to view an issue in the YouTrack project. Must contain %{colon_id}.' ) % { colon_id : '<code>:id</code>' . html_safe } , required : true }
2019-07-07 11:18:12 +05:30
]
end
end