Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add previous/next buttons to review comments #16273

Merged
merged 4 commits into from
Jun 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions templates/repo/diff/conversation.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@
</ui>
</div>
<div class="df je ac fw mt-3">
<div class="ui buttons mr-2">
<button class="ui icon tiny basic button previous-conversation">
{{svg "octicon-arrow-up"}} {{$.i18n.Tr "repo.issues.previous"}}
</button>
<button class="ui icon tiny basic button next-conversation">
{{svg "octicon-arrow-down"}} {{$.i18n.Tr "repo.issues.next"}}
</button>
</div>
{{if and $.CanMarkConversation $isNotPending}}
<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">
{{if $resolved}}
Expand Down
22 changes: 22 additions & 0 deletions web_src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,28 @@ async function initRepository() {
action: 'hide'
});

// Previous/Next code review conversation
$(document).on('click', '.previous-conversation', (e) => {
const $conversation = $(e.currentTarget).closest('.comment-code-cloud');
const $conversations = $('.comment-code-cloud:not(.hide)');
const index = $conversations.index($conversation);
if (index !== 0) {
const $previousConversation = $conversations.eq(index - 1);
const anchor = $previousConversation.find('.comment').first().attr('id');
window.location.href = `#${anchor}`;
}
});
$(document).on('click', '.next-conversation', (e) => {
const $conversation = $(e.currentTarget).closest('.comment-code-cloud');
const $conversations = $('.comment-code-cloud:not(.hide)');
const index = $conversations.index($conversation);
if (index !== $conversations.length - 1) {
const $nextConversation = $conversations.eq(index + 1);
const anchor = $nextConversation.find('.comment').first().attr('id');
window.location.href = `#${anchor}`;
}
});

// Quote reply
$(document).on('click', '.quote-reply', function (event) {
$(this).closest('.dropdown').find('.menu').toggle('visible');
Expand Down