diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-09-29 00:21:47 -0300 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-10-19 14:58:25 -0200 |
commit | 07709c5576a06179c5365b0d7fe154c5f67ca7e5 (patch) | |
tree | 88ab5e1296d4b7775c524b8cef2da8e4b14b463f /lib/banzai | |
parent | 484f19ed1c5c07cbf8ea26fab8b6759961fcf9ca (diff) | |
download | gitlab-ce-07709c5576a06179c5365b0d7fe154c5f67ca7e5.tar.gz |
Unfold references for group labels when moving issue to another project
Diffstat (limited to 'lib/banzai')
-rw-r--r-- | lib/banzai/filter/label_reference_filter.rb | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/lib/banzai/filter/label_reference_filter.rb b/lib/banzai/filter/label_reference_filter.rb index 4c4784b0052..649c697b415 100644 --- a/lib/banzai/filter/label_reference_filter.rb +++ b/lib/banzai/filter/label_reference_filter.rb @@ -70,13 +70,46 @@ module Banzai end def object_link_text(object, matches) - if object.is_a?(GroupLabel) || object.project == context[:project] - LabelsHelper.render_colored_label(object) + if same_group?(object) && namespace_match?(matches) + render_same_project_label(object) + elsif same_project?(object) + render_same_project_label(object) else - LabelsHelper.render_colored_cross_project_label(object) + render_cross_project_label(object, matches) end end + def same_group?(object) + object.is_a?(GroupLabel) && object.group == project.group + end + + def namespace_match?(matches) + matches[:project].blank? || matches[:project] == project.path_with_namespace + end + + def same_project?(object) + object.is_a?(ProjectLabel) && object.project == project + end + + def project + context[:project] + end + + def render_same_project_label(object) + LabelsHelper.render_colored_label(object) + end + + def render_cross_project_label(object, matches) + source_project = + if matches[:project] + Project.find_with_namespace(matches[:project]) + else + object.project + end + + LabelsHelper.render_colored_cross_project_label(object, source_project) + end + def unescape_html_entities(text) CGI.unescapeHTML(text.to_s) end |