summaryrefslogtreecommitdiff
path: root/lib/banzai/filter
diff options
context:
space:
mode:
authorJan Provaznik <jprovaznik@gitlab.com>2018-03-20 09:29:15 +0100
committerJan Provaznik <jprovaznik@gitlab.com>2018-03-23 10:04:44 +0100
commit204ab7c9f88e19eea96ff64e39ae81cdcb83bada (patch)
treee2e96e3d0d2dc933d6e32529eea9306e841303f4 /lib/banzai/filter
parent453b5c1c12ecc34f2aca7df021bfc451fefab095 (diff)
downloadgitlab-ce-204ab7c9f88e19eea96ff64e39ae81cdcb83bada.tar.gz
Fix issuable state indicator
Now the issuable reference check works only in project scope, if we reference an issuable from a non-project resource (e.g. epics), then project is not set, and there is mismatch in generated issue references. This patch enables issuable reference state check also from group scope. Closes gitlab-ee#4683 Related to #30916
Diffstat (limited to 'lib/banzai/filter')
-rw-r--r--lib/banzai/filter/issuable_state_filter.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/banzai/filter/issuable_state_filter.rb b/lib/banzai/filter/issuable_state_filter.rb
index 77299abe324..8f541dcfdb2 100644
--- a/lib/banzai/filter/issuable_state_filter.rb
+++ b/lib/banzai/filter/issuable_state_filter.rb
@@ -17,7 +17,7 @@ module Banzai
issuables.each do |node, issuable|
next if !can_read_cross_project? && issuable.project != project
- if VISIBLE_STATES.include?(issuable.state) && node.inner_html == issuable.reference_link_text(project)
+ if VISIBLE_STATES.include?(issuable.state) && issuable_reference?(node.inner_html, issuable)
node.content += " (#{issuable.state})"
end
end
@@ -27,6 +27,10 @@ module Banzai
private
+ def issuable_reference?(text, issuable)
+ text == issuable.reference_link_text(project || group)
+ end
+
def can_read_cross_project?
Ability.allowed?(current_user, :read_cross_project)
end
@@ -38,6 +42,10 @@ module Banzai
def project
context[:project]
end
+
+ def group
+ context[:group]
+ end
end
end
end