summaryrefslogtreecommitdiffstats
path: root/web_src/js/features/repo-diff.js
diff options
context:
space:
mode:
authorGusted <williamzijl7@hotmail.com>2022-05-07 05:35:12 +0000
committerGitHub <noreply@github.com>2022-05-07 01:35:12 -0400
commit0eac09e0662ae70b8b6e3e5e8c33547c79ff7124 (patch)
treed5dc0a6ed8c4c1b92a273277380300289103d328 /web_src/js/features/repo-diff.js
parent5a9c505e148a06cc652cab52bf7a59b23e605282 (diff)
downloadgitea-0eac09e0662ae70b8b6e3e5e8c33547c79ff7124.tar.gz
gitea-0eac09e0662ae70b8b6e3e5e8c33547c79ff7124.zip
Improve reviewing PR UX (#19612)
Diffstat (limited to 'web_src/js/features/repo-diff.js')
-rw-r--r--web_src/js/features/repo-diff.js17
1 files changed, 16 insertions, 1 deletions
diff --git a/web_src/js/features/repo-diff.js b/web_src/js/features/repo-diff.js
index 45dad52fb1..013b8d3fa0 100644
--- a/web_src/js/features/repo-diff.js
+++ b/web_src/js/features/repo-diff.js
@@ -6,8 +6,23 @@ import {validateTextareaNonEmpty} from './comp/EasyMDE.js';
const {csrfToken} = window.config;
export function initRepoDiffReviewButton() {
+ const $reviewBox = $('#review-box');
+ const $counter = $reviewBox.find('.review-comments-counter');
+
$(document).on('click', 'button[name="is_review"]', (e) => {
- $(e.target).closest('form').append('<input type="hidden" name="is_review" value="true">');
+ const $form = $(e.target).closest('form');
+ $form.append('<input type="hidden" name="is_review" value="true">');
+
+ // Watch for the form's submit event.
+ $form.on('submit', () => {
+ const num = parseInt($counter.attr('data-pending-comment-number')) + 1 || 1;
+ $counter.attr('data-pending-comment-number', num);
+ $counter.text(num);
+ // Force the browser to reflow the DOM. This is to ensure that the browser replay the animation
+ $reviewBox.removeClass('pulse');
+ $reviewBox.width();
+ $reviewBox.addClass('pulse');
+ });
});
}