Convert js/resources/models to ES6.

Review Request #8108 — Created April 8, 2016 and submitted

Information

Review Board
release-3.0.x
851ad83...

Reviewers

This is a relatively large but straightforward conversion.

Ran unit tests.

Description From Last Updated

You can make this const and do: const url = /* ... */; return this.isNew() ? url : `${url}${this.id}/`;

brenniebrennie

Do we prefer spread/rest over arguments? e.g., { destroyIfEmpty(...args) { if (!this.get('text')) { this.destroy.apply(this, args); } } }

brenniebrennie

Add a period.

brenniebrennie

"Serialize and return"

brenniebrennie

What about: { deserializers: { date(date) { return date ? new Date(date) : ''; }, summary(message) { return message.split('\n', 1)[0]; …

brenniebrennie

Same here.

brenniebrennie

parseResourceData(rsp)

brenniebrennie

Same comment as the other one about making this const.

brenniebrennie

Same as above.

brenniebrennie

Same as above.

brenniebrennie

Same comment re: function literals.

brenniebrennie

Same comment about const-ness.

brenniebrennie

parseResourceData(rsp)

brenniebrennie

validate(attrs)

brenniebrennie
reviewbot
  1. Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/staticbundles.py
    
    Ignored Files:
        reviewboard/static/rb/js/resources/models/screenshotCommentReplyModel.es6.js
        reviewboard/static/rb/js/resources/models/fileDiffModel.js
        reviewboard/static/rb/js/resources/models/repositoryBranchModel.es6.js
        reviewboard/static/rb/js/resources/models/repositoryCommitModel.es6.js
        reviewboard/static/rb/js/resources/models/validateDiffModel.es6.js
        reviewboard/static/rb/js/resources/models/baseCommentModel.es6.js
        reviewboard/static/rb/js/resources/models/screenshotCommentModel.es6.js
        reviewboard/static/rb/js/resources/models/diffCommentModel.es6.js
        reviewboard/static/rb/js/resources/models/generalCommentModel.es6.js
        reviewboard/static/rb/js/resources/models/apiTokenModel.es6.js
        reviewboard/static/rb/js/resources/models/draftResourceChildModelMixin.es6.js
        reviewboard/static/rb/js/resources/models/repositoryCommitModel.js
        reviewboard/static/rb/js/resources/models/repositoryBranchModel.js
        reviewboard/static/rb/js/resources/models/screenshotModel.es6.js
        reviewboard/static/rb/js/resources/models/reviewModel.es6.js
        reviewboard/static/rb/js/resources/models/fileDiffModel.es6.js
        reviewboard/static/rb/js/resources/models/repositoryModel.es6.js
        reviewboard/static/rb/js/resources/models/baseResourceModel.es6.js
        reviewboard/static/rb/js/resources/models/diffCommentReplyModel.es6.js
        reviewboard/static/rb/js/resources/models/fileAttachmentCommentModel.es6.js
        reviewboard/static/rb/js/resources/models/fileAttachmentModel.es6.js
        reviewboard/static/rb/js/resources/utils/serializers.es6.js
        reviewboard/static/rb/js/resources/models/fileAttachmentCommentReplyModel.es6.js
        reviewboard/static/rb/js/resources/models/draftResourceChildModelMixin.js
        reviewboard/static/rb/js/resources/models/screenshotCommentModel.js
        reviewboard/static/rb/js/resources/models/draftFileAttachmentModel.es6.js
        reviewboard/static/rb/js/resources/models/diffModel.es6.js
        reviewboard/static/rb/js/resources/models/draftReviewRequestModel.es6.js
        reviewboard/static/rb/js/resources/models/fileAttachmentCommentModel.js
        reviewboard/static/rb/js/resources/models/reviewGroupModel.es6.js
        reviewboard/static/rb/js/resources/models/fileAttachmentModel.js
        reviewboard/static/rb/js/resources/models/reviewRequestModel.es6.js
        reviewboard/static/rb/js/resources/models/reviewModel.js
        reviewboard/static/rb/js/resources/models/draftResourceModelMixin.es6.js
        reviewboard/static/rb/js/resources/models/baseCommentReplyModel.es6.js
        reviewboard/static/rb/js/resources/models/generalCommentReplyModel.es6.js
        reviewboard/static/rb/js/resources/models/screenshotModel.js
        reviewboard/static/rb/js/resources/models/draftReviewModel.es6.js
        reviewboard/static/rb/js/resources/models/repositoryModel.js
        reviewboard/static/rb/js/resources/models/defaultReviewerModel.es6.js
        reviewboard/static/rb/js/resources/models/reviewReplyModel.es6.js
    
    
    
    Tool: Pyflakes
    Processed Files:
        reviewboard/staticbundles.py
    
    Ignored Files:
        reviewboard/static/rb/js/resources/models/screenshotCommentReplyModel.es6.js
        reviewboard/static/rb/js/resources/models/fileDiffModel.js
        reviewboard/static/rb/js/resources/models/repositoryBranchModel.es6.js
        reviewboard/static/rb/js/resources/models/repositoryCommitModel.es6.js
        reviewboard/static/rb/js/resources/models/validateDiffModel.es6.js
        reviewboard/static/rb/js/resources/models/baseCommentModel.es6.js
        reviewboard/static/rb/js/resources/models/screenshotCommentModel.es6.js
        reviewboard/static/rb/js/resources/models/diffCommentModel.es6.js
        reviewboard/static/rb/js/resources/models/generalCommentModel.es6.js
        reviewboard/static/rb/js/resources/models/apiTokenModel.es6.js
        reviewboard/static/rb/js/resources/models/draftResourceChildModelMixin.es6.js
        reviewboard/static/rb/js/resources/models/repositoryCommitModel.js
        reviewboard/static/rb/js/resources/models/repositoryBranchModel.js
        reviewboard/static/rb/js/resources/models/screenshotModel.es6.js
        reviewboard/static/rb/js/resources/models/reviewModel.es6.js
        reviewboard/static/rb/js/resources/models/fileDiffModel.es6.js
        reviewboard/static/rb/js/resources/models/repositoryModel.es6.js
        reviewboard/static/rb/js/resources/models/baseResourceModel.es6.js
        reviewboard/static/rb/js/resources/models/diffCommentReplyModel.es6.js
        reviewboard/static/rb/js/resources/models/fileAttachmentCommentModel.es6.js
        reviewboard/static/rb/js/resources/models/fileAttachmentModel.es6.js
        reviewboard/static/rb/js/resources/utils/serializers.es6.js
        reviewboard/static/rb/js/resources/models/fileAttachmentCommentReplyModel.es6.js
        reviewboard/static/rb/js/resources/models/draftResourceChildModelMixin.js
        reviewboard/static/rb/js/resources/models/screenshotCommentModel.js
        reviewboard/static/rb/js/resources/models/draftFileAttachmentModel.es6.js
        reviewboard/static/rb/js/resources/models/diffModel.es6.js
        reviewboard/static/rb/js/resources/models/draftReviewRequestModel.es6.js
        reviewboard/static/rb/js/resources/models/fileAttachmentCommentModel.js
        reviewboard/static/rb/js/resources/models/reviewGroupModel.es6.js
        reviewboard/static/rb/js/resources/models/fileAttachmentModel.js
        reviewboard/static/rb/js/resources/models/reviewRequestModel.es6.js
        reviewboard/static/rb/js/resources/models/reviewModel.js
        reviewboard/static/rb/js/resources/models/draftResourceModelMixin.es6.js
        reviewboard/static/rb/js/resources/models/baseCommentReplyModel.es6.js
        reviewboard/static/rb/js/resources/models/generalCommentReplyModel.es6.js
        reviewboard/static/rb/js/resources/models/screenshotModel.js
        reviewboard/static/rb/js/resources/models/draftReviewModel.es6.js
        reviewboard/static/rb/js/resources/models/repositoryModel.js
        reviewboard/static/rb/js/resources/models/defaultReviewerModel.es6.js
        reviewboard/static/rb/js/resources/models/reviewReplyModel.es6.js
    
    
  2. 
      
brennie
  1. Some stylistic nitpicks. Nothing major.

  2. reviewboard/static/rb/js/resources/models/apiTokenModel.es6.js (Diff revision 1)
     
     
     
     
     
     
     
     
     
    Show all issues

    You can make this const and do:

    const url = /* ... */;
    
    return this.isNew() ? url : `${url}${this.id}/`;
    
  3. Show all issues

    Do we prefer spread/rest over arguments? e.g.,

    {
        destroyIfEmpty(...args) {
            if (!this.get('text')) {
                this.destroy.apply(this, args);
            }
        }
    }
    
    1. I don't feel strongly about it. If we decide to go that route I can make another pass.

  4. Show all issues

    Add a period.

  5. Show all issues

    "Serialize and return"

  6. Show all issues

    What about:

    {
    deserializers: {
        date(date) {
            return date ? new Date(date) : '';
        },
        summary(message) {
            return message.split('\n', 1)[0];
        }
    }
    }
    
    1. That seems longer for no benefit. The new function sugar is nice for things that look like classes (and may eventually become classes), but I don't think it's always worth it.

  7. Show all issues

    Same here.

  8. Show all issues

    parseResourceData(rsp)

  9. Show all issues

    Same comment as the other one about making this const.

  10. Show all issues

    Same as above.

  11. Show all issues

    Same as above.

  12. reviewboard/static/rb/js/resources/models/reviewModel.es6.js (Diff revision 1)
     
     
     
     
     
     
     
     
    Show all issues

    Same comment re: function literals.

  13. You can do ready() { ... } I believe. Not sure if this will be correct, though.

    1. Yeah, I want the lexical this binding.

  14. Show all issues

    Same comment about const-ness.

  15. Show all issues

    parseResourceData(rsp)

  16. Show all issues

    validate(attrs)

  17. 
      
david
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        reviewboard/staticbundles.py
    
    Ignored Files:
        reviewboard/static/rb/js/resources/models/screenshotCommentReplyModel.es6.js
        reviewboard/static/rb/js/resources/models/fileDiffModel.js
        reviewboard/static/rb/js/resources/models/repositoryBranchModel.es6.js
        reviewboard/static/rb/js/resources/models/repositoryCommitModel.es6.js
        reviewboard/static/rb/js/resources/models/validateDiffModel.es6.js
        reviewboard/static/rb/js/resources/models/baseCommentModel.es6.js
        reviewboard/static/rb/js/resources/models/screenshotCommentModel.es6.js
        reviewboard/static/rb/js/resources/models/generalCommentModel.es6.js
        reviewboard/static/rb/js/resources/models/diffCommentModel.es6.js
        reviewboard/static/rb/js/resources/models/draftResourceChildModelMixin.es6.js
        reviewboard/static/rb/js/resources/models/repositoryCommitModel.js
        reviewboard/static/rb/js/resources/models/repositoryBranchModel.js
        reviewboard/static/rb/js/resources/models/screenshotModel.es6.js
        reviewboard/static/rb/js/resources/models/reviewModel.es6.js
        reviewboard/static/rb/js/resources/models/fileDiffModel.es6.js
        reviewboard/static/rb/js/resources/models/repositoryModel.es6.js
        reviewboard/static/rb/js/resources/models/baseResourceModel.es6.js
        reviewboard/static/rb/js/resources/models/diffCommentReplyModel.es6.js
        reviewboard/static/rb/js/resources/models/fileAttachmentCommentModel.es6.js
        reviewboard/static/rb/js/resources/models/fileAttachmentModel.es6.js
        reviewboard/static/rb/js/resources/utils/serializers.es6.js
        reviewboard/static/rb/js/resources/models/fileAttachmentCommentReplyModel.es6.js
        reviewboard/static/rb/js/resources/models/draftResourceChildModelMixin.js
        reviewboard/static/rb/js/resources/models/screenshotCommentModel.js
        reviewboard/static/rb/js/resources/models/draftFileAttachmentModel.es6.js
        reviewboard/static/rb/js/resources/models/diffModel.es6.js
        reviewboard/static/rb/js/resources/models/draftReviewRequestModel.es6.js
        reviewboard/static/rb/js/resources/models/fileAttachmentCommentModel.js
        reviewboard/static/rb/js/resources/models/reviewGroupModel.es6.js
        reviewboard/static/rb/js/resources/models/fileAttachmentModel.js
        reviewboard/static/rb/js/resources/models/reviewRequestModel.es6.js
        reviewboard/static/rb/js/resources/models/reviewModel.js
        reviewboard/static/rb/js/resources/models/apiTokenModel.js
        reviewboard/static/rb/js/resources/models/draftResourceModelMixin.es6.js
        reviewboard/static/rb/js/resources/models/baseCommentReplyModel.es6.js
        reviewboard/static/rb/js/resources/models/generalCommentReplyModel.es6.js
        reviewboard/static/rb/js/resources/models/apiTokenModel.es6.js
        reviewboard/static/rb/js/resources/models/screenshotModel.js
        reviewboard/static/rb/js/resources/models/draftReviewModel.es6.js
        reviewboard/static/rb/js/resources/models/repositoryModel.js
        reviewboard/static/rb/js/resources/models/defaultReviewerModel.es6.js
        reviewboard/static/rb/js/resources/models/reviewReplyModel.es6.js
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/staticbundles.py
    
    Ignored Files:
        reviewboard/static/rb/js/resources/models/screenshotCommentReplyModel.es6.js
        reviewboard/static/rb/js/resources/models/fileDiffModel.js
        reviewboard/static/rb/js/resources/models/repositoryBranchModel.es6.js
        reviewboard/static/rb/js/resources/models/repositoryCommitModel.es6.js
        reviewboard/static/rb/js/resources/models/validateDiffModel.es6.js
        reviewboard/static/rb/js/resources/models/baseCommentModel.es6.js
        reviewboard/static/rb/js/resources/models/screenshotCommentModel.es6.js
        reviewboard/static/rb/js/resources/models/generalCommentModel.es6.js
        reviewboard/static/rb/js/resources/models/diffCommentModel.es6.js
        reviewboard/static/rb/js/resources/models/draftResourceChildModelMixin.es6.js
        reviewboard/static/rb/js/resources/models/repositoryCommitModel.js
        reviewboard/static/rb/js/resources/models/repositoryBranchModel.js
        reviewboard/static/rb/js/resources/models/screenshotModel.es6.js
        reviewboard/static/rb/js/resources/models/reviewModel.es6.js
        reviewboard/static/rb/js/resources/models/fileDiffModel.es6.js
        reviewboard/static/rb/js/resources/models/repositoryModel.es6.js
        reviewboard/static/rb/js/resources/models/baseResourceModel.es6.js
        reviewboard/static/rb/js/resources/models/diffCommentReplyModel.es6.js
        reviewboard/static/rb/js/resources/models/fileAttachmentCommentModel.es6.js
        reviewboard/static/rb/js/resources/models/fileAttachmentModel.es6.js
        reviewboard/static/rb/js/resources/utils/serializers.es6.js
        reviewboard/static/rb/js/resources/models/fileAttachmentCommentReplyModel.es6.js
        reviewboard/static/rb/js/resources/models/draftResourceChildModelMixin.js
        reviewboard/static/rb/js/resources/models/screenshotCommentModel.js
        reviewboard/static/rb/js/resources/models/draftFileAttachmentModel.es6.js
        reviewboard/static/rb/js/resources/models/diffModel.es6.js
        reviewboard/static/rb/js/resources/models/draftReviewRequestModel.es6.js
        reviewboard/static/rb/js/resources/models/fileAttachmentCommentModel.js
        reviewboard/static/rb/js/resources/models/reviewGroupModel.es6.js
        reviewboard/static/rb/js/resources/models/fileAttachmentModel.js
        reviewboard/static/rb/js/resources/models/reviewRequestModel.es6.js
        reviewboard/static/rb/js/resources/models/reviewModel.js
        reviewboard/static/rb/js/resources/models/apiTokenModel.js
        reviewboard/static/rb/js/resources/models/draftResourceModelMixin.es6.js
        reviewboard/static/rb/js/resources/models/baseCommentReplyModel.es6.js
        reviewboard/static/rb/js/resources/models/generalCommentReplyModel.es6.js
        reviewboard/static/rb/js/resources/models/apiTokenModel.es6.js
        reviewboard/static/rb/js/resources/models/screenshotModel.js
        reviewboard/static/rb/js/resources/models/draftReviewModel.es6.js
        reviewboard/static/rb/js/resources/models/repositoryModel.js
        reviewboard/static/rb/js/resources/models/defaultReviewerModel.es6.js
        reviewboard/static/rb/js/resources/models/reviewReplyModel.es6.js
    
    
  2. 
      
david
Review request changed
Status:
Completed
Change Summary:
Pushed to release-3.0.x (41e48b8)