@@ -54,6 +54,9 @@ export default class ReviewsView extends React.Component {
5454 threadIDsOpen : PropTypes . shape ( {
5555 has : PropTypes . func . isRequired ,
5656 } ) ,
57+ highlightedThreadIDs : PropTypes . shape ( {
58+ has : PropTypes . func . isRequired ,
59+ } ) ,
5760 postingToThreadID : PropTypes . string ,
5861 scrollToThreadID : PropTypes . string ,
5962 // Structure: Map< relativePath: String, {
@@ -110,26 +113,14 @@ export default class ReviewsView extends React.Component {
110113 componentDidMount ( ) {
111114 const { scrollToThreadID} = this . props ;
112115 if ( scrollToThreadID ) {
113- const threadHolder = this . threadHolders . get ( scrollToThreadID ) ;
114- if ( threadHolder ) {
115- threadHolder . map ( element => {
116- element . scrollIntoViewIfNeeded ( ) ;
117- return null ; // shh, eslint
118- } ) ;
119- }
116+ this . scrollToThread ( scrollToThreadID ) ;
120117 }
121118 }
122119
123120 componentDidUpdate ( prevProps ) {
124121 const { scrollToThreadID} = this . props ;
125122 if ( scrollToThreadID && scrollToThreadID !== prevProps . scrollToThreadID ) {
126- const threadHolder = this . threadHolders . get ( scrollToThreadID ) ;
127- if ( threadHolder ) {
128- threadHolder . map ( element => {
129- element . scrollIntoViewIfNeeded ( ) ;
130- return null ; // shh, eslint
131- } ) ;
132- }
123+ this . scrollToThread ( scrollToThreadID ) ;
133124 }
134125 }
135126
@@ -309,7 +300,8 @@ export default class ReviewsView extends React.Component {
309300 return null ;
310301 }
311302
312- const resolvedThreads = commentThreads . filter ( pair => pair . thread . isResolved ) . length ;
303+ const resolvedThreads = commentThreads . filter ( pair => pair . thread . isResolved ) ;
304+ const unresolvedThreads = commentThreads . filter ( pair => ! pair . thread . isResolved ) ;
313305
314306 const toggleComments = evt => {
315307 evt . preventDefault ( ) ;
@@ -330,16 +322,28 @@ export default class ReviewsView extends React.Component {
330322 < span className = "github-Reviews-progress" >
331323 < span className = "github-Reviews-count" >
332324 Resolved
333- { ' ' } < span className = "github-Reviews-countNr" > { resolvedThreads } </ span > { ' ' }
325+ { ' ' } < span className = "github-Reviews-countNr" > { resolvedThreads . length } </ span > { ' ' }
334326 of
335- { ' ' } < span className = "github-Reviews-countNr" > { commentThreads . length } </ span >
327+ { ' ' } < span className = "github-Reviews-countNr" > { resolvedThreads . length + unresolvedThreads . length } </ span >
336328 </ span >
337- < progress className = "github-Reviews-progessBar" value = { resolvedThreads } max = { commentThreads . length } />
329+ < progress
330+ className = "github-Reviews-progessBar" value = { resolvedThreads . length }
331+ max = { resolvedThreads . length + unresolvedThreads . length }
332+ />
338333 </ span >
339334 </ summary >
340- < main className = "github-Reviews-container" >
341- { commentThreads . map ( this . renderReviewCommentThread ) }
342- </ main >
335+
336+ { unresolvedThreads . length > 0 && < main className = "github-Reviews-container" >
337+ { unresolvedThreads . map ( this . renderReviewCommentThread ) }
338+ </ main > }
339+ { resolvedThreads . length > 0 && < details className = "github-Reviews-section resolved-comments" open >
340+ < summary className = "github-Reviews-header" >
341+ < span className = "github-Reviews-title" > Resolved</ span >
342+ </ summary >
343+ < main className = "github-Reviews-container" >
344+ { resolvedThreads . map ( this . renderReviewCommentThread ) }
345+ </ main >
346+ </ details > }
343347
344348 </ details >
345349 ) ;
@@ -372,7 +376,7 @@ export default class ReviewsView extends React.Component {
372376 const openDiffClasses = cx ( 'icon-diff' , ...navButtonClasses ) ;
373377
374378 const isOpen = this . props . threadIDsOpen . has ( thread . id ) ;
375- const isHighlighted = this . props . scrollToThreadID === thread . id ;
379+ const isHighlighted = this . props . highlightedThreadIDs . has ( thread . id ) ;
376380 const toggle = evt => {
377381 evt . preventDefault ( ) ;
378382 evt . stopPropagation ( ) ;
@@ -495,7 +499,7 @@ export default class ReviewsView extends React.Component {
495499 < button
496500 className = "github-Review-resolveButton btn icon icon-check"
497501 title = "Unresolve conversation"
498- onClick = { ( ) => this . props . unresolveThread ( thread ) } >
502+ onClick = { ( ) => this . resolveUnresolveThread ( thread ) } >
499503 Unresolve conversation
500504 </ button >
501505 ) ;
@@ -504,7 +508,7 @@ export default class ReviewsView extends React.Component {
504508 < button
505509 className = "github-Review-resolveButton btn icon icon-check"
506510 title = "Resolve conversation"
507- onClick = { ( ) => this . props . resolveThread ( thread ) } >
511+ onClick = { ( ) => this . resolveUnresolveThread ( thread ) } >
508512 Resolve conversation
509513 </ button >
510514 ) ;
@@ -646,4 +650,23 @@ export default class ReviewsView extends React.Component {
646650
647651 return { lineNumber, positionText} ;
648652 }
653+
654+ /* istanbul ignore next */
655+ scrollToThread ( threadID ) {
656+ const threadHolder = this . threadHolders . get ( threadID ) ;
657+ if ( threadHolder ) {
658+ threadHolder . map ( element => {
659+ element . scrollIntoViewIfNeeded ( ) ;
660+ return null ; // shh, eslint
661+ } ) ;
662+ }
663+ }
664+
665+ async resolveUnresolveThread ( thread ) {
666+ if ( thread . isResolved ) {
667+ await this . props . unresolveThread ( thread ) ;
668+ } else {
669+ await this . props . resolveThread ( thread ) ;
670+ }
671+ }
649672}
0 commit comments