MozReview: Don't open issues by default whe comment is a reply. (Bug 1326043) r?mars draft
authorDavid Walsh <dwalsh@mozilla.com>
Fri, 06 Jan 2017 11:29:48 -0600
changeset 269 e6391292967d24930aa04e290b7d4531b1ce0370
parent 257 65d75dd8779b0b4103957abc959c78bd0ef8e6f6
push idunknown
push userunknown
push dateunknown
reviewersmars
bugs1326043
MozReview: Don't open issues by default whe comment is a reply. (Bug 1326043) r?mars MozReview-Commit-ID: do8UJJCpJs
reviewboard/reviewboard/static/rb/js/models/commentEditorModel.js
reviewboard/reviewboard/static/rb/js/views/commentDialogView_mozreview.js
--- a/reviewboard/reviewboard/static/rb/js/models/commentEditorModel.js
+++ b/reviewboard/reviewboard/static/rb/js/models/commentEditorModel.js
@@ -14,16 +14,17 @@ RB.CommentEditor = Backbone.Model.extend
         return {
             canDelete: false,
             canEdit: undefined,
             canSave: false,
             editing: false,
             extraData: {},
             comment: null,
             dirty: false,
+            isReply: false,
             openIssue: userSession.get('commentsOpenAnIssue'),
             publishedComments: [],
             publishedCommentsType: null,
             reviewRequest: null,
             richText: userSession.get('defaultUseRichText'),
             text: ''
         };
     },
@@ -239,17 +240,17 @@ RB.CommentEditor = Backbone.Model.extend
              * value if it's true, and we'll fall back on the comment's value
              * if false. This is so that we can keep a consistent experience
              * when the "Always edit Markdown by default" value is set.
              */
             this.set({
                 dirty: false,
                 extraData: comment.get('extraData'),
                 openIssue: comment.get('issueOpened') === null
-                           ? this.defaults().openIssue
+                           ? (this.get('isReply') ? false : this.defaults().openIssue)
                            : comment.get('issueOpened'),
                 richText: defaultRichText || !!comment.get('richText')
             });
 
             /*
              * We'll try to set the one from the appropriate text fields, if it
              * exists and is not empty. If we have this, then it came from a
              * previous save. If we don't have it, we'll fall back to "text",
--- a/reviewboard/reviewboard/static/rb/js/views/commentDialogView_mozreview.js
+++ b/reviewboard/reviewboard/static/rb/js/views/commentDialogView_mozreview.js
@@ -605,16 +605,17 @@ RB.CommentDialogView = Backbone.View.ext
             reviewRequestEditor =
                 options.reviewRequestEditor ||
                 RB.PageManager.getPage().reviewRequestEditor,
             commentIssueManager =
                 options.commentIssueManager ||
                 reviewRequestEditor.get('commentIssueManager'),
             beside,
             dlg,
+            publishedComments,
             x,
             y;
 
         function showCommentDlg() {
             try {
                 dlg.open();
             } catch(e) {
                 dlg.close();
@@ -622,27 +623,29 @@ RB.CommentDialogView = Backbone.View.ext
             }
 
             RB.CommentDialogView._instance = dlg;
         }
 
         console.assert(options.comment, 'A comment must be specified');
 
         options = options || {};
+        publishedComments = options.publishedComments;
 
         dlg = new RB.CommentDialogView({
             animate: options.animate,
             commentIssueManager: commentIssueManager,
             model: new RB.CommentEditor({
                 comment: options.comment,
                 reviewRequest: reviewRequestEditor.get('reviewRequest'),
                 reviewRequestEditor: reviewRequestEditor,
-                publishedComments: options.publishedComments || undefined,
+                publishedComments: publishedComments || undefined,
                 publishedCommentsType: options.publishedCommentsType ||
-                                       undefined
+                                       undefined,
+                isReply: publishedComments && publishedComments.length > 0
             })
         });
 
         dlg.render().$el
             .css('z-index', 999) // XXX Use classes for z-indexes.
             .appendTo(options.container || document.body);
 
         options.position = options.position || {};