diff options
Diffstat (limited to 'web_src')
-rw-r--r-- | web_src/js/features/repo-diff.js | 17 | ||||
-rw-r--r-- | web_src/js/features/repo-issue.js | 10 | ||||
-rw-r--r-- | web_src/less/_review.less | 13 | ||||
-rw-r--r-- | web_src/less/animations.less | 16 |
4 files changed, 55 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'); + }); }); } diff --git a/web_src/js/features/repo-issue.js b/web_src/js/features/repo-issue.js index a39a704f47..4e077c14e2 100644 --- a/web_src/js/features/repo-issue.js +++ b/web_src/js/features/repo-issue.js @@ -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'); diff --git a/web_src/less/_review.less b/web_src/less/_review.less index eddd32fa66..8bc41b9736 100644 --- a/web_src/less/_review.less +++ b/web_src/less/_review.less @@ -242,6 +242,19 @@ a.blob-excerpt:hover { border: none !important; } +#review-box .review-comments-counter { + background-color: var(--color-primary-light-4); + color: #fff; +} + +#review-box:hover .review-comments-counter { + background-color: var(--color-primary-light-5); +} + +#review-box .review-comments-counter[data-pending-comment-number="0"] { + display: none; +} + .pull.files.diff [id] { scroll-margin-top: 99px; diff --git a/web_src/less/animations.less b/web_src/less/animations.less index 083e10089d..92a3052a1f 100644 --- a/web_src/less/animations.less +++ b/web_src/less/animations.less @@ -50,3 +50,19 @@ opacity: 0; } } + +@keyframes pulse { + 0% { + transform: scale(1); + } + 50% { + transform: scale(1.8); + } + 100% { + transform: scale(1); + } +} + +.pulse { + animation: pulse 2s linear; +} |