diff options
author | Jarka Košanová <jarka@gitlab.com> | 2019-06-26 17:03:57 +0300 |
---|---|---|
committer | Jarka Košanová <jarka@gitlab.com> | 2019-07-02 16:00:27 +0300 |
commit | ddbbf453c76144ac60c67e783424faf843c8efa1 (patch) | |
tree | 028cd360ebcae9582ac05a4b13ba2005621c534a /app/models | |
parent | 0e8b76e1918a7ca441e9eb98819f10da24e0588a (diff) |
Use title and description fields for issue trackers
- instead of using properties
- backward compatibility has to be kept for now
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/project_services/bugzilla_service.rb | 18 | ||||
-rw-r--r-- | app/models/project_services/custom_issue_tracker_service.rb | 20 | ||||
-rw-r--r-- | app/models/project_services/gitlab_issue_tracker_service.rb | 10 | ||||
-rw-r--r-- | app/models/project_services/issue_tracker_service.rb | 33 | ||||
-rw-r--r-- | app/models/project_services/jira_service.rb | 19 | ||||
-rw-r--r-- | app/models/project_services/redmine_service.rb | 18 | ||||
-rw-r--r-- | app/models/project_services/youtrack_service.rb | 12 | ||||
-rw-r--r-- | app/models/service.rb | 2 |
8 files changed, 66 insertions, 66 deletions
diff --git a/app/models/project_services/bugzilla_service.rb b/app/models/project_services/bugzilla_service.rb index 1a2bb6a171b..8b79b5e9f0c 100644 --- a/app/models/project_services/bugzilla_service.rb +++ b/app/models/project_services/bugzilla_service.rb @@ -3,22 +3,14 @@ class BugzillaService < IssueTrackerService validates :project_url, :issues_url, :new_issue_url, presence: true, public_url: true, if: :activated? - prop_accessor :title, :description, :project_url, :issues_url, :new_issue_url + prop_accessor :project_url, :issues_url, :new_issue_url - def title - if self.properties && self.properties['title'].present? - self.properties['title'] - else - 'Bugzilla' - end + def default_title + 'Bugzilla' end - def description - if self.properties && self.properties['description'].present? - self.properties['description'] - else - 'Bugzilla issue tracker' - end + def default_description + s_('IssueTracker|Bugzilla issue tracker') end def self.to_param diff --git a/app/models/project_services/custom_issue_tracker_service.rb b/app/models/project_services/custom_issue_tracker_service.rb index b8f8072869c..535fcf6b94e 100644 --- a/app/models/project_services/custom_issue_tracker_service.rb +++ b/app/models/project_services/custom_issue_tracker_service.rb @@ -5,24 +5,12 @@ class CustomIssueTrackerService < IssueTrackerService prop_accessor :title, :description, :project_url, :issues_url, :new_issue_url - def title - if self.properties && self.properties['title'].present? - self.properties['title'] - else - 'Custom Issue Tracker' - end + def default_title + 'Custom Issue Tracker' end - def title=(value) - self.properties['title'] = value if self.properties - end - - def description - if self.properties && self.properties['description'].present? - self.properties['description'] - else - 'Custom issue tracker' - end + def default_description + s_('IssueTracker|Custom issue tracker') end def self.to_param diff --git a/app/models/project_services/gitlab_issue_tracker_service.rb b/app/models/project_services/gitlab_issue_tracker_service.rb index fa9abf58e62..51032932eab 100644 --- a/app/models/project_services/gitlab_issue_tracker_service.rb +++ b/app/models/project_services/gitlab_issue_tracker_service.rb @@ -5,10 +5,18 @@ class GitlabIssueTrackerService < IssueTrackerService validates :project_url, :issues_url, :new_issue_url, presence: true, public_url: true, if: :activated? - prop_accessor :title, :description, :project_url, :issues_url, :new_issue_url + prop_accessor :project_url, :issues_url, :new_issue_url default_value_for :default, true + def default_title + 'GitLab' + end + + def default_description + s_('IssueTracker|GitLab issue tracker') + end + def self.to_param 'gitlab' end diff --git a/app/models/project_services/issue_tracker_service.rb b/app/models/project_services/issue_tracker_service.rb index f54497fc6d8..3a1130ffc15 100644 --- a/app/models/project_services/issue_tracker_service.rb +++ b/app/models/project_services/issue_tracker_service.rb @@ -5,6 +5,8 @@ class IssueTrackerService < Service default_value_for :category, 'issue_tracker' + before_save :handle_properties + # Pattern used to extract links from comments # Override this method on services that uses different patterns # This pattern does not support cross-project references @@ -18,6 +20,37 @@ class IssueTrackerService < Service end end + # this will be removed as part of https://gitlab.com/gitlab-org/gitlab-ce/issues/63084 + def title + if title_attribute = read_attribute(:title) + title_attribute + elsif self.properties && self.properties['title'].present? + self.properties['title'] + else + default_title + end + end + + # this will be removed as part of https://gitlab.com/gitlab-org/gitlab-ce/issues/63084 + def description + if description_attribute = read_attribute(:description) + description_attribute + elsif self.properties && self.properties['description'].present? + self.properties['description'] + else + default_description + end + end + + def handle_properties + properties.slice('title', 'description').each do |key, _| + current_value = self.properties.delete(key) + value = attribute_changed?(key) ? attribute_change(key).last : current_value + + write_attribute(key, value) + end + end + def default? default end diff --git a/app/models/project_services/jira_service.rb b/app/models/project_services/jira_service.rb index f31eb7fd19a..a3b89b2543a 100644 --- a/app/models/project_services/jira_service.rb +++ b/app/models/project_services/jira_service.rb @@ -17,7 +17,7 @@ class JiraService < IssueTrackerService # Jira Cloud version is deprecating authentication via username and password. # We should use username/password for Jira Server and email/api_token for Jira Cloud, # for more information check: https://gitlab.com/gitlab-org/gitlab-ce/issues/49936. - prop_accessor :username, :password, :url, :api_url, :jira_issue_transition_id, :title, :description + prop_accessor :username, :password, :url, :api_url, :jira_issue_transition_id before_update :reset_password @@ -37,7 +37,6 @@ class JiraService < IssueTrackerService def initialize_properties super do self.properties = { - title: issues_tracker['title'], url: issues_tracker['url'], api_url: issues_tracker['api_url'] } @@ -74,20 +73,12 @@ class JiraService < IssueTrackerService [Jira service documentation](#{help_page_url('user/project/integrations/jira')})." end - def title - if self.properties && self.properties['title'].present? - self.properties['title'] - else - 'Jira' - end + def default_title + 'Jira' end - def description - if self.properties && self.properties['description'].present? - self.properties['description'] - else - s_('JiraService|Jira issue tracker') - end + def default_description + s_('JiraService|Jira issue tracker') end def self.to_param diff --git a/app/models/project_services/redmine_service.rb b/app/models/project_services/redmine_service.rb index a80be4b06da..5ca057ca833 100644 --- a/app/models/project_services/redmine_service.rb +++ b/app/models/project_services/redmine_service.rb @@ -3,22 +3,14 @@ class RedmineService < IssueTrackerService validates :project_url, :issues_url, :new_issue_url, presence: true, public_url: true, if: :activated? - prop_accessor :title, :description, :project_url, :issues_url, :new_issue_url + prop_accessor :project_url, :issues_url, :new_issue_url - def title - if self.properties && self.properties['title'].present? - self.properties['title'] - else - 'Redmine' - end + def default_title + 'Redmine' end - def description - if self.properties && self.properties['description'].present? - self.properties['description'] - else - 'Redmine issue tracker' - end + def default_description + s_('IssueTracker|Redmine issue tracker') end def self.to_param diff --git a/app/models/project_services/youtrack_service.rb b/app/models/project_services/youtrack_service.rb index 175c2ebf197..f9de1f7dc49 100644 --- a/app/models/project_services/youtrack_service.rb +++ b/app/models/project_services/youtrack_service.rb @@ -3,7 +3,7 @@ class YoutrackService < IssueTrackerService validates :project_url, :issues_url, presence: true, public_url: true, if: :activated? - prop_accessor :description, :project_url, :issues_url + prop_accessor :project_url, :issues_url # {PROJECT-KEY}-{NUMBER} Examples: YT-1, PRJ-1, gl-030 def self.reference_pattern(only_long: false) @@ -14,16 +14,12 @@ class YoutrackService < IssueTrackerService end end - def title + def default_title 'YouTrack' end - def description - if self.properties && self.properties['description'].present? - self.properties['description'] - else - 'YouTrack issue tracker' - end + def default_description + s_('IssueTracker|YouTrack issue tracker') end def self.to_param diff --git a/app/models/service.rb b/app/models/service.rb index 40033003f3b..752467622f2 100644 --- a/app/models/service.rb +++ b/app/models/service.rb @@ -129,7 +129,7 @@ class Service < ApplicationRecord def api_field_names fields.map { |field| field[:name] } - .reject { |field_name| field_name =~ /(password|token|key)/ } + .reject { |field_name| field_name =~ /(password|token|key|title|description)/ } end def global_fields |