Skip to content

Commit fe66b61

Browse files
jpraetnoerwzeripath
authored
Add previous/next buttons to review comments (#16273)
Co-authored-by: Norwin <[email protected]> Signed-off-by: Andrew Thornton <[email protected]> Co-authored-by: zeripath <[email protected]>
1 parent 9b1b4b5 commit fe66b61

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

templates/repo/diff/conversation.tmpl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@
2727
</ui>
2828
</div>
2929
<div class="df je ac fw mt-3">
30+
<div class="ui buttons mr-2">
31+
<button class="ui icon tiny basic button previous-conversation">
32+
{{svg "octicon-arrow-up"}} {{$.i18n.Tr "repo.issues.previous"}}
33+
</button>
34+
<button class="ui icon tiny basic button next-conversation">
35+
{{svg "octicon-arrow-down"}} {{$.i18n.Tr "repo.issues.next"}}
36+
</button>
37+
</div>
3038
{{if and $.CanMarkConversation $isNotPending}}
3139
<button class="ui icon tiny basic button resolve-conversation" data-origin="diff" data-action="{{if not $resolved}}Resolve{{else}}UnResolve{{end}}" data-comment-id="{{(index .comments 0).ID}}" data-update-url="{{$.RepoLink}}/issues/resolve_conversation">
3240
{{if $resolved}}

web_src/js/index.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -942,6 +942,28 @@ async function initRepository() {
942942
action: 'hide'
943943
});
944944

945+
// Previous/Next code review conversation
946+
$(document).on('click', '.previous-conversation', (e) => {
947+
const $conversation = $(e.currentTarget).closest('.comment-code-cloud');
948+
const $conversations = $('.comment-code-cloud:not(.hide)');
949+
const index = $conversations.index($conversation);
950+
if (index !== 0) {
951+
const $previousConversation = $conversations.eq(index - 1);
952+
const anchor = $previousConversation.find('.comment').first().attr('id');
953+
window.location.href = `#${anchor}`;
954+
}
955+
});
956+
$(document).on('click', '.next-conversation', (e) => {
957+
const $conversation = $(e.currentTarget).closest('.comment-code-cloud');
958+
const $conversations = $('.comment-code-cloud:not(.hide)');
959+
const index = $conversations.index($conversation);
960+
if (index !== $conversations.length - 1) {
961+
const $nextConversation = $conversations.eq(index + 1);
962+
const anchor = $nextConversation.find('.comment').first().attr('id');
963+
window.location.href = `#${anchor}`;
964+
}
965+
});
966+
945967
// Quote reply
946968
$(document).on('click', '.quote-reply', function (event) {
947969
$(this).closest('.dropdown').find('.menu').toggle('visible');

0 commit comments

Comments
 (0)