File tree 7 files changed +74
-3
lines changed 7 files changed +74
-3
lines changed Original file line number Diff line number Diff line change @@ -752,11 +752,27 @@ func ViewPullFiles(ctx *context.Context) {
752
752
if ctx .Written () {
753
753
return
754
754
}
755
- ctx .Data ["CurrentReview" ], err = models .GetCurrentReview (ctx .Doer , issue )
755
+
756
+ currentReview , err := models .GetCurrentReview (ctx .Doer , issue )
756
757
if err != nil && ! models .IsErrReviewNotExist (err ) {
757
758
ctx .ServerError ("GetCurrentReview" , err )
758
759
return
759
760
}
761
+ numPendingCodeComments := int64 (0 )
762
+ if currentReview != nil {
763
+ numPendingCodeComments , err = models .CountComments (& models.FindCommentsOptions {
764
+ Type : models .CommentTypeCode ,
765
+ ReviewID : currentReview .ID ,
766
+ IssueID : issue .ID ,
767
+ })
768
+ if err != nil {
769
+ ctx .ServerError ("CountComments" , err )
770
+ return
771
+ }
772
+ }
773
+ ctx .Data ["CurrentReview" ] = currentReview
774
+ ctx .Data ["PendingCodeCommentNumber" ] = numPendingCodeComments
775
+
760
776
getBranchData (ctx , issue )
761
777
ctx .Data ["IsIssuePoster" ] = ctx .IsSigned && issue .IsPoster (ctx .Doer .ID )
762
778
ctx .Data ["HasIssuesOrPullsWritePermission" ] = ctx .Repo .CanWriteIssuesOrPulls (issue .IsPull )
Original file line number Diff line number Diff line change 37
37
<div class="comment-header-right actions df ac">
38
38
{{if and .Review}}
39
39
{{if eq .Review.Type 0}}
40
- <div class="ui label basic small yellow">
40
+ <div class="ui label basic small yellow pending-label ">
41
41
{{$.root.i18n.Tr "repo.issues.review.pending"}}
42
42
</div>
43
43
{{else}}
Original file line number Diff line number Diff line change 1
1
<div class="ui top right pointing dropdown custom" id="review-box">
2
2
<div class="ui tiny green button btn-review">
3
3
{{.i18n.Tr "repo.diff.review"}}
4
+ <span class="ui small label review-comments-counter" data-pending-comment-number="{{.PendingCodeCommentNumber}}">{{.PendingCodeCommentNumber}}</span>
4
5
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
5
6
</div>
6
7
<div class="menu review-box">
Original file line number Diff line number Diff line change @@ -6,8 +6,23 @@ import {validateTextareaNonEmpty} from './comp/EasyMDE.js';
6
6
const { csrfToken} = window . config ;
7
7
8
8
export function initRepoDiffReviewButton ( ) {
9
+ const $reviewBox = $ ( '#review-box' ) ;
10
+ const $counter = $reviewBox . find ( '.review-comments-counter' ) ;
11
+
9
12
$ ( document ) . on ( 'click' , 'button[name="is_review"]' , ( e ) => {
10
- $ ( e . target ) . closest ( 'form' ) . append ( '<input type="hidden" name="is_review" value="true">' ) ;
13
+ const $form = $ ( e . target ) . closest ( 'form' ) ;
14
+ $form . append ( '<input type="hidden" name="is_review" value="true">' ) ;
15
+
16
+ // Watch for the form's submit event.
17
+ $form . on ( 'submit' , ( ) => {
18
+ const num = parseInt ( $counter . attr ( 'data-pending-comment-number' ) ) + 1 || 1 ;
19
+ $counter . attr ( 'data-pending-comment-number' , num ) ;
20
+ $counter . text ( num ) ;
21
+ // Force the browser to reflow the DOM. This is to ensure that the browser replay the animation
22
+ $reviewBox . removeClass ( 'pulse' ) ;
23
+ $reviewBox . width ( ) ;
24
+ $reviewBox . addClass ( 'pulse' ) ;
25
+ } ) ;
11
26
} ) ;
12
27
}
13
28
Original file line number Diff line number Diff line change @@ -160,6 +160,16 @@ export function initRepoIssueCommentDelete() {
160
160
_csrf : csrfToken ,
161
161
} ) . done ( ( ) => {
162
162
const $conversationHolder = $this . closest ( '.conversation-holder' ) ;
163
+
164
+ // Check if this was a pending comment.
165
+ if ( $conversationHolder . find ( '.pending-label' ) . length ) {
166
+ const $counter = $ ( '#review-box .review-comments-counter' ) ;
167
+ let num = parseInt ( $counter . attr ( 'data-pending-comment-number' ) ) - 1 || 0 ;
168
+ num = Math . max ( num , 0 ) ;
169
+ $counter . attr ( 'data-pending-comment-number' , num ) ;
170
+ $counter . text ( num ) ;
171
+ }
172
+
163
173
$ ( `#${ $this . data ( 'comment-id' ) } ` ) . remove ( ) ;
164
174
if ( $conversationHolder . length && ! $conversationHolder . find ( '.comment' ) . length ) {
165
175
const path = $conversationHolder . data ( 'path' ) ;
Original file line number Diff line number Diff line change @@ -242,6 +242,19 @@ a.blob-excerpt:hover {
242
242
border : none !important ;
243
243
}
244
244
245
+ #review-box .review-comments-counter {
246
+ background-color : var (--color-primary-light-4 );
247
+ color : #fff ;
248
+ }
249
+
250
+ #review-box :hover .review-comments-counter {
251
+ background-color : var (--color-primary-light-5 );
252
+ }
253
+
254
+ #review-box .review-comments-counter [data- pending- comment- number= " 0" ] {
255
+ display : none ;
256
+ }
257
+
245
258
.pull.files.diff [id] {
246
259
scroll-margin-top : 99px ;
247
260
Original file line number Diff line number Diff line change 50
50
opacity : 0 ;
51
51
}
52
52
}
53
+
54
+ @keyframes pulse {
55
+ 0% {
56
+ transform : scale (1 );
57
+ }
58
+ 50% {
59
+ transform : scale (1.8 );
60
+ }
61
+ 100% {
62
+ transform : scale (1 );
63
+ }
64
+ }
65
+
66
+ .pulse {
67
+ animation : pulse 2s linear ;
68
+ }
You can’t perform that action at this time.
0 commit comments