Refine general comments support

Review Request #7764 — Created Nov. 9, 2015 and submitted

Information

Review Board
master

Reviewers

This patch adds the finishing touches to support for general comments
-- that is, comments unattached from a file attachment, diff, etc. --
on reviews.

A button has been added to the review dialog to add a general comment.
These comments can be deleted with the delete comment icon that is
present with all other comments. JavaScript unit tests have been added
to test the deletion functionality.

A button has been added to the draft review banner to add a general
comment. This comment can only be deleted from within the review
dialog.

The include_text_types fields have been removed from the
BaseCommentResource because it requires special parsing. They were
added, but their type was incorrect. The field expects a
comma-separated list of the text types, not a single text type. This
broke the ability to comment has so has been reverted. A unit test has
been added to ensure this behaviour does not regress.

Calls to _no_access_error in the ReviewGeneralCommentResource and
ReviewReplyGeneralCommentResource have been corrected to
get_no_access_error, as the former method does not exist.

  • Ran unit tests.
  • Ran JS tests.
  • Added comments from both the banner and the dialog.
  • Deleted comments from the dialog.

Description From Last Updated

Shouldn't this pass in RB.UserSession.instance.get('commentsOpenAnIssue'));?

daviddavid

This should also indent 4 more spaces.

daviddavid

Instead of using string concatenation, how about: $('<input type="button">').val(gettext('Cancel')), $('<input type="button">') .val(gettext('Discard')) .click(...)

daviddavid

Why this change?

daviddavid

