mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 21:28:11 +09:00 
			
		
		
		
	Improve reviewing PR UX (#19612)
This commit is contained in:
		| @@ -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'); | ||||
|     }); | ||||
|   }); | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -160,6 +160,16 @@ export function initRepoIssueCommentDelete() { | ||||
|         _csrf: csrfToken, | ||||
|       }).done(() => { | ||||
|         const $conversationHolder = $this.closest('.conversation-holder'); | ||||
|  | ||||
|         // Check if this was a pending comment. | ||||
|         if ($conversationHolder.find('.pending-label').length) { | ||||
|           const $counter = $('#review-box .review-comments-counter'); | ||||
|           let num = parseInt($counter.attr('data-pending-comment-number')) - 1 || 0; | ||||
|           num = Math.max(num, 0); | ||||
|           $counter.attr('data-pending-comment-number', num); | ||||
|           $counter.text(num); | ||||
|         } | ||||
|  | ||||
|         $(`#${$this.data('comment-id')}`).remove(); | ||||
|         if ($conversationHolder.length && !$conversationHolder.find('.comment').length) { | ||||
|           const path = $conversationHolder.data('path'); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user