Move publishError events out of views to models. Clarify PublishError message.
Review Request #7479 — Created July 2, 2015 and submitted
Move publishError events out of views to models. Clarify PublishError message.
This causes to error handlers for the "Ship It!" button and the Review Dialog
to be triggered.
Simulated a PublishError on the server and verified that alerts popped up after clicking the "Ship It!" button, the "Publish Review" button in the Review dialog, and the "Publish" button in the draft banner for both a review and a reply.
Description | From | Last Updated |
---|---|---|
Now that we're passing our own function in as part of the object, we don't have to do the whole … |
david |
-
I think it would be better to put this in
RB.DraftReview
'spublish
method (we already have a success handler there that emits a signal).
- Change Summary:
-
I moved the publishError triggering to RB.DraftReview as suggested. I also removed the trigger from RB.DraftReviewBannerView since it is no longer needed. While I was at it, I moved the review-reply publishError triggering out of RB.ReviewReplyDraftBannerView into RB.ReviewReply for consistency. Finally I realized that the message from PublishError was wrong in that it referenced review requests, when it can also be triggered by publishing a review or a review reply.
- Summary:
-
Add publishError events to error handlers for the "Ship It!" button and the Review Dialog.Move publishError events out of views to models. Clarify PublishError message.
- Description:
-
~ Add publishError events to error handlers for the "Ship It!" button and the Review Dialog.
~ Move publishError events out of views to models. Clarify PublishError message.
~ Both are caught by the publishError handler set in RB.DraftReviewBannerView's render() function.
~ This causes to error handlers for the "Ship It!" button and the Review Dialog
+ to be triggered. - Testing Done:
-
~ Simulated a PublishError on the server and verified that alerts popped up after both clicking the "Ship It!" button and the "Publish Review" button in the Review dialog.
~ Simulated a PublishError on the server and verified that alerts popped up after clicking the "Ship It!" button, the "Publish Review" button in the Review dialog, and the "Publish" button in the draft banner for both a review and a reply.
- Diff:
-
Revision 2 (+25 -18)
-
Tool: PEP8 Style Checker Processed Files: reviewboard/reviews/errors.py Ignored Files: reviewboard/static/rb/js/views/reviewReplyDraftBannerView.js reviewboard/static/rb/js/views/draftReviewBannerView.js reviewboard/static/rb/js/resources/models/draftReviewModel.js reviewboard/static/rb/js/resources/models/reviewReplyModel.js Tool: Pyflakes Processed Files: reviewboard/reviews/errors.py Ignored Files: reviewboard/static/rb/js/views/reviewReplyDraftBannerView.js reviewboard/static/rb/js/views/draftReviewBannerView.js reviewboard/static/rb/js/resources/models/draftReviewModel.js reviewboard/static/rb/js/resources/models/reviewReplyModel.js
-
-
Now that we're passing our own function in as part of the object, we don't have to do the whole bind/undefined thing. Instead, this can just be:
error: function(model, xhr) { model.trigger('publishError', xhr.errorText); if (_.isFunction(options.error)) { options.error.call(context, model, xhr); } }
Same in the other file.
-
Tool: Pyflakes Processed Files: reviewboard/reviews/errors.py Ignored Files: reviewboard/static/rb/js/views/reviewReplyDraftBannerView.js reviewboard/static/rb/js/views/draftReviewBannerView.js reviewboard/static/rb/js/resources/models/draftReviewModel.js reviewboard/static/rb/js/resources/models/reviewReplyModel.js Tool: PEP8 Style Checker Processed Files: reviewboard/reviews/errors.py Ignored Files: reviewboard/static/rb/js/views/reviewReplyDraftBannerView.js reviewboard/static/rb/js/views/draftReviewBannerView.js reviewboard/static/rb/js/resources/models/draftReviewModel.js reviewboard/static/rb/js/resources/models/reviewReplyModel.js