File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -126,14 +126,20 @@ export class PRContext {
126126 this . updatePR ( { pendingCommentDrafts : pendingCommentDrafts } ) ;
127127 } ;
128128
129- public requestChanges = async ( body : string ) =>
130- this . appendReview ( await this . postMessage ( { command : 'pr.request-changes' , args : body } ) ) ;
129+ private async submitReviewCommand ( command : string , body : string ) {
130+ try {
131+ const result : SubmitReviewReply = await this . postMessage ( { command, args : body } ) ;
132+ return this . appendReview ( result ) ;
133+ } catch ( error ) {
134+ return this . updatePR ( { busy : false } ) ;
135+ }
136+ }
137+
138+ public requestChanges = ( body : string ) => this . submitReviewCommand ( 'pr.request-changes' , body ) ;
131139
132- public approve = async ( body : string ) =>
133- this . appendReview ( await this . postMessage ( { command : 'pr.approve' , args : body } ) ) ;
140+ public approve = ( body : string ) => this . submitReviewCommand ( 'pr.approve' , body ) ;
134141
135- public submit = async ( body : string ) =>
136- this . appendReview ( await this . postMessage ( { command : 'pr.submit' , args : body } ) ) ;
142+ public submit = ( body : string ) => this . submitReviewCommand ( 'pr.submit' , body ) ;
137143
138144 public close = async ( body ?: string ) => {
139145 try {
Original file line number Diff line number Diff line change @@ -209,7 +209,7 @@ function AddReviewSummaryComment() {
209209 const comment = useRef < HTMLTextAreaElement > ( ) ;
210210 const [ isBusy , setBusy ] = useState ( false ) ;
211211
212- async function submitAction ( event : React . MouseEvent , action : ReviewType ) : Promise < void > {
212+ async function submitAction ( event : React . MouseEvent | React . KeyboardEvent , action : ReviewType ) : Promise < void > {
213213 event . preventDefault ( ) ;
214214 const { value } = comment . current ! ;
215215 setBusy ( true ) ;
@@ -226,9 +226,20 @@ function AddReviewSummaryComment() {
226226 setBusy ( false ) ;
227227 }
228228
229+ const onKeyDown = ( event : React . KeyboardEvent < HTMLTextAreaElement > ) => {
230+ if ( ( event . ctrlKey || event . metaKey ) && event . key === 'Enter' ) {
231+ submitAction ( event , ReviewType . Comment ) ;
232+ }
233+ } ;
234+
229235 return (
230236 < form >
231- < textarea id = 'pending-review' ref = { comment } placeholder = "Leave a review summary comment" > </ textarea >
237+ < textarea
238+ id = 'pending-review'
239+ ref = { comment }
240+ placeholder = "Leave a review summary comment"
241+ onKeyDown = { onKeyDown }
242+ > </ textarea >
232243 < div className = "form-actions" >
233244 { isAuthor ? null : (
234245 < button
You can’t perform that action at this time.
0 commit comments