summaryrefslogtreecommitdiff
path: root/app/models/project_services/youtrack_service.rb
blob: 957be685aea9b8ba5d6357a1ddee1f600e939e99 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# frozen_string_literal: true

class YoutrackService < IssueTrackerService
  validates :project_url, :issues_url, presence: true, public_url: true, if: :activated?

  prop_accessor :description, :project_url, :issues_url

  # {PROJECT-KEY}-{NUMBER} Examples: YT-1, PRJ-1
  def self.reference_pattern(only_long: false)
    if only_long
      /(?<issue>\b[A-Z][A-Za-z0-9_]*-\d+)/
    else
      /(?<issue>\b[A-Z][A-Za-z0-9_]*-\d+)|(#{Issue.reference_prefix}(?<issue>\d+))/
    end
  end

  def title
    'YouTrack'
  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

  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
end