Changeset - 348ecbd25577
[Not reviewed]
default
0 6 0
Mads Kiilerich - 12 years ago 2014-07-18 18:47:02
madski@unity3d.com
pull requests: show links to next/previous comment - don't get lost navigating huge PRs
6 files changed with 54 insertions and 8 deletions:
0 comments (0 inline, 0 general)
kallithea/public/css/style.css
Show inline comments
 
@@ -4450,7 +4450,9 @@ div.rst-block  pre {
 
    margin: 0.5em 0px !important;
 
}
 

	
 
.comments .comments-number {
 
.comments .comments-number,
 
.pr-comments-number {
 
    margin: 5px;
 
    padding: 0px 0px 10px 0px;
 
    font-weight: bold;
 
    color: #666;
 
@@ -5082,6 +5084,13 @@ div.comment:target>.comment-wrapp {
 
    margin: -2px;
 
}
 

	
 
div.prev-next-comment div.prev-comment,
 
div.prev-next-comment div.next-comment {
 
    display: inline-block;
 
    min-width: 150px;
 
    margin: 3px 6px;
 
}
 

	
 
#help_kb {
 
    display: none;
 
}
kallithea/public/js/base.js
Show inline comments
 
@@ -814,7 +814,9 @@ var _placeInline = function(target_id, l
 
        $after_tr = $after_tr.next();
 
    }
 
    // put in the comment at the bottom
 
    $after_tr.after(_table_tr('inline-comments', html));
 
    var $tr = _table_tr('inline-comments', html)
 
    $tr.find('div.comment').addClass('inline-comment');
 
    $after_tr.after($tr);
 

	
 
    // scan nodes, and attach add button to last one
 
    _placeAddButton($line_tr);
 
@@ -862,6 +864,36 @@ var renderInlineComments = function(file
 
    }
 
}
 

	
 
/**
 
 * Double link comments
 
 */
 
var linkInlineComments = function(firstlinks, comments){
 
    var $comments = $(comments);
 
    if ($comments.length > 0) {
 
        $(firstlinks).html('<a href="#{0}">First comment</a>'.format($comments.attr('id')));
 
    }
 
    if ($comments.length <= 1) {
 
        return;
 
    }
 

	
 
    $comments.each(function(i, e){
 
            var prev = '';
 
            if (i > 0){
 
                var prev_anchor = YUD.getAttribute(comments.item(i-1),'id');
 
                prev = '<a href="#{0}">Previous comment</a>'.format(prev_anchor);
 
            }
 
            var next = '';
 
            if (i+1 < comments.length){
 
                var next_anchor = YUD.getAttribute(comments.item(i+1),'id');
 
                next = '<a href="#{0}">Next comment</a>'.format(next_anchor);
 
            }
 
            var $div = $(('<div class="prev-next-comment">'+
 
                          '<div class="prev-comment">{0}</div>'+
 
                          '<div class="next-comment">{1}</div>').format(prev, next));
 
            $div.prependTo(this);
 
        });
 
}
 

	
 
/* activate files.html stuff */
 
