Commit 62dcdef9 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Improve cross project label look and feel

parent 7183a7da
......@@ -50,22 +50,23 @@ module LabelsHelper
@project.labels.pluck(:title)
end
def render_colored_label(label, label_prefix = '')
def render_colored_label(label, label_suffix = '')
label_color = label.color || Label::DEFAULT_COLOR
text_color = text_color_for_bg(label_color)
# Intentionally not using content_tag here so that this method can be called
# by LabelReferenceFilter
span = %(<span class="label color-label") +
%( style="background-color: #{label_color}; color: #{text_color}">) +
label_prefix + escape_once(label.name) + '</span>'
%(style="background-color: #{label_color}; color: #{text_color}">) +
%(#{escape_once(label.name)}#{label_suffix}</span>)
span.html_safe
end
def render_colored_cross_project_label(label)
label_prefix = "#{label.project.path_with_namespace} &raquo; "
render_colored_label(label, label_prefix)
label_suffix = label.project.name
label_suffix = " <i>&laquo; #{label_suffix}</i>"
render_colored_label(label, label_suffix)
end
def suggested_colors
......
......@@ -178,7 +178,8 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do
end
describe 'cross project label references' do
let(:another_project) { create(:empty_project, :public) }
let(:project_name) { 'Some project' }
let(:another_project) { create(:empty_project, :public, name: project_name) }
let(:label) { create(:label, project: another_project, color: '#00ff00') }
let(:reference) { label.to_reference(project) }
......@@ -192,7 +193,12 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do
end
it 'has valid color' do
expect(result.css('a span').first.attr('style')).to match /background-color: #00ff00/
expect(result.css('a span').first.attr('style'))
.to match /background-color: #00ff00/
end
it 'contains cross project content' do
expect(result.css('a').first.text).to eq "#{label.name} « #{project_name}"
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment