enable inline comments via admin setting (bug 1115707) r?smacleod draft
authorbyron jones <glob@mozilla.com>
Thu, 25 Aug 2016 14:53:45 +0800
changeset 174 a013fafced7729fc6e29d767f75082f7aa321bc2
parent 173 fdbfa60db88ee4eedb77d66788759cf4778651e2
child 175 bf7e26563eac2f5563dd24700429aa1d42059410
push idunknown
push userunknown
push dateunknown
reviewerssmacleod
bugs1115707
enable inline comments via admin setting (bug 1115707) r?smacleod Bind the inline comments view to the admin setting. MozReview-Commit-ID: Ddnv4eu3k2f
reviewboard/reviewboard/static/rb/js/diffviewer/views/diffReviewableView_mozreview.js
reviewboard/reviewboard/templates/diffviewer/view_diff_mozreview.html
--- a/reviewboard/reviewboard/static/rb/js/diffviewer/views/diffReviewableView_mozreview.js
+++ b/reviewboard/reviewboard/static/rb/js/diffviewer/views/diffReviewableView_mozreview.js
@@ -34,16 +34,24 @@ RB.DiffReviewableView = RB.AbstractRevie
         'click .diff-expand-btn': '_onExpandChunkClicked',
         'mouseup': '_onMouseUp'
     },
 
     /*
      * Initializes the reviewable for a file's diff.
      */
     initialize: function() {
+        // MozReview: use inline-comments when enabled
+        if ($('#show_comments_inline').data('enabled')) {
+            this.commentBlockView = RB.InlineCommentView;
+            this.commentsInline = true;
+        } else {
+            this.commentsInline = false;
+        }
+
         _super(this).initialize.call(this);
 
         _.bindAll(this, '_updateCollapseButtonPos', '_onWindowResize');
 
         this._selector = new RB.TextCommentRowSelector({
             el: this.el,
             reviewableView: this
         });
@@ -188,18 +196,26 @@ RB.DiffReviewableView = RB.AbstractRevie
             endRowEl = rowEls[1];
 
             /*
              * Note that endRow might be null if it exists in a collapsed
              * region, so we can get away with just using beginRow if we
              * need to.
              */
             commentBlockView.setRows($(beginRowEl), $(endRowEl || beginRowEl));
-            commentBlockView.$el.appendTo(
-                commentBlockView.$beginRow[0].cells[0]);
+
+            // MozReview: inline comments need to be injected into the DOM
+            // differently from comment bubbles.
+            if (this.commentsInline) {
+                commentBlockView.$el.insertAfter(commentBlockView.$endRow);
+            } else {
+                commentBlockView.$el.appendTo(
+                    commentBlockView.$beginRow[0].cells[0]);
+            }
+
             this._visibleCommentBlockViews.push(commentBlockView);
 
             prevBeginRowIndex = beginRowEl.rowIndex;
         } else {
             this._hiddenCommentBlockViews.push(commentBlockView);
         }
 
         return prevBeginRowIndex;
--- a/reviewboard/reviewboard/templates/diffviewer/view_diff_mozreview.html
+++ b/reviewboard/reviewboard/templates/diffviewer/view_diff_mozreview.html
@@ -20,16 +20,23 @@
 <h2>{% trans "There was an internal error displaying the diff." %}</h2>
 <p><b>{% blocktrans %}Details:</b> {{error}}{% endblocktrans %}</p>
 {%    if request.user.is_superuser %}
 {%     if trace %}<pre>{{trace|escape}}</pre>{% endif %}
 {%    endif %}
 {%   enderrorbox %}
 {%  else %}{# !error #}
 
+{# MozReview: add inline comments templates #}
+{% if siteconfig_settings.diffviewer_show_comments_inline %}
+{%  include "diffviewer/inline_comments.html" %}
+{% endif %}
+<div id="show_comments_inline"
+ data-enabled="{{siteconfig_settings.diffviewer_show_comments_inline|yesno:"true,false"}}">
+
 <div id="review_request">
  <div id="review_request_banners"></div>
 {% display_review_request_trophies review_request %}
 
 {%   box "review-request" %}
  <div class="review-request-header">
   <ul class="actions page-tabs">
    <li><a href="{{review_request.get_absolute_url}}">{% trans "Reviews" %}</a></li>