Added tooltips for the graphs that represent diff change summaries in the diff viewer.

Review Request #7880 — Created Jan. 16, 2016 and submitted

Information

Review Board
release-2.0.x

Reviewers

Right now, the diff viewer shows graphs beside each modified file to show whether or not files were added/deleted, how many lines were inserted/changed/deleted, or if there was an error loading the diff information for a given file.

Users were able to depict what the graphs typically mean, however it was desired that tooltips were added for each of the icons to give a detailed description of the change summary for that file.

In my local environment I posted reviews with every type of modification to a file (as well as an erroneous diff of a file) to ensure tooltip was both correct and displaying properly.

Description From Last Updated

We already query this element once. We don't want to do it again, so let's pull it out into a …

chipx86chipx86

Make sure all new variables are declared with var at the top. Also, we only ever want one var statement …

chipx86chipx86

We should wrap this for translation, and use single quotes: tooltip = gettext('New file');

daviddavid

We should wrap this for translation, and use single quotes: tooltip = gettext('Deleted file');

daviddavid

There's not a ton of reason to have this be an "else if" -- we can just have this be …

daviddavid

The translation utilities provide nice pluralization and formatting capabilities: tooltip += interpolate( ngettext('%s new line', '%s new lines', numInserts), [numInserts]) …

daviddavid

There should be blank lines between blocks (like if statements, for loops, etc.) and other code. So, blank line here, …

chipx86chipx86

Alignment errors.

chipx86chipx86

Since we're using jquery, we can use the .attr method: $item.find('.diff-file-icon').attr('title', tooltip); We probably also don't need to gate it …

daviddavid

We're querying the diff icon twice here as well. These sort of lookups are expensive, and we want to be …

chipx86chipx86

We should call this variable $fileIcon to indicate that it's a jquery.

daviddavid

Trailing whitespace, and since we're indenting the second argument, let's put the first on its own line too: $fileIcon.attr( 'title', …

daviddavid

Call this $fileIcon.

daviddavid

How about tooltipParts instead of mods?

daviddavid

Technically this should be %d instead of %s.

brenniebrennie

%d

brenniebrennie

%d

brenniebrennie

Trailing whitespace.

daviddavid

Trailing whitespace.

daviddavid
reviewbot
  1. Tool: Pyflakes
    Ignored Files:
        reviewboard/static/rb/js/diffviewer/views/diffFileIndexView.js
    
    
    
    Tool: PEP8 Style Checker
    Ignored Files:
        reviewboard/static/rb/js/diffviewer/views/diffFileIndexView.js
    
    
  2. 
      
david
  1. 
      
  2. Show all issues

    We should wrap this for translation, and use single quotes:

    tooltip = gettext('New file');
    
  3. Show all issues

    We should wrap this for translation, and use single quotes:

    tooltip = gettext('Deleted file');
    
  4. Show all issues

    There's not a ton of reason to have this be an "else if" -- we can just have this be an "else" clause and let the inner conditionals do this work.

  5. reviewboard/static/rb/js/diffviewer/views/diffFileIndexView.js (Diff revision 1)
     
     
     
     
     
     
     
     
     
     
     
     
    Show all issues

    The translation utilities provide nice pluralization and formatting capabilities:

    tooltip += interpolate(
        ngettext('%s new line', '%s new lines', numInserts),
        [numInserts])
    

    It might also be nice to do this by creating an array of parts and using ', '.join(parts).

    There's also some trailing whitespace introduced in here.

  6. Show all issues

    Since we're using jquery, we can use the .attr method:

    $item.find('.diff-file-icon').attr('title', tooltip);
    

    We probably also don't need to gate it in the if statement because if the tooltip is empty, we'll just set the title to an empty string.

  7. 
      
chipx86
  1. 
      
  2. Show all issues

    We already query this element once. We don't want to do it again, so let's pull it out into a variable that both statements can use.

    We also need to localize the text by calling gettext('...').

    Along with this, we want more user-friendly error messages. "There was an error loading the diff. See the details below." sort of a thing.

  3. Show all issues

    Make sure all new variables are declared with var at the top. Also, we only ever want one var statement per function. See how we do it in other blocks of code.

  4. Show all issues

    There should be blank lines between blocks (like if statements, for loops, etc.) and other code. So, blank line here, and same with ones below.

  5. Show all issues

    Alignment errors.

    1. I'm not sure what you mean, do you mean that 'numReplaces + " line"' should be on a new line, or did I do the new line improperly with '((numReplaces > 1)...'?

    2. After quick discussion with David, the formatting issues were fixed with the new solution.

  6. Show all issues

    We're querying the diff icon twice here as well. These sort of lookups are expensive, and we want to be as careful as possible to not do them more than once.

  7. 
      
david
  1. Also, please put the bug number into the "bugs" field.

  2. 
      
EV
EV
EV
reviewbot
  1. Tool: Pyflakes
    Ignored Files:
        reviewboard/static/rb/js/diffviewer/views/diffFileIndexView.js
    
    
    
    Tool: PEP8 Style Checker
    Ignored Files:
        reviewboard/static/rb/js/diffviewer/views/diffFileIndexView.js
    
    
  2. 
      
david
  1. 
      
  2. Show all issues

    We should call this variable $fileIcon to indicate that it's a jquery.

  3. Show all issues

    Trailing whitespace, and since we're indenting the second argument, let's put the first on its own line too:

    $fileIcon.attr(
        'title',
        gettext('There was an error loading this diff. See the details below'));
    
  4. Show all issues

    Call this $fileIcon.

  5. Show all issues

    How about tooltipParts instead of mods?

  6. Show all issues

    Trailing whitespace.

  7. Show all issues

    Trailing whitespace.

  8. 
      
brennie
  1. 
      
  2. Show all issues

    Technically this should be %d instead of %s.

    1. After some testing and googling I don't think ngettext() supports anything but %s.

    2. Yeah, this is javascript, and the gettext implementations there are pretty minimal.

    3. So keep it the way it is?

    4. Yep. Feel free to drop the issue(s).

  3. Show all issues

    %d

  4. Show all issues

    %d

  5. 
      
EV
reviewbot
  1. Tool: PEP8 Style Checker
    Ignored Files:
        reviewboard/static/rb/js/diffviewer/views/diffFileIndexView.js
    
    
    
    Tool: Pyflakes
    Ignored Files:
        reviewboard/static/rb/js/diffviewer/views/diffFileIndexView.js
    
    
  2. 
      
david
  1. Ship It!
  2. 
      
EV
Review request changed
Status:
Completed
Change Summary:
Pushed to release-2.0.x (ceb2b88)