File tree Expand file tree Collapse file tree 7 files changed +74
-3
lines changed Expand file tree Collapse file tree 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) {
752752 if ctx .Written () {
753753 return
754754 }
755- ctx .Data ["CurrentReview" ], err = models .GetCurrentReview (ctx .Doer , issue )
755+
756+ currentReview , err := models .GetCurrentReview (ctx .Doer , issue )
756757 if err != nil && ! models .IsErrReviewNotExist (err ) {
757758 ctx .ServerError ("GetCurrentReview" , err )
758759 return
759760 }
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+
760776 getBranchData (ctx , issue )
761777 ctx .Data ["IsIssuePoster" ] = ctx .IsSigned && issue .IsPoster (ctx .Doer .ID )
762778 ctx .Data ["HasIssuesOrPullsWritePermission" ] = ctx .Repo .CanWriteIssuesOrPulls (issue .IsPull )
Original file line number Diff line number Diff line change 3737 <div class="comment-header-right actions df ac">
3838 {{if and .Review}}
3939 {{if eq .Review.Type 0}}
40- <div class="ui label basic small yellow">
40+ <div class="ui label basic small yellow pending-label ">
4141 {{$.root.i18n.Tr "repo.issues.review.pending"}}
4242 </div>
4343 {{else}}
Original file line number Diff line number Diff line change 11<div class="ui top right pointing dropdown custom" id="review-box">
22 <div class="ui tiny green button btn-review">
33 {{.i18n.Tr "repo.diff.review"}}
4+ <span class="ui small label review-comments-counter" data-pending-comment-number="{{.PendingCodeCommentNumber}}">{{.PendingCodeCommentNumber}}</span>
45 {{svg "octicon-triangle-down" 14 "dropdown icon"}}
56 </div>
67 <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';
66const { csrfToken} = window . config ;
77
88export function initRepoDiffReviewButton ( ) {
9+ const $reviewBox = $ ( '#review-box' ) ;
10+ const $counter = $reviewBox . find ( '.review-comments-counter' ) ;
11+
912 $ ( 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+ } ) ;
1126 } ) ;
1227}
1328
Original file line number Diff line number Diff line change @@ -160,6 +160,16 @@ export function initRepoIssueCommentDelete() {
160160 _csrf : csrfToken ,
161161 } ) . done ( ( ) => {
162162 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+
163173 $ ( `#${ $this . data ( 'comment-id' ) } ` ) . remove ( ) ;
164174 if ( $conversationHolder . length && ! $conversationHolder . find ( '.comment' ) . length ) {
165175 const path = $conversationHolder . data ( 'path' ) ;
Original file line number Diff line number Diff line change @@ -242,6 +242,19 @@ a.blob-excerpt:hover {
242242 border : none !important ;
243243}
244244
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+
245258.pull.files.diff [id] {
246259 scroll-margin-top : 99px ;
247260
Original file line number Diff line number Diff line change 5050 opacity : 0 ;
5151 }
5252}
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