Added tooltip to label value in collapsed sidebar
What does this MR do?
Adds a list of the issuables labels to a tooltip in the collapsed sidebar. Limited to 5 otherwise the list could get crazy long.
What are the relevant issue numbers?
Closes #19398 (closed)
Screenshots (if relevant)
Merge request reports
Activity
Added 15 commits:
- b979ad08...4be505bf - 14 commits from branch
master
- fa01d50d - Added tooltip to label value in collapsed sidebar
- b979ad08...4be505bf - 14 commits from branch
Reassigned to @jschatz1
Milestone changed to %8.11
@iamphill conflicts, also probably assign to Fatih or someone else since Jacob is busy :P
Added 1050 commits:
-
c0cc6766...a0788fc3 - 1049 commits from branch
master
- c7ad5e7b - Added tooltip to label value in collapsed sidebar
-
c0cc6766...a0788fc3 - 1049 commits from branch
Added 1 commit:
- 8b940c70 - Added tests
Added 1 commit:
- 8f06cfca - Added tooltip to label value in collapsed sidebar
Added 1 commit:
- 2143e2bb - Added tooltip to label value in collapsed sidebar
Reassigned to @fatihacet
Reassigned to @fatihacet
123 126 } 124 127 $value.removeAttr('style').html(template); 125 128 $sidebarCollapsedValue.text(labelCount); 129 130 if (data.labels.length) { 131 labelTooltipTitle = _.chain(data.labels) Too much stuff is going on here.
_.chain
,.map
,.compact
,.values
. I think we can make it more simpler.var labels = data.labels.map(function(label) { return label.title; }); var labelsLength = labels.length; if (labelsLength > 5) { labels = labels.slice(0, 5); labels.push('and ' + (labelsLength - 5) + ' more'); } labelTooltipTitle = labels.join(', ');
Yeah good point @fatihacet I think I was in an underscore mood when I wrote this!
Reassigned to @iamphill
Added 1 commit:
- 6e76d7ea - Made logic simpler by moving away from underscorejs
Reassigned to @fatihacet
Reassigned to @jschatz1
163 163 - Reduce size of HTML used by diff comment forms 164 164 - Protected branches have a "Developers can Merge" setting. !4892 (original implementation by Mathias Vestergaard) 165 165 - Fix user creation with stronger minimum password requirements. !4054 (nathan-pmt) 166 - Added tooltip listing label names to the labels value in the collapsed issuable sidebar 167 - Fix user creation with stronger minimum password requirements !4054 (nathan-pmt) 91 92 it 'should update the tooltip for collapsed sidebar' do 93 page.within('.block.labels') do 94 find('.edit-link').click 95 96 page.within('.dropdown-menu-labels') do 97 click_link 'a' 98 click_link 'b' 99 click_link 'c' 100 click_link 'd' 101 click_link 'e' 102 click_link 'f' 103 end 104 105 find('.edit-link').click 106 sleep 1 72 72 end 73 73 end 74 74 75 def issuable_labels_tooltip(labels) 76 max_labels = 5 77 label_size = labels.size 78 label_names = labels.each_with_index.map do |label, i| def issuable_labels_tooltip(labels, limit: 5) first, last = labels.split(limit) label_names = first.collect(&:name) label_names << "and #{last.size} more" unless last.empty? label_names.join(', ') end
Edited by Robert Speicher
73 73 end 74 74 end 75 75 76 context 'update labels', js: true do I think a JS-based feature spec that persists 6 database objects is overkill for testing this.
Create a unit test for the helper method that tests with one
build_stubbed(:label)
object, then another test case that uses two and uselimit: 2
.Edited by Robert Speicher
Reassigned to @iamphill
77 before do 78 project.team << [user, :developer] 79 visit_issue(project, issue) 80 end 81 82 context 'more than 5' do 83 before do 84 create(:label, project: project, title: 'a') 85 create(:label, project: project, title: 'b') 86 create(:label, project: project, title: 'c') 87 create(:label, project: project, title: 'd') 88 create(:label, project: project, title: 'e') 89 create(:label, project: project, title: 'f') 90 end 91 92 it 'should update the tooltip for collapsed sidebar' do Added 1035 commits:
-
6e76d7ea...2c1062f8 - 1031 commits from branch
master
- 40cd1b3e - Added tooltip to label value in collapsed sidebar
- 7de4f826 - Made logic simpler by moving away from underscorejs
- 19b90e5d - Addressed feedback
- a5ff9650 - Changed tests to use JS tests
Toggle commit list-
6e76d7ea...2c1062f8 - 1031 commits from branch
72 72 end 73 73 end 74 74 75 def issuable_labels_tooltip(labels, limit: 5) 76 first, last = labels.partition.with_index{ |_, i| i < limit } Curious why you went this way rather than
labels.split(limit)
.Edited by Robert Speicher@iamphill Wow, my fault.
split
does something completely different than I thought it did.@rspeicher haha! I tried so many different ways with
split
but thought I was missing something REALLY obviousEdited by Phil Hughes
17 17 - API: Endpoints for enabling and disabling deploy keys 18 18 - API: List access requests, request access, approve, and deny access requests to a project or a group. !4833 19 19 - Use long options for curl examples in documentation !5703 (winniehell) 20 - Added tooltip listing label names to the labels value in the collapsed issuable sidebar - spec/helpers/issuable_helper_spec.rb 0 → 100644
1 require 'spec_helper' 2 3 describe IssuablesHelper do The filename is wrong - it should be issuables_helper_spec.rb
Edited by Robert Speicher
1 .block.labels 2 .sidebar-collapsed-icon.js-sidebar-labels-tooltip 3 .title.hide-collapsed 4 %a.edit-link.pull-right{ href: "#" } 5 Edit 6 .selectbox.hide-collapsed{ style: "display: none;" } 7 .dropdown 8 %button.dropdown-menu-toggle.js-label-select.js-multiselect{"data-ability-name" => "issue", "data-field-name" => "issue[label_names][]", "data-issue-update" => "/root/test/issues/2.json", "data-labels" => "/root/test/labels.json", "data-project-id" => "12", "data-show-any" => "true", "data-show-no" => "true", "data-toggle" => "dropdown", :type => "button"} Added 250 commits:
Toggle commit listReassigned to @rspeicher
mentioned in commit 4ecfd74f
mentioned in commit 930b1e4e
Mentioned in commit 4ecfd74f