Improve cross project label look and feel
This commit is contained in:
parent
7183a7da6d
commit
62dcdef969
2 changed files with 14 additions and 7 deletions
|
@ -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} » "
|
label_suffix = label.project.name
|
||||||
render_colored_label(label, label_prefix)
|
label_suffix = " <i>« #{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
|
||||||
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
|
||||||
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
|
||||||
|
|
Loading…
Reference in a new issue