summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Tang <dennis@dennistang.net>2018-03-26 19:50:23 -0700
committerDennis Tang <dennis@dennistang.net>2018-03-26 19:50:23 -0700
commit36ce61cd1313e6f32ce43f693e1d3034ddfe3aab (patch)
treee2db2bcea0710838c5e42d9597aeddbc45285a78
parentb70100c25302fbfb0a1ecdeaca3d6983b3d7b98c (diff)
downloadgitlab-ce-25010-collapsed-sidebar-tooltips.tar.gz
revert label tooltip changes and add tests for label empty state tooltip25010-collapsed-sidebar-tooltips
-rw-r--r--app/assets/javascripts/labels_select.js3
-rw-r--r--app/helpers/issuables_helper.rb4
-rw-r--r--spec/helpers/issuables_helper_spec.rb12
-rw-r--r--spec/javascripts/labels_issue_sidebar_spec.js4
4 files changed, 13 insertions, 10 deletions
diff --git a/app/assets/javascripts/labels_select.js b/app/assets/javascripts/labels_select.js
index 7e7925cbaeb..ec7dcffe8ba 100644
--- a/app/assets/javascripts/labels_select.js
+++ b/app/assets/javascripts/labels_select.js
@@ -111,8 +111,7 @@ export default class LabelsSelect {
labelTitles.push('and ' + (data.labels.length - 5) + ' more');
}
- formattedLabels = labelTitles.join(', ');
- labelTooltipTitle = sprintf(__('Labels: %{formattedLabels}'), ({ formattedLabels }));
+ labelTooltipTitle = labelTitles.join(', ');
}
else {
labelTooltipTitle = __('Labels');
diff --git a/app/helpers/issuables_helper.rb b/app/helpers/issuables_helper.rb
index 9022547605a..0ab6ae8d7c7 100644
--- a/app/helpers/issuables_helper.rb
+++ b/app/helpers/issuables_helper.rb
@@ -185,11 +185,11 @@ module IssuablesHelper
def issuable_labels_tooltip(labels, limit: 5)
first, last = labels.partition.with_index { |_, i| i < limit }
- if labels.any?
+ if labels && labels.any?
label_names = first.collect(&:name)
label_names << "and #{last.size} more" unless last.empty?
- _("Labels") + ": #{label_names.join(', ')}"
+ label_names.join(', ')
else
_("Labels")
end
diff --git a/spec/helpers/issuables_helper_spec.rb b/spec/helpers/issuables_helper_spec.rb
index f03de5fc6e2..34834a5ecce 100644
--- a/spec/helpers/issuables_helper_spec.rb
+++ b/spec/helpers/issuables_helper_spec.rb
@@ -22,12 +22,16 @@ describe IssuablesHelper do
end
describe '#issuable_labels_tooltip' do
- it 'returns label text' do
- expect(issuable_labels_tooltip([label])).to eq("Labels: #{label.title}")
+ it 'returns label text with no labels' do
+ expect(issuable_labels_tooltip([])).to eq("Labels")
end
- it 'returns label text' do
- expect(issuable_labels_tooltip([label, label2], limit: 1)).to eq("Labels: #{label.title}, and 1 more")
+ it 'returns label text with labels within max limit' do
+ expect(issuable_labels_tooltip([label])).to eq(label.title)
+ end
+
+ it 'returns label text with labels exceeding max limit' do
+ expect(issuable_labels_tooltip([label, label2], limit: 1)).to eq("#{label.title}, and 1 more")
end
end
diff --git a/spec/javascripts/labels_issue_sidebar_spec.js b/spec/javascripts/labels_issue_sidebar_spec.js
index c0621a153ae..5aafb6ad8f0 100644
--- a/spec/javascripts/labels_issue_sidebar_spec.js
+++ b/spec/javascripts/labels_issue_sidebar_spec.js
@@ -68,7 +68,7 @@ import '~/users_select';
$('.edit-link').get(0).click();
setTimeout(() => {
- expect($('.sidebar-collapsed-icon').attr('data-original-title')).toBe('Labels: test 0, test 1, test 2, test 3, test 4');
+ expect($('.sidebar-collapsed-icon').attr('data-original-title')).toBe('test 0, test 1, test 2, test 3, test 4');
done();
}, 0);
}, 0);
@@ -90,7 +90,7 @@ import '~/users_select';
$('.edit-link').get(0).click();
setTimeout(() => {
- expect($('.sidebar-collapsed-icon').attr('data-original-title')).toBe('Labels: test 0, test 1, test 2, test 3, test 4, and 1 more');
+ expect($('.sidebar-collapsed-icon').attr('data-original-title')).toBe('test 0, test 1, test 2, test 3, test 4, and 1 more');
done();
}, 0);
}, 0);