diff options
author | Marin Jankovski <maxlazio@gmail.com> | 2015-01-27 03:24:11 +0300 |
---|---|---|
committer | Marin Jankovski <maxlazio@gmail.com> | 2015-01-27 03:24:11 +0300 |
commit | 00a0d5aeeaf19ea4d72fd1890afac099026f1706 (patch) | |
tree | 8e39c3a788682f18eb3772e6cf9c700a4baff6e1 | |
parent | 9b5b334a798233b200318ecfbff55f0284f874da (diff) |
Move repetition to the parent.
-rw-r--r-- | app/models/project_services/issue_tracker_service.rb | 44 | ||||
-rw-r--r-- | app/models/project_services/jira_service.rb | 45 | ||||
-rw-r--r-- | app/models/project_services/redmine_service.rb | 54 | ||||
-rw-r--r-- | lib/gitlab/markdown.rb | 9 |
4 files changed, 58 insertions, 94 deletions
diff --git a/app/models/project_services/issue_tracker_service.rb b/app/models/project_services/issue_tracker_service.rb index 664b55a5951..7ff6e0f284d 100644 --- a/app/models/project_services/issue_tracker_service.rb +++ b/app/models/project_services/issue_tracker_service.rb @@ -15,4 +15,48 @@ class IssueTrackerService < Service def new_issue_url # implement inside child end + + def fields + [ + { type: 'text', name: 'description', placeholder: description }, + { type: 'text', name: 'project_url', placeholder: 'Project url' }, + { type: 'text', name: 'issues_url', placeholder: 'Issue url'}, + { type: 'text', name: 'new_issue_url', placeholder: 'New Issue url'} + ] + end + + def initialize_properties + if properties.nil? + if enabled_in_gitlab_config + self.properties = { + title: issues_tracker['title'], + project_url: set_project_url, + issues_url: issues_tracker['issues_url'], + new_issue_url: issues_tracker['new_issue_url'] + } + end + end + end + + private + + def enabled_in_gitlab_config + Gitlab.config.issues_tracker && + Gitlab.config.issues_tracker.values.any? && + issues_tracker + end + + def issues_tracker + Gitlab.config.issues_tracker[to_param] + end + + def set_project_url + id = self.project.issues_tracker_id + + if id + issues_tracker['project_url'].gsub(":issues_tracker_id", id) + else + issues_tracker['project_url'] + end + end end diff --git a/app/models/project_services/jira_service.rb b/app/models/project_services/jira_service.rb index f8b04ddeea7..b0d668948d0 100644 --- a/app/models/project_services/jira_service.rb +++ b/app/models/project_services/jira_service.rb @@ -21,49 +21,4 @@ class JiraService < IssueTrackerService def to_param 'jira' end - - def fields - [ - { type: 'text', name: 'title', placeholder: title }, - { type: 'text', name: 'description', placeholder: description }, - { type: 'text', name: 'project_url', placeholder: 'Project url' }, - { type: 'text', name: 'issues_url', placeholder: 'Issue url'}, - { type: 'text', name: 'new_issue_url', placeholder: 'New Issue url'} - ] - end - - def initialize_properties - if properties.nil? - if enabled_in_gitlab_config - self.properties = { - title: issues_tracker['title'], - project_url: set_project_url, - issues_url: issues_tracker['issues_url'], - new_issue_url: issues_tracker['new_issue_url'] - } - end - end - end - - private - - def enabled_in_gitlab_config - Gitlab.config.issues_tracker && - Gitlab.config.issues_tracker.values.any? && - issues_tracker - end - - def issues_tracker - Gitlab.config.issues_tracker['jira'] - end - - def set_project_url - id = self.project.issues_tracker_id - - if id - issues_tracker['project_url'].gsub(":issues_tracker_id", id) - else - issues_tracker['project_url'] - end - end end diff --git a/app/models/project_services/redmine_service.rb b/app/models/project_services/redmine_service.rb index 71286d74b58..11cce3e0561 100644 --- a/app/models/project_services/redmine_service.rb +++ b/app/models/project_services/redmine_service.rb @@ -3,56 +3,22 @@ class RedmineService < IssueTrackerService prop_accessor :title, :description, :project_url, :issues_url, :new_issue_url def title - 'Redmine' + if self.properties && self.properties['title'].present? + self.properties['title'] + else + 'Redmine' + end end def description - 'Redmine issue tracker' + if self.properties && self.properties['description'].present? + self.properties['description'] + else + 'Redmine issue tracker' + end end def to_param 'redmine' end - - def fields - [ - { type: 'text', name: 'project_url', placeholder: 'Project url' }, - { type: 'text', name: 'issues_url', placeholder: 'Issue url'}, - { type: 'text', name: 'new_issue_url', placeholder: 'New Issue url'} - ] - end - - def initialize_properties - if properties.nil? - if enabled_in_gitlab_config - self.properties = { - title: issues_tracker['title'], - project_url: set_project_url, - issues_url: issues_tracker['issues_url'], - new_issue_url: issues_tracker['new_issue_url'] - } - end - end - end - - private - - def enabled_in_gitlab_config - Gitlab.config.issues_tracker && - Gitlab.config.issues_tracker.values.any? && - issues_tracker - end - - def issues_tracker - Gitlab.config.issues_tracker['redmine'] - end - - def set_project_url - id = self.project.issues_tracker_id - if id - issues_tracker['project_url'].gsub(":issues_tracker_id", id) - else - issues_tracker['project_url'] - end - end end diff --git a/lib/gitlab/markdown.rb b/lib/gitlab/markdown.rb index 2f041336471..c0e83fb3078 100644 --- a/lib/gitlab/markdown.rb +++ b/lib/gitlab/markdown.rb @@ -220,9 +220,8 @@ module Gitlab link_to("#{prefix_text}##{identifier}", url, options) end else - external_issue_tracker = project.external_issue_tracker - if external_issue_tracker.present? - reference_external_issue(identifier, external_issue_tracker, project, + if project.external_issue_tracker.present? + reference_external_issue(identifier, project, prefix_text) end end @@ -266,10 +265,10 @@ module Gitlab end end - def reference_external_issue(identifier, issue_tracker, project = @project, + def reference_external_issue(identifier, project = @project, prefix_text = nil) url = url_for_issue(identifier, project) - title = issue_tracker.title + title = project.external_issue_tracker.title options = html_options.merge( title: "Issue in #{title}", |