@@ -86,7 +86,7 @@ export function CommentView(commentProps: Props) {
8686 onMouseLeave = { ( ) => setShowActionBar ( false ) }
8787 onFocus = { ( ) => setShowActionBar ( true ) }
8888 >
89- { ariaAnnouncement ? < div role = 'alert' aria-label = { ariaAnnouncement } /> : null }
89+ { ariaAnnouncement ? < div role = 'alert' aria-label = { ariaAnnouncement } /> : null }
9090 < div className = "action-bar comment-actions" style = { { display : showActionBar ? 'flex' : 'none' } } >
9191 < button
9292 title = "Quote reply"
@@ -290,8 +290,45 @@ export const CommentBody = ({ comment, bodyHTML, body, canApplyPatch, allowEmpty
290290 < div className = "comment-body" >
291291 { renderedBody }
292292 { applyPatchButton }
293- { specialDisplayBodyPostfix ? < br /> : null }
293+ { specialDisplayBodyPostfix ? < br /> : null }
294294 { specialDisplayBodyPostfix ? < em > { specialDisplayBodyPostfix } </ em > : null }
295+ < CommentReactions reactions = { comment ?. reactions } />
296+ </ div >
297+ ) ;
298+ } ;
299+
300+ type CommentReactionsProps = {
301+ reactions ?: { label : string ; count : number ; reactors : readonly string [ ] } [ ] ;
302+ } ;
303+
304+ const CommentReactions = ( { reactions } : CommentReactionsProps ) => {
305+ if ( ! Array . isArray ( reactions ) || reactions . length === 0 ) return null ;
306+ const filtered = reactions . filter ( r => r . count > 0 ) ;
307+ if ( filtered . length === 0 ) return null ;
308+ return (
309+ < div className = "comment-reactions" style = { { marginTop : 6 } } >
310+ { filtered . map ( ( reaction , idx ) => {
311+ const maxReactors = 10 ;
312+ const reactors = reaction . reactors || [ ] ;
313+ const displayReactors = reactors . slice ( 0 , maxReactors ) ;
314+ const moreCount = reactors . length > maxReactors ? reactors . length - maxReactors : 0 ;
315+ let title : string = '' ;
316+ if ( displayReactors . length > 0 ) {
317+ if ( moreCount > 0 ) {
318+ title = `${ joinWithAnd ( displayReactors ) } and ${ moreCount } more reacted with ${ reaction . label } ` ;
319+ } else {
320+ title = `${ joinWithAnd ( displayReactors ) } reacted with ${ reaction . label } ` ;
321+ }
322+ }
323+ return (
324+ < div
325+ key = { reaction . label + idx }
326+ title = { title }
327+ >
328+ < span className = "reaction-label" > { reaction . label } </ span > { nbsp } { reaction . count > 1 ? < span className = "reaction-count" > { reaction . count } </ span > : null }
329+ </ div >
330+ ) ;
331+ } ) }
295332 </ div >
296333 ) ;
297334} ;
@@ -302,7 +339,6 @@ export function AddComment({
302339 hasWritePermission,
303340 isIssue,
304341 isAuthor,
305- isDraft,
306342 continueOnGitHub,
307343 currentUserReviewState,
308344 lastReviewType,
@@ -468,7 +504,7 @@ export const AddCommentSimple = (pr: PullRequest) => {
468504 const { updatePR, requestChanges, approve, submit, openOnGitHub } = useContext ( PullRequestContext ) ;
469505 const [ isBusy , setBusy ] = useState ( false ) ;
470506 const textareaRef = useRef < HTMLTextAreaElement > ( ) ;
471- let currentSelection : ReviewType = pr . lastReviewType ?? ( pr . currentUserReviewState === 'APPROVED' ? ReviewType . Approve : ( pr . currentUserReviewState === 'CHANGES_REQUESTED' ? ReviewType . RequestChanges : ReviewType . Comment ) ) ;
507+ let currentSelection : ReviewType = pr . lastReviewType ?? ( pr . currentUserReviewState === 'APPROVED' ? ReviewType . Approve : ( pr . currentUserReviewState === 'CHANGES_REQUESTED' ? ReviewType . RequestChanges : ReviewType . Comment ) ) ;
472508
473509 async function submitAction ( action : ReviewType ) : Promise < void > {
474510 const { value } = textareaRef . current ! ;
@@ -558,3 +594,10 @@ export const AddCommentSimple = (pr: PullRequest) => {
558594 </ span >
559595 ) ;
560596} ;
597+
598+ function joinWithAnd ( arr : string [ ] ) : string {
599+ if ( arr . length === 0 ) return '' ;
600+ if ( arr . length === 1 ) return arr [ 0 ] ;
601+ if ( arr . length === 2 ) return `${ arr [ 0 ] } and ${ arr [ 1 ] } ` ;
602+ return `${ arr . slice ( 0 , - 1 ) . join ( ', ' ) } and ${ arr [ arr . length - 1 ] } ` ;
603+ }
0 commit comments