No trailing commas in js (at least until we're totally ready to break IE8 with impunity).

daviddavid

These should be in the form of <input type="button"/>, for consistency.

chipx86chipx86

Blank line before this.

chipx86chipx86

It's not super clear from the change, so why is this special-cased?

chipx86chipx86

Missing "Returns".

chipx86chipx86

Let's leave the /> in. While not technically needed for HTML, it's something we do to help with readability a …

chipx86chipx86

We don't have any other resources with these explicitly listed, but ideally, we should. We should have it for every …

chipx86chipx86

You need to handle general_comments here, too.

daviddavid

serailize?

daviddavid
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        reviewboard/webapi/resources/base_comment.py
        reviewboard/webapi/tests/mixins_comment.py
        reviewboard/webapi/mixins.py
        reviewboard/webapi/resources/review_general_comment.py
        reviewboard/webapi/resources/review_reply_general_comment.py
    
    Ignored Files:
        reviewboard/static/rb/js/views/draftReviewBannerView.js
        reviewboard/static/rb/js/views/tests/reviewDialogViewTests.js
        reviewboard/static/rb/css/common.less
        reviewboard/static/rb/js/views/reviewDialogView.js
        reviewboard/templates/reviews/reviewable_base.html
        reviewboard/static/rb/js/pages/views/reviewablePageView.js
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/webapi/resources/base_comment.py
        reviewboard/webapi/tests/mixins_comment.py
        reviewboard/webapi/mixins.py
        reviewboard/webapi/resources/review_general_comment.py
        reviewboard/webapi/resources/review_reply_general_comment.py
    
    Ignored Files:
        reviewboard/static/rb/js/views/draftReviewBannerView.js
        reviewboard/static/rb/js/views/tests/reviewDialogViewTests.js
        reviewboard/static/rb/css/common.less
        reviewboard/static/rb/js/views/reviewDialogView.js
        reviewboard/templates/reviews/reviewable_base.html
        reviewboard/static/rb/js/pages/views/reviewablePageView.js
    
    
  2. 
      
brennie
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        reviewboard/webapi/resources/base_comment.py
        reviewboard/webapi/tests/mixins_comment.py
        reviewboard/webapi/mixins.py
        reviewboard/webapi/resources/review_general_comment.py
        reviewboard/webapi/resources/review_reply_general_comment.py
    
    Ignored Files:
        reviewboard/static/rb/js/views/draftReviewBannerView.js
        reviewboard/static/rb/js/views/tests/reviewDialogViewTests.js
        reviewboard/static/rb/css/common.less
        reviewboard/static/rb/js/pages/views/reviewablePageView.js
        reviewboard/static/rb/js/views/reviewDialogView.js
        reviewboard/templates/reviews/reviewable_base.html
        reviewboard/static/rb/js/resources/models/reviewModel.js
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/webapi/resources/base_comment.py
        reviewboard/webapi/tests/mixins_comment.py
        reviewboard/webapi/mixins.py
        reviewboard/webapi/resources/review_general_comment.py
        reviewboard/webapi/resources/review_reply_general_comment.py
    
    Ignored Files:
        reviewboard/static/rb/js/views/draftReviewBannerView.js
        reviewboard/static/rb/js/views/tests/reviewDialogViewTests.js
        reviewboard/static/rb/css/common.less
        reviewboard/static/rb/js/pages/views/reviewablePageView.js
        reviewboard/static/rb/js/views/reviewDialogView.js
        reviewboard/templates/reviews/reviewable_base.html
        reviewboard/static/rb/js/resources/models/reviewModel.js
    
    
  2. 
      
david
  1. Given that we have "Add Comment" in the review request actions, I don't think we also need it in the draft banner.

    The text type changes scare me--please have Christian give that a thorough review.

    1. The text type changes are reverting stuff that Yanija did.

  2. Show all issues

    Shouldn't this pass in RB.UserSession.instance.get('commentsOpenAnIssue'));?

  3. Show all issues

    This should also indent 4 more spaces.

  4. 
      
brennie
reviewbot
  1. Tool: PEP8 Style Checker
    Ignored Files:
        reviewboard/static/rb/js/views/draftReviewBannerView.js
        reviewboard/static/rb/js/views/tests/reviewDialogViewTests.js
        reviewboard/static/rb/css/common.less
        reviewboard/static/rb/js/pages/views/reviewablePageView.js
        reviewboard/static/rb/js/views/reviewDialogView.js
        reviewboard/templates/reviews/reviewable_base.html
        reviewboard/static/rb/js/resources/models/reviewModel.js
    
    
    
    Tool: Pyflakes
    Ignored Files:
        reviewboard/static/rb/js/views/draftReviewBannerView.js
        reviewboard/static/rb/js/views/tests/reviewDialogViewTests.js
        reviewboard/static/rb/css/common.less
        reviewboard/static/rb/js/pages/views/reviewablePageView.js
        reviewboard/static/rb/js/views/reviewDialogView.js
        reviewboard/templates/reviews/reviewable_base.html
        reviewboard/static/rb/js/resources/models/reviewModel.js
    
    
  2. 
      
david
  1. 
      
  2. Show all issues

    Instead of using string concatenation, how about:

    $('<input type="button">').val(gettext('Cancel')),
    $('<input type="button">')
        .val(gettext('Discard'))
        .click(...)
    
  3. Show all issues

    Why this change?

    1. <input> tags don't need to be self-closing. I originally had added a button here for adding a comment.

      I can undo this if you wish.

  4. 
      
brennie
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        reviewboard/webapi/resources/base_comment.py
        reviewboard/webapi/tests/mixins_comment.py
        reviewboard/webapi/mixins.py
        reviewboard/webapi/resources/review_general_comment.py
        reviewboard/webapi/resources/review_reply_general_comment.py
    
    Ignored Files:
        reviewboard/static/rb/js/views/draftReviewBannerView.js
        reviewboard/static/rb/js/views/tests/reviewDialogViewTests.js
        reviewboard/static/rb/css/common.less
        reviewboard/static/rb/js/pages/views/reviewablePageView.js
        reviewboard/static/rb/js/views/reviewDialogView.js
        reviewboard/templates/reviews/reviewable_base.html
        reviewboard/static/rb/js/resources/models/reviewModel.js
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/webapi/resources/base_comment.py
        reviewboard/webapi/tests/mixins_comment.py
        reviewboard/webapi/mixins.py
        reviewboard/webapi/resources/review_general_comment.py
        reviewboard/webapi/resources/review_reply_general_comment.py
    
    Ignored Files:
        reviewboard/static/rb/js/views/draftReviewBannerView.js
        reviewboard/static/rb/js/views/tests/reviewDialogViewTests.js
        reviewboard/static/rb/css/common.less
        reviewboard/static/rb/js/pages/views/reviewablePageView.js
        reviewboard/static/rb/js/views/reviewDialogView.js
        reviewboard/templates/reviews/reviewable_base.html
        reviewboard/static/rb/js/resources/models/reviewModel.js
    
    
  2. 
      
david
  1. 
      
  2. Show all issues

    No trailing commas in js (at least until we're totally ready to break IE8 with impunity).

  3. 
      
brennie
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        reviewboard/webapi/resources/base_comment.py
        reviewboard/webapi/tests/mixins_comment.py
        reviewboard/webapi/mixins.py
        reviewboard/webapi/resources/review_general_comment.py
        reviewboard/webapi/resources/review_reply_general_comment.py
    
    Ignored Files:
        reviewboard/static/rb/js/views/draftReviewBannerView.js
        reviewboard/static/rb/js/views/tests/reviewDialogViewTests.js
        reviewboard/static/rb/css/common.less
        reviewboard/static/rb/js/pages/views/reviewablePageView.js
        reviewboard/static/rb/js/views/reviewDialogView.js
        reviewboard/templates/reviews/reviewable_base.html
        reviewboard/static/rb/js/resources/models/reviewModel.js
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/webapi/resources/base_comment.py
        reviewboard/webapi/tests/mixins_comment.py
        reviewboard/webapi/mixins.py
        reviewboard/webapi/resources/review_general_comment.py
        reviewboard/webapi/resources/review_reply_general_comment.py
    
    Ignored Files:
        reviewboard/static/rb/js/views/draftReviewBannerView.js
        reviewboard/static/rb/js/views/tests/reviewDialogViewTests.js
        reviewboard/static/rb/css/common.less
        reviewboard/static/rb/js/pages/views/reviewablePageView.js
        reviewboard/static/rb/js/views/reviewDialogView.js
        reviewboard/templates/reviews/reviewable_base.html
        reviewboard/static/rb/js/resources/models/reviewModel.js
    
    
  2. 
      
david
  1. Looks good, but I still want Christian to look at the text types stuff.

  2. 
      
chipx86
  1. 
      
  2. Show all issues

    These should be in the form of <input type="button"/>, for consistency.

  3. Show all issues

    Blank line before this.

  4. Show all issues

    It's not super clear from the change, so why is this special-cased?

  5. Show all issues

    Missing "Returns".

  6. Show all issues

    Let's leave the /> in. While not technically needed for HTML, it's something we do to help with readability a bit.

  7. reviewboard/webapi/resources/base_comment.py (Diff revision 5)
     
     
     
     
     
     
    Show all issues

    We don't have any other resources with these explicitly listed, but ideally, we should. We should have it for every resource that supports this (by using MarkdownFieldsMixin).

    I don't mind removing it here for now, but we should absolutely have a task to track adding these (and related options) in.

    1. We can include this, but have to have 'type;: six.text_type or come up with some other way of allowing comma-separated values.

      Inlcuding this as is results in ALL comments becoming unsubmittable.

  8. 
      
brennie
reviewbot
  1. Tool: PEP8 Style Checker
    Ignored Files:
        reviewboard/static/rb/js/views/draftReviewBannerView.js
        reviewboard/static/rb/js/views/tests/reviewDialogViewTests.js
        reviewboard/static/rb/css/common.less
        reviewboard/static/rb/js/pages/views/reviewablePageView.js
        reviewboard/static/rb/js/views/reviewDialogView.js
        reviewboard/static/rb/js/resources/models/reviewModel.js
    
    
    
    Tool: Pyflakes
    Ignored Files:
        reviewboard/static/rb/js/views/draftReviewBannerView.js
        reviewboard/static/rb/js/views/tests/reviewDialogViewTests.js
        reviewboard/static/rb/css/common.less
        reviewboard/static/rb/js/pages/views/reviewablePageView.js
        reviewboard/static/rb/js/views/reviewDialogView.js
        reviewboard/static/rb/js/resources/models/reviewModel.js
    
    
  2. 
      
brennie
reviewbot
  1. Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/webapi/resources/base_comment.py
        reviewboard/webapi/tests/mixins_comment.py
        reviewboard/webapi/mixins.py
        reviewboard/notifications/webhooks.py
        reviewboard/webapi/resources/review_general_comment.py
        reviewboard/webapi/resources/review_reply_general_comment.py
    
    Ignored Files:
        reviewboard/static/rb/js/views/draftReviewBannerView.js
        reviewboard/static/rb/js/views/tests/reviewDialogViewTests.js
        reviewboard/static/rb/css/common.less
        reviewboard/static/rb/js/pages/views/reviewablePageView.js
        reviewboard/static/rb/js/views/reviewDialogView.js
        reviewboard/static/rb/js/resources/models/reviewModel.js
    
    
    
    Tool: Pyflakes
    Processed Files:
        reviewboard/webapi/resources/base_comment.py
        reviewboard/webapi/tests/mixins_comment.py
        reviewboard/webapi/mixins.py
        reviewboard/notifications/webhooks.py
        reviewboard/webapi/resources/review_general_comment.py
        reviewboard/webapi/resources/review_reply_general_comment.py
    
    Ignored Files:
        reviewboard/static/rb/js/views/draftReviewBannerView.js
        reviewboard/static/rb/js/views/tests/reviewDialogViewTests.js
        reviewboard/static/rb/css/common.less
        reviewboard/static/rb/js/pages/views/reviewablePageView.js
        reviewboard/static/rb/js/views/reviewDialogView.js
        reviewboard/static/rb/js/resources/models/reviewModel.js
    
    
  2. 
      
david
  1. 
      
  2. reviewboard/notifications/webhooks.py (Diff revision 7)
     
     
     
     
     
    Show all issues

    You need to handle general_comments here, too.

  3. 
      
brennie
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        reviewboard/webapi/resources/base_comment.py
        reviewboard/webapi/tests/mixins_comment.py
        reviewboard/webapi/mixins.py
        reviewboard/notifications/webhooks.py
        reviewboard/webapi/resources/review_general_comment.py
        reviewboard/webapi/resources/review_reply_general_comment.py
    
    Ignored Files:
        reviewboard/static/rb/js/views/draftReviewBannerView.js
        reviewboard/static/rb/js/views/tests/reviewDialogViewTests.js
        reviewboard/static/rb/css/common.less
        reviewboard/static/rb/js/pages/views/reviewablePageView.js
        reviewboard/static/rb/js/views/reviewDialogView.js
        reviewboard/static/rb/js/resources/models/reviewModel.js
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/webapi/resources/base_comment.py
        reviewboard/webapi/tests/mixins_comment.py
        reviewboard/webapi/mixins.py
        reviewboard/notifications/webhooks.py
        reviewboard/webapi/resources/review_general_comment.py
        reviewboard/webapi/resources/review_reply_general_comment.py
    
    Ignored Files:
        reviewboard/static/rb/js/views/draftReviewBannerView.js
        reviewboard/static/rb/js/views/tests/reviewDialogViewTests.js
        reviewboard/static/rb/css/common.less
        reviewboard/static/rb/js/pages/views/reviewablePageView.js
        reviewboard/static/rb/js/views/reviewDialogView.js
        reviewboard/static/rb/js/resources/models/reviewModel.js
    
    
  2. 
      
david
  1. 
      
  2. reviewboard/notifications/webhooks.py (Diff revision 8)
     
     
    Show all issues

    serailize?

  3. 
      
brennie
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        reviewboard/webapi/resources/base_comment.py
        reviewboard/webapi/tests/mixins_comment.py
        reviewboard/webapi/mixins.py
        reviewboard/notifications/webhooks.py
        reviewboard/webapi/resources/review_general_comment.py
        reviewboard/webapi/resources/review_reply_general_comment.py
    
    Ignored Files:
        reviewboard/static/rb/js/views/draftReviewBannerView.js
        reviewboard/static/rb/js/views/tests/reviewDialogViewTests.js
        reviewboard/static/rb/css/common.less
        reviewboard/static/rb/js/pages/views/reviewablePageView.js
        reviewboard/static/rb/js/views/reviewDialogView.js
        reviewboard/static/rb/js/resources/models/reviewModel.js
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/webapi/resources/base_comment.py
        reviewboard/webapi/tests/mixins_comment.py
        reviewboard/webapi/mixins.py
        reviewboard/notifications/webhooks.py
        reviewboard/webapi/resources/review_general_comment.py
        reviewboard/webapi/resources/review_reply_general_comment.py
    
    Ignored Files:
        reviewboard/static/rb/js/views/draftReviewBannerView.js
        reviewboard/static/rb/js/views/tests/reviewDialogViewTests.js
        reviewboard/static/rb/css/common.less
        reviewboard/static/rb/js/pages/views/reviewablePageView.js
        reviewboard/static/rb/js/views/reviewDialogView.js
        reviewboard/static/rb/js/resources/models/reviewModel.js
    
    
  2. 
      
david
  1. Ship It!
  2. 
      
brennie
Review request changed
Status:
Completed
Change Summary:
Pushed to ucosp/nicole_xin/general-comments (7a1c248)