# HG changeset patch # User Mads Kiilerich # Date 2014-07-18 18:47:02 # Node ID 348ecbd25577947cf018e54f1f48d44bd8e1ed8d # Parent 05af189da2aefb112e65a8aa4e90257e7c0723ca pull requests: show links to next/previous comment - don't get lost navigating huge PRs diff --git a/kallithea/public/css/style.css b/kallithea/public/css/style.css --- a/kallithea/public/css/style.css +++ b/kallithea/public/css/style.css @@ -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; } diff --git a/kallithea/public/js/base.js b/kallithea/public/js/base.js --- a/kallithea/public/js/base.js +++ b/kallithea/public/js/base.js @@ -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('First comment'.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 = 'Previous comment'.format(prev_anchor); + } + var next = ''; + if (i+1 < comments.length){ + var next_anchor = YUD.getAttribute(comments.item(i+1),'id'); + next = 'Next comment'.format(next_anchor); + } + var $div = $(('
'+ + '
{0}
'+ + '
{1}
').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__"; diff --git a/kallithea/templates/changeset/changeset.html b/kallithea/templates/changeset/changeset.html --- a/kallithea/templates/changeset/changeset.html +++ b/kallithea/templates/changeset/changeset.html @@ -64,7 +64,7 @@ ${self.repo_context_bar('changelog', c.c ${c.ignorews_url(request.GET)} ${c.context_url(request.GET)}
-
${ungettext("%d comment", "%d comments", len(c.comments)) % len(c.comments)} ${ungettext("(%d inline)", "(%d inline)", c.inline_cnt) % c.inline_cnt}
+
${ungettext("%d comment", "%d comments", len(c.comments)) % len(c.comments)} ${ungettext("(%d inline)", "(%d inline)", c.inline_cnt) % c.inline_cnt}
@@ -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']); diff --git a/kallithea/templates/changeset/changeset_file_comment.html b/kallithea/templates/changeset/changeset_file_comment.html --- a/kallithea/templates/changeset/changeset_file_comment.html +++ b/kallithea/templates/changeset/changeset_file_comment.html @@ -108,7 +108,7 @@ ## generates inlines taken from c.comments var <%def name="inlines()"> -
${ungettext("%d comment", "%d comments", len(c.comments)) % len(c.comments)} ${ungettext("(%d inline)", "(%d inline)", c.inline_cnt) % c.inline_cnt}
+
${ungettext("%d comment", "%d comments", len(c.comments)) % len(c.comments)} ${ungettext("(%d inline)", "(%d inline)", c.inline_cnt) % c.inline_cnt}
%for path, lines in c.inline_comments: % for line,comments in lines.iteritems(): %endfor
+
${ungettext("%d comment", "%d comments", len(c.comments)) % len(c.comments)} ${ungettext("(%d inline)", "(%d inline)", c.inline_cnt) % c.inline_cnt}
% if c.limited_diff:
${_('Changeset was too big and was cut off...')} ${_('Show full diff anyway')}
% 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}"); }) diff --git a/kallithea/tests/functional/test_changeset_comments.py b/kallithea/tests/functional/test_changeset_comments.py --- a/kallithea/tests/functional/test_changeset_comments.py +++ b/kallithea/tests/functional/test_changeset_comments.py @@ -42,7 +42,7 @@ class TestChangeSetCommentsController(Te # test DB self.assertEqual(ChangesetComment.query().count(), 1) response.mustcontain('''
%s comment ''' - '''(0 inline)
''' % 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( '''
0 comments''' - ''' (%s inline)
''' % 1 + ''' (%s inline)''' % 1 ) response.mustcontain( '''''' % 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('''
0 comments''' - ''' (0 inline)
''') + ''' (0 inline)''')