diff --git a/app/helpers/labels_helper.rb b/app/helpers/labels_helper.rb index c4967a42a451ea7a4bb681173099fc37c31e0b5e..79bab0969d1c842f4f232a77c5525e9346be21bb 100644 --- a/app/helpers/labels_helper.rb +++ b/app/helpers/labels_helper.rb @@ -46,11 +46,11 @@ def link_to_label(label, type: :issue, tooltip: true, small: false, css_class: n end end - def render_label(label, link: nil, tooltip: true, dataset: nil, small: false) + def render_label(label, link: nil, tooltip: true, dataset: nil, small: false, tooltip_shows_title: false) html = render_colored_label(label) if link - title = label_tooltip_title(label) if tooltip + title = label_tooltip_title(label, tooltip_shows_title: tooltip_shows_title) if tooltip html = render_label_link(html, link: link, title: title, dataset: dataset) end @@ -74,8 +74,8 @@ def wrap_label_html(label_html, small:, label:) %(<span class="#{wrapper_classes.join(' ')}">#{label_html}</span>).html_safe end - def label_tooltip_title(label) - Sanitize.clean(label.description) + def label_tooltip_title(label, tooltip_shows_title: false) + Sanitize.clean(tooltip_shows_title ? label.title : label.description) end def suggested_colors diff --git a/app/views/shared/_label_row.html.haml b/app/views/shared/_label_row.html.haml index 19489981d9491b80abbdbf65e6955613599b79bc..5058455dcd79009147b6e06cea55f08200ce3918 100644 --- a/app/views/shared/_label_row.html.haml +++ b/app/views/shared/_label_row.html.haml @@ -4,7 +4,7 @@ - show_label_merge_requests_link = subject_or_group_defined && show_label_issuables_link?(label, :merge_requests) .label-name.gl-flex-shrink-0.gl-mr-5 - = render_label(label, tooltip: false) + = render_label(label, link: '#', tooltip: true, tooltip_shows_title: true) - if show_labels_full_path?(@project, @group) .gl-mt-2 = render 'shared/label_full_path', label: label diff --git a/ee/app/helpers/ee/labels_helper.rb b/ee/app/helpers/ee/labels_helper.rb index f60da732f515ad0ab9c1010a1675fe27b1a20291..a9e0d1da0f25bc9534ba2d562498e82264b652f1 100644 --- a/ee/app/helpers/ee/labels_helper.rb +++ b/ee/app/helpers/ee/labels_helper.rb @@ -33,7 +33,7 @@ def wrap_label_html(label_html, small:, label:) %(<span class="#{wrapper_classes.join(' ')}" style="--label-inset-border: inset 0 0 0 #{border_width} #{html_escape(label.color)}; color: #{html_escape(label.color)}">#{label_html}</span>).html_safe end - def label_tooltip_title(label) + def label_tooltip_title(label, tooltip_shows_title: false) tooltip = super tooltip = %(<span class='font-weight-bold scoped-label-tooltip-title'>Scoped label</span><br>#{tooltip}) if label.scoped_label? diff --git a/spec/helpers/labels_helper_spec.rb b/spec/helpers/labels_helper_spec.rb index b45496308133a861695676588d4f1acd066c033c..4877ab1ff03383f4d42758b5c9a0e07a9b37ace3 100644 --- a/spec/helpers/labels_helper_spec.rb +++ b/spec/helpers/labels_helper_spec.rb @@ -275,9 +275,18 @@ let(:html) { '<img src="example.png">This is an image</img>' } let(:label_with_html_content) { create(:label, title: 'test', description: html) } - it 'removes HTML' do - tooltip = label_tooltip_title(label_with_html_content) - expect(tooltip).to eq('This is an image') + context 'tooltip shows description' do + it 'removes HTML' do + tooltip = label_tooltip_title(label_with_html_content) + expect(tooltip).to eq('This is an image') + end + end + + context 'tooltip shows title' do + it 'shows title' do + tooltip = label_tooltip_title(label_with_html_content, tooltip_shows_title: true) + expect(tooltip).to eq('test') + end end end diff --git a/spec/views/shared/_label_row.html.haml_spec.rb b/spec/views/shared/_label_row.html.haml_spec.rb index eb277930c1d27fbf15f24214837736e2886ec257..ef5a479d736fc5de71b6a6c36a5bce80f81c8c94 100644 --- a/spec/views/shared/_label_row.html.haml_spec.rb +++ b/spec/views/shared/_label_row.html.haml_spec.rb @@ -25,8 +25,8 @@ expect(rendered).to have_text(label.title) end - it 'has a non-linked label title' do - expect(rendered).not_to have_link(label.title) + it 'has a linked label title' do + expect(rendered).to have_link(label.title) end it 'has Issues link' do @@ -57,8 +57,8 @@ expect(rendered).to have_text(label.title) end - it 'has a non-linked label title' do - expect(rendered).not_to have_link(label.title) + it 'has a linked label title' do + expect(rendered).to have_link(label.title) end it 'has Issues link' do @@ -85,8 +85,8 @@ expect(rendered).to have_text(label.title) end - it 'has a non-linked label title' do - expect(rendered).not_to have_link(label.title) + it 'has a linked label title' do + expect(rendered).to have_link(label.title) end it 'has Issues link' do @@ -111,8 +111,8 @@ expect(rendered).to have_text(label.title) end - it 'has a non-linked label title' do - expect(rendered).not_to have_link(label.title) + it 'has a linked label title' do + expect(rendered).to have_link(label.title) end it 'does not show Issues link' do