diff --git a/CHANGELOG b/CHANGELOG index d7b561f89228beccc34ff47de98345e03da82cbd..2ff1be3322b7aecca0709504b8162dffce469054 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -18,6 +18,7 @@ v 8.11.0 (unreleased) - API: Endpoints for enabling and disabling deploy keys - API: List access requests, request access, approve, and deny access requests to a project or a group. !4833 - Use long options for curl examples in documentation !5703 (winniehell) + - Added tooltip listing label names to the labels value in the collapsed issuable sidebar - Remove magic comments (`# encoding: UTF-8`) from Ruby files. !5456 (winniehell) - Fix badge count alignment (ClemMakesApps) - GitLab Performance Monitoring can now track custom events such as the number of tags pushed to a repository @@ -300,8 +301,6 @@ v 8.10.0 - Reduce size of HTML used by diff comment forms - Protected branches have a "Developers can Merge" setting. !4892 (original implementation by Mathias Vestergaard) - Fix user creation with stronger minimum password requirements. !4054 (nathan-pmt) - - Added tooltip listing label names to the labels value in the collapsed issuable sidebar - - Fix user creation with stronger minimum password requirements !4054 (nathan-pmt) - Only show New Snippet button to users that can create snippets. - PipelinesFinder uses git cache data - Track a user who created a pipeline diff --git a/app/assets/javascripts/labels_select.js b/app/assets/javascripts/labels_select.js index 5eb9def1982d365aad16ca40b383f11c7b6f7c7b..8dbbd9dd517a48c5d1c0375b467575fa7ceadf0f 100644 --- a/app/assets/javascripts/labels_select.js +++ b/app/assets/javascripts/labels_select.js @@ -32,6 +32,8 @@ labelNoneHTMLTemplate = '<span class="no-value">None</span>'; } + $sidebarLabelTooltip.tooltip(); + new gl.CreateLabelDropdown($dropdown.closest('.dropdown').find('.dropdown-new-label'), projectId); saveLabelData = function() { diff --git a/app/helpers/issuables_helper.rb b/app/helpers/issuables_helper.rb index b95a3e95001077b893e58e57348e1b7791850e30..c3f4c1b148d375b94b5a4b2f3e09bab48bdc24a1 100644 --- a/app/helpers/issuables_helper.rb +++ b/app/helpers/issuables_helper.rb @@ -72,18 +72,14 @@ module IssuablesHelper end end - def issuable_labels_tooltip(labels) - max_labels = 5 - label_size = labels.size - label_names = labels.each_with_index.map do |label, i| - label.name unless i >= max_labels - end + def issuable_labels_tooltip(labels, limit: 5) + first = labels[0...limit] + last = labels[(limit-1)...-1] - if label_size > max_labels - label_names << "and #{label_size - max_labels} more" - end + label_names = first.collect(&:name) + label_names << "and #{last.size} more" unless last.empty? - label_names.compact.join(', ') + label_names.join(', ') end private diff --git a/app/views/shared/issuable/_sidebar.html.haml b/app/views/shared/issuable/_sidebar.html.haml index c1b50e65af5f094ecbe34559083bc7c3aea8ecc6..bb18ef2536ebd947bc8b11525ce85ac8ac2462f9 100644 --- a/app/views/shared/issuable/_sidebar.html.haml +++ b/app/views/shared/issuable/_sidebar.html.haml @@ -109,7 +109,7 @@ - if issuable.project.labels.any? .block.labels - .sidebar-collapsed-icon.js-sidebar-labels-tooltip{ title: issuable_labels_tooltip(issuable.labels_array), data: { placement: "left", container: "body" } } + .sidebar-collapsed-icon.js-sidebar-labels-tooltip{ title: issuable_labels_tooltip(issuable.labels), data: { placement: "left", container: "body" } } = icon('tags') %span = issuable.labels_array.size diff --git a/spec/features/issues/issue_sidebar_spec.rb b/spec/features/issues/issue_sidebar_spec.rb index a6acbd5a701fde99e92e8d889f7ebb7dd748b181..b043bc3feeedd0cdab974d0d5e0ded2b3863ef43 100644 --- a/spec/features/issues/issue_sidebar_spec.rb +++ b/spec/features/issues/issue_sidebar_spec.rb @@ -1,6 +1,8 @@ require 'rails_helper' feature 'Issue Sidebar', feature: true do + include WaitForAjax + let(:project) { create(:project) } let(:issue) { create(:issue, project: project) } let!(:user) { create(:user)} @@ -103,7 +105,7 @@ feature 'Issue Sidebar', feature: true do end find('.edit-link').click - sleep 1 + wait_for_ajax expect(find('.js-sidebar-labels-tooltip', visible: false)['data-original-title']).to eq('a, b, c, d, e, and 1 more') end