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 ...@@ -50,22 +50,23 @@ module LabelsHelper
@project.labels.pluck(:title) @project.labels.pluck(:title)
end end
def render_colored_label(label, label_prefix = '') def render_colored_label(label, label_suffix = '')
label_color = label.color || Label::DEFAULT_COLOR label_color = label.color || Label::DEFAULT_COLOR
text_color = text_color_for_bg(label_color) text_color = text_color_for_bg(label_color)
# Intentionally not using content_tag here so that this method can be called # Intentionally not using content_tag here so that this method can be called
# by LabelReferenceFilter # by LabelReferenceFilter
span = %(<span class="label color-label") + span = %(<span class="label color-label") +
%( style="background-color: #{label_color}; color: #{text_color}">) + %(style="background-color: #{label_color}; color: #{text_color}">) +
label_prefix + escape_once(label.name) + '</span>' %(#{escape_once(label.name)}#{label_suffix}</span>)
span.html_safe span.html_safe
end end
def render_colored_cross_project_label(label) def render_colored_cross_project_label(label)
label_prefix = "#{label.project.path_with_namespace} &raquo; " label_suffix = label.project.name
render_colored_label(label, label_prefix) label_suffix = " <i>&laquo; #{label_suffix}</i>"
render_colored_label(label, label_suffix)
end end
def suggested_colors def suggested_colors
......
...@@ -178,7 +178,8 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do ...@@ -178,7 +178,8 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do
end end
describe 'cross project label references' do 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(:label) { create(:label, project: another_project, color: '#00ff00') }
let(:reference) { label.to_reference(project) } let(:reference) { label.to_reference(project) }
...@@ -192,7 +193,12 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do ...@@ -192,7 +193,12 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do
end end
it 'has valid color' do 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 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