Make Ctrl+Enter (quick submit) work for issue comment and wiki editor (#19729)

* Make Ctrl+Enter (quick submit) work for issue comment and wiki editor

* Remove the required `SubmitReviewForm.Type`, empty type (triggered by quick submit) means "comment"

* Merge duplicate code
This commit is contained in:
wxiaoguang 2022-05-20 10:26:04 +08:00 committed by GitHub
parent 3b359b1629
commit cc7236e852
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 54 additions and 16 deletions

View file

@ -623,7 +623,7 @@ func (f *CodeCommentForm) Validate(req *http.Request, errs binding.Errors) bindi
// SubmitReviewForm for submitting a finished code review
type SubmitReviewForm struct {
Content string
Type string `binding:"Required;In(approve,comment,reject)"`
Type string
CommitID string
Files []string
}
@ -634,7 +634,7 @@ func (f *SubmitReviewForm) Validate(req *http.Request, errs binding.Errors) bind
return middleware.Validate(errs, ctx.Data, f, ctx.Locale)
}
// ReviewType will return the corresponding reviewtype for type
// ReviewType will return the corresponding ReviewType for type
func (f SubmitReviewForm) ReviewType() models.ReviewType {
switch f.Type {
case "approve":
@ -643,6 +643,8 @@ func (f SubmitReviewForm) ReviewType() models.ReviewType {
return models.ReviewTypeComment
case "reject":
return models.ReviewTypeReject
case "":
return models.ReviewTypeComment // default to comment when doing quick-submit (Ctrl+Enter) on the review form
default:
return models.ReviewTypeUnknown
}