Review Composer: Sidebar

Review Request #10225 — Created Oct. 11, 2018 and updated

Information

Review Board
master
3de8456...

Reviewers

The Review composer is the redesign of the review dialog to improve user
experience. The Review composer: sidebar serves as the sidebar for the
review composer.

The sidebar contains a button to create new general comments to replace the
add general comments button in the review dialog. A rendered list of comments
which will serve as a table of contents of reviews left in the review and a
tips and documentation section.

Added new JS unit tests to test functionality added. All JS tests pass.


Description From Last Updated

Since we're doing _super.remove below we don't need this.

brenniebrennie

Doing render() here will break things.

brenniebrennie

This should be this.$el.append($generalCommentButton).

brenniebrennie

Col: 15 'commentList' is defined but never used.

reviewbotreviewbot

Col: 15 'tipsSection' is defined but never used.

reviewbotreviewbot

Col: 69 Missing semicolon.

reviewbotreviewbot

You don't need this becuase of the _super call below.

brenniebrennie

This should be in its own file. You will have to add the new file to staticbundles.py.

brenniebrennie

Col: 29 Missing semicolon.

reviewbotreviewbot

Col: 63 Missing semicolon.

reviewbotreviewbot

Col: 11 Missing semicolon.

reviewbotreviewbot

Col: 35 Missing semicolon.

reviewbotreviewbot

Alphabetize.

brenniebrennie

Alphabetize.

brenniebrennie

Alphabetize.

brenniebrennie

