Created a keyboard shortcut to add comments to a diff

Review Request #5442 — Created Feb. 8, 2014 and submitted

edwinzg
Review Board
master
44
reviewboard

Fixes issue #44

Created a keyboard shortcut (r, R) to add comments to a block of a diff. Also saved the chunk that is highlighted when navigating the diff using keyboard shortcuts to use for detecting where to put the comments.

Navigated through a diff using keyboard shortcuts and pressed all three of the keyboard shortcuts to bring up a comment, which bring up the comment box.

If no block is selected, nothing happens when the shortcuts are pressed.

Tested on multi and single line blocks.

Tested on a diff with two files.

Description From Last Updated

The last item in javascript objects or arrays shouldn't have a comma after it (IE will fail to parse it).

daviddavid

Please remove "This" (have it just start with "Creates ...") and end the sentence with a period.

daviddavid

Please wrap this line to 80 characters. You should be able to just put the "endNode" on the next line, …

daviddavid

Last item shouldn't have a comma after it.

daviddavid

_chunk is kind of an ambiguous name. How about _highlightedChunk?

daviddavid

We should reset this._chunk here, since the files are getting reloaded/changed.

daviddavid

Add a space between the () and the {.

daviddavid

All of these should be prefixed with var. We also try to have a single var statement, to fit in …

daviddavid

var definitions should be the first statement in the function.

daviddavid

Please wrap this to 80 columns.

daviddavid

Same comment as the similar code in diffReviewableView.js.

daviddavid

Hmm. How about just using 'c' instead of both 'r' and 'c'?

daviddavid

The lines starting with '.' should be indented 4 spaces instead of 8.

daviddavid

The line starting with '.' should be indented 4 spaces instead of 8.

daviddavid

Can you capitalize the C in "chunk" for this variable name?

daviddavid

Hmm. I just realized that this is calling createComment for every file in the diff, which doesn't seem right. Did …

daviddavid
ED
ED
ED
david
  1. 
      
  2. The last item in javascript objects or arrays shouldn't have a comma after it (IE will fail to parse it).

  3. Please remove "This" (have it just start with "Creates ...") and end the sentence with a period.

  4. Please wrap this line to 80 characters. You should be able to just put the "endNode" on the next line, indented to line up with "beginLineNum" above it.

  5. Last item shouldn't have a comma after it.

  6. _chunk is kind of an ambiguous name. How about _highlightedChunk?

  7. We should reset this._chunk here, since the files are getting reloaded/changed.

  8. Add a space between the () and the {.

  9. reviewboard/static/rb/js/pages/views/diffViewerPageView.js (Diff revision 1)
     
     
     
     
     
     
     

    All of these should be prefixed with var. We also try to have a single var statement, to fit in with linting tools like jshint.

    We also should make sure that lines wrap to 80 columns.

    So this should look something like:

    var chunkID = this._chunk[0].id,
        lineElements = document
            .getElementById(chunkId)
            .getElementsByTagName('tr'),
        beginLineNum = ...
    
  10. var definitions should be the first statement in the function.

  11. Please wrap this to 80 columns.

  12. Same comment as the similar code in diffReviewableView.js.

  13. 
      
ED
david
  1. Can you go through the old comments and click "Fixed" on all the opened issues that you've fixed?

    1. Oops, nevermind, had an out-of-date dashboard view.

  2. Hmm. How about just using 'c' instead of both 'r' and 'c'?

    1. c was being used for _selectnextComment

    2. Ahh. I'm tempted to say that we shouldn't create confusion between 'c' and 'C' then, and just use 'rR'

    3. That makes sense

  3. The lines starting with '.' should be indented 4 spaces instead of 8.

  4. The line starting with '.' should be indented 4 spaces instead of 8.

  5. 
      
ED
david
  1. 
      
  2. Can you capitalize the C in "chunk" for this variable name?

  3. 
      
ED
ED
david
  1. 
      
  2. Hmm. I just realized that this is calling createComment for every file in the diff, which doesn't seem right. Did you try this with a diff that contained multiple files?

    Perhaps we should do something like conditionalize this on $.contains(diffReviewableView.el, beginNode) ?

  3. 
      
ED
ED
ED
david
  1. Ship It!

  2. 
      
ED
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to master (149ba95). Thanks!
Loading...