44 CommentIcon ,
55 IssueOpenedIcon ,
66 MilestoneIcon ,
7+ SmileyIcon ,
78 TagIcon ,
89} from '@primer/octicons-react' ;
910
@@ -27,22 +28,72 @@ export const MetricGroup: FC<MetricGroupProps> = ({
2728 const hasLinkedIssues = linkedIssues . length > 0 ;
2829 const linkedIssuesPillDescription = hasLinkedIssues
2930 ? `Linked to ${
30- linkedIssues . length > 1 ? 'issues' : 'issue'
31+ linkedIssues . length > 1 ? 'issues: ' : 'issue'
3132 } ${ linkedIssues . join ( ', ' ) } `
3233 : '' ;
3334
35+ const reactionCount = notification . subject . reactionsCount ?? 0 ;
36+ const reactionGroups = notification . subject . reactionGroups ?? [ ] ;
37+ const hasReactions = reactionCount > 0 ;
38+ const hasMultipleReactions =
39+ reactionGroups . filter ( ( rg ) => rg . reactors . totalCount > 0 ) . length > 1 ;
40+ const reactionPillDescription = hasReactions
41+ ? `${ reactionCount } ${
42+ reactionCount > 1 ? 'reactions' : 'reaction'
43+ } : ${ reactionGroups
44+ . reduce ( ( acc , rg ) => {
45+ if ( ! rg . reactors . totalCount || rg . reactors . totalCount <= 0 ) {
46+ return acc ;
47+ }
48+
49+ let emoji = '' ;
50+ switch ( rg . content ) {
51+ case 'THUMBS_UP' :
52+ emoji = '👍' ;
53+ break ;
54+ case 'THUMBS_DOWN' :
55+ emoji = '👎' ;
56+ break ;
57+ case 'LAUGH' :
58+ emoji = '😆' ;
59+ break ;
60+ case 'HOORAY' :
61+ emoji = '🎉' ;
62+ break ;
63+ case 'CONFUSED' :
64+ emoji = '😕' ;
65+ break ;
66+ case 'ROCKET' :
67+ emoji = '🚀' ;
68+ break ;
69+ case 'EYES' :
70+ emoji = '👀' ;
71+ break ;
72+ case 'HEART' :
73+ emoji = '❤️' ;
74+ break ;
75+ default :
76+ return acc ;
77+ }
78+ acc . push (
79+ `${ emoji } ${ hasMultipleReactions ? rg . reactors . totalCount : '' } ` . trim ( ) ,
80+ ) ;
81+ return acc ;
82+ } , [ ] as string [ ] )
83+ . join ( ' ' ) } `
84+ : '' ;
85+
3486 const commentCount = notification . subject . commentCount ?? 0 ;
3587 const hasComments = commentCount > 0 ;
3688 const commentsPillDescription = hasComments
37- ? `${ notification . subject . commentCount } ${
38- notification . subject . commentCount > 1 ? 'comments' : 'comment'
39- } `
89+ ? `${ notification . subject . commentCount } ${ notification . subject . commentCount > 1 ? 'comments' : 'comment' } `
4090 : '' ;
4191
4292 const labels = notification . subject . labels ?? [ ] ;
43- const hasLabels = labels . length > 0 ;
93+ const labelsCount = labels . length ;
94+ const hasLabels = labelsCount > 0 ;
4495 const labelsPillDescription = hasLabels
45- ? labels . map ( ( label ) => `🏷️ ${ label } ` ) . join ( ', ' )
96+ ? ` ${ labelsCount } ${ labelsCount > 1 ? ' labels' : 'label' } : ${ labels . map ( ( label ) => `🏷️ ${ label } ` ) . join ( ', ' ) } `
4697 : '' ;
4798
4899 const milestone = notification . subject . milestone ;
@@ -59,6 +110,15 @@ export const MetricGroup: FC<MetricGroupProps> = ({
59110 />
60111 ) }
61112
113+ { hasReactions && (
114+ < MetricPill
115+ color = { IconColor . GRAY }
116+ icon = { SmileyIcon }
117+ metric = { notification . subject . reactionsCount }
118+ title = { reactionPillDescription }
119+ />
120+ ) }
121+
62122 { notification . subject . reviews ?. map ( ( review ) => {
63123 const icon = getPullRequestReviewIcon ( review ) ;
64124 if ( ! icon ) {
0 commit comments