11import { GlobalShortcutParam } from '@/slackTypes' ;
22import { userRepo } from '@repos/userRepo' ;
33import { App } from '@slack/bolt' ;
4- import { View } from '@slack/types' ;
4+ import { KnownBlock , View } from '@slack/types' ;
55import log from '@utils/log' ;
6- import { ul } from '@utils/text' ;
7- import { Interaction } from './enums' ;
6+ import { bold , formatSlot , mention , ul } from '@utils/text' ;
7+ import { InterviewFormatLabel , Interaction } from './enums' ;
88import { activeReviewRepo } from '@repos/activeReviewsRepo' ;
99import { ActiveReview } from '@models/ActiveReview' ;
1010import { User } from '@models/User' ;
1111import { reviewActionService } from '@/services/ReviewActionService' ;
12+ import { pairingSessionsRepo } from '@repos/pairingSessionsRepo' ;
13+ import { PairingSession } from '@models/PairingSession' ;
1214
1315export const getReviewInfo = {
1416 app : undefined as unknown as App ,
@@ -51,6 +53,60 @@ export const getReviewInfo = {
5153 } ;
5254 } ,
5355
56+ pairingDialog ( session : PairingSession ) : View {
57+ const blocks : KnownBlock [ ] = [
58+ {
59+ type : 'section' ,
60+ text : {
61+ type : 'mrkdwn' ,
62+ text : `:mag: Pairing session for ${ bold ( session . candidateName ) } — requested by ${ mention ( { id : session . requestorId } ) } .` ,
63+ } ,
64+ } ,
65+ { type : 'divider' } ,
66+ {
67+ type : 'section' ,
68+ text : {
69+ type : 'mrkdwn' ,
70+ text : ul (
71+ `${ bold ( 'Format:' ) } ${ InterviewFormatLabel . get ( session . format ) ?? session . format } ` ,
72+ `${ bold ( 'Languages:' ) } ${ session . languages . join ( ', ' ) } ` ,
73+ `${ bold ( 'Teammates needed per slot:' ) } ${ session . teammatesNeededCount } ` ,
74+ `${ bold ( 'Pending responses:' ) } ${ session . pendingTeammates . length } ` ,
75+ `${ bold ( 'Declined:' ) } ${ session . declinedTeammates . length } ` ,
76+ ) ,
77+ } ,
78+ } ,
79+ { type : 'divider' } ,
80+ {
81+ type : 'section' ,
82+ text : {
83+ type : 'mrkdwn' ,
84+ text : bold (
85+ `Candidate availability (${ session . slots . length } slot${ session . slots . length !== 1 ? 's' : '' } ):` ,
86+ ) ,
87+ } ,
88+ } ,
89+ ...session . slots . map < KnownBlock > ( slot => ( {
90+ type : 'section' ,
91+ text : {
92+ type : 'mrkdwn' ,
93+ text : ul (
94+ `${ formatSlot ( slot . date , slot . startTime , slot . endTime ) } — ${ slot . interestedTeammates . length } interested${
95+ slot . interestedTeammates . length > 0
96+ ? `: ${ slot . interestedTeammates . map ( t => mention ( { id : t . userId } ) ) . join ( ', ' ) } `
97+ : ''
98+ } `,
99+ ) ,
100+ } ,
101+ } ) ) ,
102+ ] ;
103+ return {
104+ title : { text : 'Pairing Session Info' , type : 'plain_text' } ,
105+ type : 'modal' ,
106+ blocks,
107+ } ;
108+ } ,
109+
54110 missingReviewDialog ( ) : View {
55111 return {
56112 title : {
@@ -74,19 +130,27 @@ export const getReviewInfo = {
74130 log . d ( 'getReviewInfo.shortcut' , `Requesting review info, user.id=${ shortcut . user . id } ` ) ;
75131 await ack ( ) ;
76132
133+ const threadTs = shortcut . message . ts ;
134+
135+ const pairingSession = await pairingSessionsRepo . getByThreadIdOrUndefined ( threadTs ) ;
136+ if ( pairingSession ) {
137+ await client . views . open ( {
138+ trigger_id : shortcut . trigger_id ,
139+ view : this . pairingDialog ( pairingSession ) ,
140+ } ) ;
141+ return ;
142+ }
143+
77144 try {
78- const activeReview = await activeReviewRepo . getReviewByThreadIdOrFail ( shortcut . message . ts ) ;
145+ const activeReview = await activeReviewRepo . getReviewByThreadIdOrFail ( threadTs ) ;
79146 const allUsers = await userRepo . listAll ( ) ;
80147 await client . views . open ( {
81148 trigger_id : shortcut . trigger_id ,
82149 view : this . dialog ( activeReview , allUsers ) ,
83150 } ) ;
84151 // eslint-disable-next-line @typescript-eslint/no-explicit-any
85152 } catch ( _err : any ) {
86- log . d (
87- 'getReviewInfo.shortcut' ,
88- `Unable to find active review with ts ${ shortcut . message . ts } ` ,
89- ) ;
153+ log . d ( 'getReviewInfo.shortcut' , `Unable to find active review with ts ${ threadTs } ` ) ;
90154 await client . views . open ( {
91155 trigger_id : shortcut . trigger_id ,
92156 view : this . missingReviewDialog ( ) ,
0 commit comments