var fileBrowserListeners = function(current_url, node_list_url, url_base){
 
    var current_url_branch = "?branch=__BRANCH__";
kallithea/templates/changeset/changeset.html
Show inline comments
 
@@ -64,7 +64,7 @@ ${self.repo_context_bar('changelog', c.c
 
                  ${c.ignorews_url(request.GET)}
 
                  ${c.context_url(request.GET)}
 
                </div>
 
                <div class="comments-number" style="float:right;padding-right:5px">${ungettext("%d comment", "%d comments", len(c.comments)) % len(c.comments)} ${ungettext("(%d inline)", "(%d inline)", c.inline_cnt) % c.inline_cnt}</div>
 
                <div class="comments-number" style="float:right;padding-right:5px">${ungettext("%d comment", "%d comments", len(c.comments)) % len(c.comments)} ${ungettext("(%d inline)", "(%d inline)", c.inline_cnt) % c.inline_cnt} <span class="firstlink"></span> </div>
 
            </div>
 
        </div>
 
        <div id="changeset_content">
 
@@ -197,6 +197,8 @@ ${self.repo_context_bar('changelog', c.c
 
          var file_comments = YUQ('.inline-comment-placeholder');
 
          renderInlineComments(file_comments);
 

	
 
          linkInlineComments(document.getElementsByClassName('firstlink'), document.getElementsByClassName("inline-comment"));
 

	
 
          pyroutes.register('changeset_home',
 
                            "${h.url('changeset_home', repo_name='%(repo_name)s', revision='%(revision)s')}",
 
                            ['repo_name', 'revision']);
kallithea/templates/changeset/changeset_file_comment.html
Show inline comments
 
@@ -108,7 +108,7 @@
 

	
 
## generates inlines taken from c.comments var
 
<%def name="inlines()">
 
    <div class="comments-number">${ungettext("%d comment", "%d comments", len(c.comments)) % len(c.comments)} ${ungettext("(%d inline)", "(%d inline)", c.inline_cnt) % c.inline_cnt}</div>
 
    <div class="comments-number">${ungettext("%d comment", "%d comments", len(c.comments)) % len(c.comments)} ${ungettext("(%d inline)", "(%d inline)", c.inline_cnt) % c.inline_cnt} <span class="firstlink"></span> </div>
 
    %for path, lines in c.inline_comments:
 
        % for line,comments in lines.iteritems():
 
            <div style="display:none" class="inline-comment-placeholder" path="${path}" target_id="${h.safeid(h.safe_unicode(path))}">
kallithea/templates/pullrequests/pullrequest_show.html
Show inline comments
 
@@ -255,6 +255,7 @@ ${self.repo_context_bar('showpullrequest
 
                    </div>
 
                %endfor
 
              </div>
 
              <div class="comments-number pr-comments-number">${ungettext("%d comment", "%d comments", len(c.comments)) % len(c.comments)} ${ungettext("(%d inline)", "(%d inline)", c.inline_cnt) % c.inline_cnt} <span class="firstlink"></span> </div>
 
              % if c.limited_diff:
 
                <h5>${_('Changeset was too big and was cut off...')} <a href="${h.url.current(fulldiff=1, **request.GET.mixed())}">${_('Show full diff anyway')}</a></h5>
 
              % endif
 
@@ -329,6 +330,8 @@ ${self.repo_context_bar('showpullrequest
 
          var file_comments = YUQ('.inline-comment-placeholder');
 
          renderInlineComments(file_comments);
 

	
 
          linkInlineComments(document.getElementsByClassName('firstlink'), document.getElementsByClassName("inline-comment"));
 

	
 
          YUE.on(YUD.get('update_pull_request'),'click',function(e){
 
              updateReviewers(undefined, "${c.repo_name}", "${c.pull_request.pull_request_id}");
 
          })
kallithea/tests/functional/test_changeset_comments.py
Show inline comments
 
@@ -42,7 +42,7 @@ class TestChangeSetCommentsController(Te
 
        # test DB
 
        self.assertEqual(ChangesetComment.query().count(), 1)
 
        response.mustcontain('''<div class="comments-number">%s comment '''
 
                             '''(0 inline)</div>''' % 1)
 
                             '''(0 inline)''' % 1)
 

	
 
        self.assertEqual(Notification.query().count(), 1)
 
        self.assertEqual(ChangesetComment.query().count(), 1)
 
@@ -78,7 +78,7 @@ class TestChangeSetCommentsController(Te
 
        self.assertEqual(ChangesetComment.query().count(), 1)
 
        response.mustcontain(
 
            '''<div class="comments-number">0 comments'''
 
            ''' (%s inline)</div>''' % 1
 
            ''' (%s inline)''' % 1
 
        )
 
        response.mustcontain(
 
            '''<div style="display:none" class="inline-comment-placeholder" '''
 
@@ -117,7 +117,7 @@ class TestChangeSetCommentsController(Te
 
        # test DB
 
        self.assertEqual(ChangesetComment.query().count(), 1)
 
        response.mustcontain('''<div class="comments-number">%s '''
 
                             '''comment (0 inline)</div>''' % 1)
 
                             '''comment (0 inline)''' % 1)
 

	
 
        self.assertEqual(Notification.query().count(), 2)
 
        users = [x.user.username for x in UserNotification.query().all()]
 
@@ -150,4 +150,4 @@ class TestChangeSetCommentsController(Te
 
        response = self.app.get(url(controller='changeset', action='index',
 
                                repo_name=HG_REPO, revision=rev))
 
        response.mustcontain('''<div class="comments-number">0 comments'''
 
                             ''' (0 inline)</div>''')
 
                             ''' (0 inline)''')
0 comments (0 inline, 0 general)