2015-12-23 02:04:40 +05:30
|
|
|
module Banzai
|
|
|
|
module Filter
|
|
|
|
# HTML filter that replaces merge request references with links. References
|
|
|
|
# to merge requests that do not exist are ignored.
|
|
|
|
#
|
|
|
|
# This filter supports cross-project references.
|
2018-03-17 18:26:18 +05:30
|
|
|
class MergeRequestReferenceFilter < IssuableReferenceFilter
|
2016-06-16 23:09:34 +05:30
|
|
|
self.reference_type = :merge_request
|
|
|
|
|
2015-12-23 02:04:40 +05:30
|
|
|
def self.object_class
|
|
|
|
MergeRequest
|
|
|
|
end
|
|
|
|
|
|
|
|
def url_for_object(mr, project)
|
2016-06-02 11:05:42 +05:30
|
|
|
h = Gitlab::Routing.url_helpers
|
2017-09-10 17:25:29 +05:30
|
|
|
h.project_merge_request_url(project, mr,
|
2015-12-23 02:04:40 +05:30
|
|
|
only_path: context[:only_path])
|
|
|
|
end
|
|
|
|
|
|
|
|
def object_link_text_extras(object, matches)
|
|
|
|
extras = super
|
|
|
|
|
|
|
|
path = matches[:path] if matches.names.include?("path")
|
|
|
|
case path
|
|
|
|
when '/diffs'
|
|
|
|
extras.unshift "diffs"
|
|
|
|
when '/commits'
|
|
|
|
extras.unshift "commits"
|
|
|
|
when '/builds'
|
|
|
|
extras.unshift "builds"
|
|
|
|
end
|
|
|
|
|
|
|
|
extras
|
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
def parent_records(parent, ids)
|
|
|
|
parent.merge_requests
|
|
|
|
.where(iid: ids.to_a)
|
|
|
|
.includes(target_project: :namespace)
|
|
|
|
end
|
2015-12-23 02:04:40 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|