aboutsummaryrefslogtreecommitdiff
path: root/web_src
diff options
context:
space:
mode:
authorwxiaoguang2023-03-04 15:13:37 +0800
committerGitHub2023-03-04 02:13:37 -0500
commit188c8c12c290e131fb342e3203634828652b0af5 (patch)
tree228bd46aa0aed2f059e7bd5a71ab42e7ceebe52e /web_src
parent47b912cd526207f831bff759b29a734049d1c8f2 (diff)
Make Ctrl+Enter submit a pending comment (starting review) instead of submitting a single comment (#23245)
Close #23241 Before: press Ctrl+Enter in the Code Review Form, a single comment will be added. After: press Ctrl+Enter in the Code Review Form, start the review with pending comments. The old name `is_review` is not clear, so the new code use `pending_review` as the new name. Co-authored-by: delvh <leon@kske.dev> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'web_src')
-rw-r--r--web_src/js/features/repo-diff.js14
-rw-r--r--web_src/js/features/repo-issue.js2
-rw-r--r--web_src/less/_repository.less6
3 files changed, 12 insertions, 10 deletions
diff --git a/web_src/js/features/repo-diff.js b/web_src/js/features/repo-diff.js
index d2559b123..56ebe4fc9 100644
--- a/web_src/js/features/repo-diff.js
+++ b/web_src/js/features/repo-diff.js
@@ -11,10 +11,8 @@ export function initRepoDiffReviewButton() {
const $reviewBox = $('#review-box');
const $counter = $reviewBox.find('.review-comments-counter');
- $(document).on('click', 'button[name="is_review"]', (e) => {
+ $(document).on('click', 'button[name="pending_review"]', (e) => {
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;
@@ -50,7 +48,15 @@ export function initRepoDiffConversationForm() {
return;
}
- const formDataString = String(new URLSearchParams(new FormData($form[0])));
+ const formData = new FormData($form[0]);
+
+ // if the form is submitted by a button, append the button's name and value to the form data
+ const submitter = e.originalEvent?.submitter;
+ const isSubmittedByButton = (submitter?.nodeName === 'BUTTON') || (submitter?.nodeName === 'INPUT' && submitter.type === 'submit');
+ if (isSubmittedByButton && submitter.name) {
+ formData.append(submitter.name, submitter.value);
+ }
+ const formDataString = String(new URLSearchParams(formData));
const $newConversationHolder = $(await $.post($form.attr('action'), formDataString));
const {path, side, idx} = $newConversationHolder.data();
diff --git a/web_src/js/features/repo-issue.js b/web_src/js/features/repo-issue.js
index 4163fb120..41c9dd118 100644
--- a/web_src/js/features/repo-issue.js
+++ b/web_src/js/features/repo-issue.js
@@ -535,7 +535,7 @@ export function initRepoPullRequestReview() {
const td = ntr.find(`.add-comment-${side}`);
let commentCloud = td.find('.comment-code-cloud');
- if (commentCloud.length === 0 && !ntr.find('button[name="is_review"]').length) {
+ if (commentCloud.length === 0 && !ntr.find('button[name="pending_review"]').length) {
const data = await $.get($(this).closest('[data-new-comment-url]').data('new-comment-url'));
td.html(data);
commentCloud = td.find('.comment-code-cloud');
diff --git a/web_src/less/_repository.less b/web_src/less/_repository.less
index abbacfb53..9eaa8644f 100644
--- a/web_src/less/_repository.less
+++ b/web_src/less/_repository.less
@@ -963,10 +963,6 @@
}
}
- .comment-form-reply .footer {
- padding-bottom: 1em;
- }
-
@media @mediaSm {
.ui.segments {
margin-left: -2rem;
@@ -3282,7 +3278,7 @@ td.blob-excerpt {
position: sticky;
top: 77px;
z-index: 7;
-
+
@media (max-width: 480px) {
position: static;
}