space between selector and {

brenniebrennie

These are not very semantic styles. Their names indicate what they do, not why they do it or what they …

brenniebrennie

Space between selector and {

brenniebrennie

This should return this.

brenniebrennie

Col: 7 'DiffCommentView' is defined but never used.

reviewbotreviewbot

Same comment here re: inline styles.

brenniebrennie

Col: 7 'FileAttachmentCommentView' is defined but never used.

reviewbotreviewbot

Col: 7 'GeneralCommentView' is defined but never used.

reviewbotreviewbot

Col: 7 'ScreenshotCommentView' is defined but never used.

reviewbotreviewbot

We try to avoid inline style as much as possible. Is there a reason this can't be added to a …

brenniebrennie

Col: 7 'HeaderFooterCommentView' is defined but never used.

reviewbotreviewbot

If it is intentionally a no-op, you do not need to define it since the parent already does. Same elsewhere.

brenniebrennie

Col: 7 'ReviewOutline' is defined but never used.

reviewbotreviewbot

Col: 3 Missing semicolon.

reviewbotreviewbot

Same comment here re: inline styles.

brenniebrennie

Our templates are indented a single space, not four.

brenniebrennie

Space after ). Same elsewhere

brenniebrennie

This is also using inline style.

brenniebrennie

How about: this.listenTo( reviewDialogView._fileAttachmentCommentsCollection, 'add', comment => this._renderComment($reviewOutline, comment));

brenniebrennie

Since you're not doing anything with tipsSection, you can just do: this.$('#sidebar-tips-section') .append($(this.tipsTemplate({ ... })));

brenniebrennie

As a convention, we name jQuery objects $foo.

brenniebrennie

This should have $() wrapped around the template to convert create the DOM nodes to attach to the tree.

brenniebrennie

Since you aren't doing anything with $buttons afterwards, you can just do: this.$('#sidebar-tips-button') .append(...);

brenniebrennie

Our templates are indented a single space, not four.

brenniebrennie

Col: 7 'DiffCommentView' is defined but never used.

reviewbotreviewbot

Col: 7 'FileAttachmentCommentView' is defined but never used.

reviewbotreviewbot

Col: 7 'GeneralCommentView' is defined but never used.

reviewbotreviewbot

Col: 7 'ScreenshotCommentView' is defined but never used.

reviewbotreviewbot

Col: 7 'HeaderFooterCommentView' is defined but never used.

reviewbotreviewbot

Col: 7 'ReviewOutline' is defined but never used.

reviewbotreviewbot

Col: 3 Missing semicolon.

reviewbotreviewbot

Col: 7 'HeaderFooterCommentView' is defined but never used.

reviewbotreviewbot

Col: 58 Missing semicolon.

reviewbotreviewbot

Col: 58 Missing semicolon.

reviewbotreviewbot

Col: 58 Missing semicolon.

reviewbotreviewbot

Col: 58 Missing semicolon.

reviewbotreviewbot

Col: 7 'HeaderFooterCommentView' is defined but never used.

reviewbotreviewbot

Space after selector and before opening brace.

brenniebrennie

Is text HTML-escaped? Or do we know its safe HTML? If not we need to use <%- text %>.

brenniebrennie

<%- text %>

brenniebrennie

Same comment about <%= foo %> vs <%- foo %>.

brenniebrennie

<br> and it should be on the next line.

brenniebrennie

<%- lines %>

brenniebrennie

Unnecessary -- this is the default impl.

brenniebrennie

Here too

brenniebrennie

Space between ) and {

brenniebrennie

Should be indented one space.

brenniebrennie

<%- text %>

brenniebrennie

<br> on next line.

brenniebrennie

Unnecessary.

brenniebrennie

Same comment here vs <%= vs <%-.

brenniebrennie

<%- text %>

brenniebrennie

<br> on next line.

brenniebrennie

Unnecessary.

brenniebrennie

This has to be marked for translation with gettext(). Replace this with a template var and pass in the result …

brenniebrennie

This has to be marked for translation with gettext(). Replace this with a template var and pass in the result …

brenniebrennie

Same comment here about <%= vs <%-.

brenniebrennie

We should avoid <b> in favour of <strong>, which is more semantic (see: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/strong) However, since this is a title, …

brenniebrennie

I don't know that we need an id selector here. class="tip-text" would be fine.

brenniebrennie

gettext()

brenniebrennie

Single quotes for strings

brenniebrennie

Text needs to be marked for translation with gettext, e.g. $('<span class="fa fa-plus"></span>') .text(gettext('Add a general comment'))

brenniebrennie

If you are going to use this for a multi-line string, use dedent, e.g. $(dedent` <span class="left-button fa fa-caret-left"></span> <span …

brenniebrennie

Undo

brenniebrennie

Comments should end in a period. However, I think the behaviour can be inferred from the name.

brenniebrennie

Comments should end in a period. Again, I don't know that this is necessary.

brenniebrennie

This file needs to be wrapped in an IIFE to not pollute global scope, e.g. (function() { const BaseCommentView = …

brenniebrennie

Undo

brenniebrennie

.sidebar-tips-button before .sidebar-tips-section.

brenniebrennie

No blank line here.

brenniebrennie

No blank line here.

brenniebrennie

Move this to right before the block it is defined in.

brenniebrennie

No blank line here.

brenniebrennie

This does not interpolate variables, so it can just be a string literal.

brenniebrennie

Instead of passing tips and current into the template, you can pass tip as tips[current] and use that instead.

brenniebrennie

There is an extra ", right before class

brenniebrennie

Needs a docstring.

brenniebrennie

Col: 22 Missing semicolon.

reviewbotreviewbot

Col: 5 'emptyDiffCommentsPayload' is defined but never used.

reviewbotreviewbot

Col: 5 'emptyFileAttachmentCommentsPayload' is defined but never used.

reviewbotreviewbot

Col: 5 'emptyGeneralCommentsPayload' is defined but never used.

reviewbotreviewbot

Col: 5 'emptyScreenshotCommentsPayload' is defined but never used.

reviewbotreviewbot

Col: 5 'diffCommentPayload' is defined but never used.

reviewbotreviewbot

Col: 5 'fileAttachmentCommentPayload' is defined but never used.

reviewbotreviewbot

Col: 5 'generalCommentPayload' is defined but never used.

reviewbotreviewbot

Col: 5 'screenshotCommentPayload' is defined but never used.

reviewbotreviewbot

Col: 5 'origGeneralCommentsEnabled' is defined but never used.

reviewbotreviewbot

Col: 5 'dlg' is defined but never used.

reviewbotreviewbot

Col: 10 'createReviewDialog' is defined but never used.

reviewbotreviewbot

Col: 21 'ajaxData' is defined but never used.

reviewbotreviewbot

Col: 96 Missing semicolon.

reviewbotreviewbot

Col: 70 Missing semicolon.

reviewbotreviewbot

Col: 41 Expected '===' and instead saw '=='.

reviewbotreviewbot

Col: 56 Missing semicolon.

reviewbotreviewbot

Col: 70 Missing semicolon.

reviewbotreviewbot

W503 line break before binary operator

reviewbotreviewbot

W503 line break before binary operator

reviewbotreviewbot

W503 line break before binary operator

reviewbotreviewbot
bolariinwa
bolariinwa
bolariinwa
bolariinwa
brennie
  1. 
      
  2. Show all issues

    Since we're doing _super.remove below we don't need this.

  3. Show all issues

    Doing render() here will break things.

  4. Show all issues

    This should be this.$el.append($generalCommentButton).

  5. 
      
bolariinwa
bolariinwa
bolariinwa
bolariinwa
bolariinwa
Review request changed
Commit:
41a14e598e91c79ec3df033cec9e10579d6492cd
a0cf5d26ce9ff762da87090594209b980d7b7b3f
Added Files:

Checks run (1 failed, 1 succeeded)

flake8 passed.
JSHint failed.

JSHint

bolariinwa
bolariinwa
bolariinwa
brennie
  1. 
      
  2. Show all issues

    You don't need this becuase of the _super call below.

  3. Show all issues

    This should be in its own file. You will have to add the new file to staticbundles.py.

  4. 
      
bolariinwa
bolariinwa
Review request changed
Commit:
d2860d4ba7246d93d090097f03c115d92c81d223
005fb9fe095141d4cdfa032c45c6f020239b91f3

Checks run (1 failed, 1 succeeded)

flake8 passed.
JSHint failed.

JSHint

bolariinwa
bolariinwa
bolariinwa
bolariinwa
bolariinwa
Review request changed
Commit:
a0f89f47f545f4689598f9498b6101eb04ed65c7
08873e805748afae0a5de767eb141457f44130d1

Checks run (1 failed, 1 succeeded)

flake8 passed.
JSHint failed.

JSHint

bolariinwa
bolariinwa
bolariinwa
Review request changed
Commit:
9163c543d5460ae63ea4e281eeaf941b0aabea52
5bd40b0a9065829fa24a56520bec136b18c0170d

Checks run (1 failed, 1 succeeded)

flake8 passed.
JSHint failed.

JSHint

brennie
  1. 
      
  2. reviewboard/static/rb/css/pages/reviews.less (Diff revision 22)
     
     
     
     
    Show all issues

    Alphabetize.

  3. reviewboard/static/rb/css/pages/reviews.less (Diff revision 22)
     
     
     
     
     
    Show all issues

    Alphabetize.

  4. reviewboard/static/rb/css/pages/reviews.less (Diff revision 22)
     
     
     
     
     
    Show all issues

    Alphabetize.

  5. Show all issues

    space between selector and {

  6. reviewboard/static/rb/css/pages/reviews.less (Diff revision 22)
     
     
     
     
     
     
     
     
    Show all issues

    These are not very semantic styles. Their names indicate what they do, not why they do it or what they are styling. Can you update these with more descriptive names?

    e.g. why do we want .color ? Is it a header? If so then name it .header.

  7. Show all issues

    Space between selector and {

  8. Show all issues

    This should return this.

  9. Show all issues

    Same comment here re: inline styles.

  10. Show all issues

    We try to avoid inline style as much as possible. Is there a reason this can't be added to a .sidebar-general-comments rule in the CSS?

    1. The styles can be placed under a class. I used the inline style so I could quickly check the effect of a style.

  11. Show all issues

    If it is intentionally a no-op, you do not need to define it since the parent already does. Same elsewhere.

  12. Show all issues

    Same comment here re: inline styles.

  13. reviewboard/static/rb/js/views/reviewComposerSidebarView.es6.js (Diff revision 22)
     
     
     
     
     
     
     
     
     
     
     
    Show all issues

    Our templates are indented a single space, not four.

  14. Show all issues

    Space after ). Same elsewhere

  15. Show all issues

    This is also using inline style.

  16. Show all issues

    How about:

            this.listenTo(
                reviewDialogView._fileAttachmentCommentsCollection,
                'add',
                comment => this._renderComment($reviewOutline, comment));
    
  17. Show all issues

    Since you're not doing anything with tipsSection, you can just do:

    this.$('#sidebar-tips-section')
        .append($(this.tipsTemplate({
            ...
        })));
    
  18. Show all issues

    As a convention, we name jQuery objects $foo.

  19. Show all issues

    This should have $() wrapped around the template to convert create the DOM nodes to attach to the tree.

  20. Show all issues

    Since you aren't doing anything with $buttons afterwards, you can just do:

    this.$('#sidebar-tips-button')
        .append(...);
    
  21. reviewboard/static/rb/js/views/reviewDialogView.es6.js (Diff revision 22)
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
    Show all issues

    Our templates are indented a single space, not four.

  22. 
      
bolariinwa
Review request changed
Commit:
5bd40b0a9065829fa24a56520bec136b18c0170d
2025c05e3ade047a42d488dcd58178317518edd6

Checks run (1 failed, 1 succeeded)

flake8 passed.
JSHint failed.

JSHint

bolariinwa
Review request changed
Commit:
2025c05e3ade047a42d488dcd58178317518edd6
bb13afeef9e9fe4a737a1e47bbdcfa85d3b4a4ff

Checks run (1 failed, 1 succeeded)

flake8 passed.
JSHint failed.

JSHint

bolariinwa
Review request changed
Commit:
bb13afeef9e9fe4a737a1e47bbdcfa85d3b4a4ff
fb26d33b9609a3acb5b3f84c06e649529e578595

Checks run (1 failed, 1 succeeded)

flake8 passed.
JSHint failed.

JSHint

bolariinwa
bolariinwa
bolariinwa
brennie
  1. 
      
  2. Show all issues

    Space after selector and before opening brace.

  3. Show all issues

    Is text HTML-escaped? Or do we know its safe HTML? If not we need to use <%- text %>.

  4. Show all issues

    Same comment about <%= foo %> vs <%- foo %>.

  5. Show all issues

    Here too

  6. Show all issues

    Space between ) and {

  7. Show all issues

    Should be indented one space.

  8. Show all issues

    Same comment here vs <%= vs <%-.

  9. Show all issues

    This has to be marked for translation with gettext(). Replace this with a template var and pass in the result of gettext() when using the template.

  10. Show all issues

    This has to be marked for translation with gettext(). Replace this with a template var and pass in the result of gettext() when using the template.

  11. Show all issues

    Same comment here about <%= vs <%-.

  12. Show all issues

    Single quotes for strings

  13. Show all issues

    Text needs to be marked for translation with gettext, e.g.

    $('<span class="fa fa-plus"></span>')
        .text(gettext('Add a general comment'))
    
  14. Show all issues

    If you are going to use this for a multi-line string, use dedent, e.g.

    $(dedent`
        <span class="left-button fa fa-caret-left"></span>
        <span class="right-button ra fa-caret-right"></span>
    `);
    
  15. 
      
bolariinwa
brennie
  1. 
      
  2. Show all issues

    <%- text %>

  3. Show all issues

    <br> and it should be on the next line.

  4. Show all issues

    <%- lines %>

  5. Show all issues

    Unnecessary -- this is the default impl.

  6. Show all issues

    <%- text %>

  7. Show all issues

    <br> on next line.

    1. Should <br> be on it's own line

  8. Show all issues

    Unnecessary.

  9. Show all issues

    <%- text %>

  10. Show all issues

    <br> on next line.

  11. Show all issues

    Unnecessary.

  12. Show all issues

    We should avoid <b> in favour of <strong>, which is more semantic (see: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/strong)

    However, since this is a title, it should be a <h1>, <h2>, etc. element.

    Also this needs to be gettext()-ed.

  13. Show all issues

    I don't know that we need an id selector here. class="tip-text" would be fine.

  14. Show all issues

    gettext()

  15. 
      
bolariinwa
bolariinwa
bolariinwa
bolariinwa
brennie
  1. 
      
  2. reviewboard/static/rb/css/pages/reviews.less (Diff revision 33)
     
     
     
    Show all issues

    Undo

  3. Show all issues

    Comments should end in a period.

    However, I think the behaviour can be inferred from the name.

  4. Show all issues

    Comments should end in a period.

    Again, I don't know that this is necessary.

  5. Show all issues

    This file needs to be wrapped in an IIFE to not pollute global scope, e.g.

    (function() {
    
    
    const BaseCommentView = Backbone.View.extend({...});
    
    // ..
    
    RB.ReviewComposerSidebar = Backbone.View.extend({...});
    
    })();
    

    This keeps all the variables in a function scope, so they don't escape into global scope (i.e, onto window).

  6. 
      
bolariinwa
brennie
  1. 
      
  2. Show all issues

    Undo

  3. reviewboard/static/rb/css/pages/reviews.less (Diff revision 34)
     
     
     
     
     
     
     
     
     
     
     
     
     
    Show all issues

    .sidebar-tips-button before .sidebar-tips-section.

  4. Show all issues

    No blank line here.

  5. Show all issues

    No blank line here.

  6. Show all issues

    Move this to right before the block it is defined in.

  7. Show all issues

    No blank line here.

  8. Show all issues

    This does not interpolate variables, so it can just be a string literal.

    1. when you say string literal, do you mean just wrapping it in a ''

  9. Show all issues

    Instead of passing tips and current into the template, you can pass tip as tips[current] and use that instead.

  10. Show all issues

    There is an extra ", right before class

  11. Show all issues

    Needs a docstring.

  12. 
      
bolariinwa
bolariinwa
Review request changed
Commit:
8118bee82b4b465af62bc01813083895aec9c4b3
427865f519bf01cb26a6f4798d09902130f2b668

Checks run (1 failed, 1 succeeded)

flake8 passed.
JSHint failed.

JSHint

bolariinwa
bolariinwa
bolariinwa
bolariinwa
Review request changed
Commit:
0e9c5f9f93568b07a1f162a09fa661b8eab84e3f
30d77b2d4dd259efcbbaa427319c4637825be4dc

Checks run (1 failed, 1 succeeded)

flake8 passed.
JSHint failed.

JSHint

bolariinwa
bolariinwa
bolariinwa
bolariinwa
Review request changed
Commit:
c2a3043f849846400f9cd4d9a59a56ed18c0cd0c
9c8a09b1414693b7c2a17bdf1d649fd205723207

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

bolariinwa
bolariinwa
Review request changed