Skip to content
Snippets Groups Projects

Added tooltip to label value in collapsed sidebar

Merged Phil Hughes requested to merge label-tooltip-sidebar-collapsed into master
10 unresolved threads

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)

Screen_Shot_2016-07-13_at_11.52.43

Screen_Shot_2016-07-13_at_11.52.50

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
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(', ');
  • Author Maintainer

    Yeah good point @fatihacet I think I was in an underscore mood when I wrote this!

  • Please register or sign in to reply
  • Phil Hughes Added 1 commit:

    Added 1 commit:

    • 6e76d7ea - Made logic simpler by moving away from underscorejs
  • Reassigned to @fatihacet

  • 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|
  • 73 73 end
    74 74 end
    75 75
    76 context 'update labels', js: true do
  • 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
  • Phil Hughes Added 1035 commits:

    Added 1035 commits:

  • 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 }
  • 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
  • 1 require 'spec_helper'
    2
    3 describe IssuablesHelper do
  • 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"}
    • It's Haml so you can DRY up the attribute hash a bit:

      %button.dropdown-menu-toggle.js-label-select.js-multiselect{type: 'button', data: {ability_name: 'issue', field_name: 'issue[label_names][]', issue_update: '/root/test/issues/2.json', etc: '...'}}
    • Please register or sign in to reply
  • Phil Hughes Added 250 commits:

    Added 250 commits:

  • Reassigned to @rspeicher

  • Robert Speicher Added ~149423 label

    Added ~149423 label

  • Robert Speicher Status changed to merged

    Status changed to merged

  • Robert Speicher mentioned in commit 4ecfd74f

    mentioned in commit 4ecfd74f

  • Picked into 8-11-stable, will go into 8.11.0-rc6.

  • Rubén Dávila Removed ~149423 label

    Removed ~149423 label

  • Robert Speicher mentioned in commit 930b1e4e

    mentioned in commit 930b1e4e

  • Robert Speicher Mentioned in commit 4ecfd74f

    Mentioned in commit 4ecfd74f

  • Please register or sign in to reply
    Loading