Class: Banzai::Filter::IssueReferenceFilter

Inherits:
IssuableReferenceFilter show all
Defined in:
lib/banzai/filter/issue_reference_filter.rb

Overview

HTML filter that replaces issue references with links. References to issues that do not exist are ignored.

This filter supports cross-project references.

When external issues tracker like Jira is activated we should not use issue reference pattern, but we should still be able to reference issues from other GitLab projects.

Constant Summary

Constants inherited from AbstractReferenceFilter

AbstractReferenceFilter::REFERENCE_PLACEHOLDER, AbstractReferenceFilter::REFERENCE_PLACEHOLDER_PATTERN

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from IssuableReferenceFilter

#find_object, #parent_from_ref, #record_identifier

Methods inherited from AbstractReferenceFilter

#call, #current_parent_path, #current_project_namespace_path, #data_attributes_for, #find_for_paths, #find_object, #find_object_cached, #find_object_from_link, #find_object_from_link_cached, #from_ref_cached, #identifier, identifier, #object_class, #object_link_filter, #object_link_text, #object_link_title, object_name, #object_sym, object_sym, #parent_per_reference, parse_symbol, #record_identifier, #records_per_parent, references_in, #references_in, #references_per_parent, #relation_for_paths, symbol_from_match, #url_for_object_cached, #wrap_link

Methods included from CrossProjectReference

#parent_from_ref

Methods inherited from ReferenceFilter

call, #call_and_update_nodes, #data_attribute, #each_node, #element_node?, #group, #ignore_ancestor_query, #initialize, #nodes, #project, #reference_class, #replace_link_node_with_href, #replace_link_node_with_text, #replace_text_when_pattern_matches, #skip_project_check?, #text_node?, #user, #validate, #yield_valid_link

Methods included from OutputSafety

#escape_once

Methods included from RequestStoreReferenceCache

#cached_call, #get_or_set_cache

Constructor Details

This class inherits a constructor from Banzai::Filter::ReferenceFilter

Class Method Details

.object_classObject


16
17
18
# File 'lib/banzai/filter/issue_reference_filter.rb', line 16

def self.object_class
  Issue
end

Instance Method Details


30
31
32
# File 'lib/banzai/filter/issue_reference_filter.rb', line 30

def object_link_text_extras(issue, matches)
  super + design_link_extras(issue, matches.named_captures['path'])
end

#parent_records(parent, ids) ⇒ Object


26
27
28
# File 'lib/banzai/filter/issue_reference_filter.rb', line 26

def parent_records(parent, ids)
  parent.issues.where(iid: ids.to_a)
end

#url_for_object(issue, project) ⇒ Object


20
21
22
23
24
# File 'lib/banzai/filter/issue_reference_filter.rb', line 20

def url_for_object(issue, project)
  return issue_path(issue, project) if only_path?

  issue_url(issue, project)
end