From cd9f57afc71e23934b442a70dfb9c9383b676a52 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Fri, 20 May 2022 10:26:04 +0800 Subject: [PATCH] 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 --- services/forms/repo_form.go | 6 ++++-- templates/repo/diff/box.tmpl | 2 +- templates/repo/issue/view_content.tmpl | 2 +- templates/user/settings/keys_ssh.tmpl | 4 ++-- web_src/js/features/common-global.js | 21 ++++++++++++++++++--- web_src/js/features/comp/EasyMDE.js | 15 ++++++++++++++- web_src/js/features/repo-legacy.js | 10 ++++++++-- web_src/js/features/repo-wiki.js | 10 ++++++---- 8 files changed, 54 insertions(+), 16 deletions(-) diff --git a/services/forms/repo_form.go b/services/forms/repo_form.go index 18cbac751cd7c..2bcb91f8c3ffa 100644 --- a/services/forms/repo_form.go +++ b/services/forms/repo_form.go @@ -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 } diff --git a/templates/repo/diff/box.tmpl b/templates/repo/diff/box.tmpl index 02c7dcd68a37d..a70532eca9bae 100644 --- a/templates/repo/diff/box.tmpl +++ b/templates/repo/diff/box.tmpl @@ -180,7 +180,7 @@ {{$.i18n.Tr "preview"}}
- +
{{$.i18n.Tr "loading"}} diff --git a/templates/repo/issue/view_content.tmpl b/templates/repo/issue/view_content.tmpl index 8d4fc4f8b3d16..52353d46d9945 100644 --- a/templates/repo/issue/view_content.tmpl +++ b/templates/repo/issue/view_content.tmpl @@ -202,7 +202,7 @@
- +
{{$.i18n.Tr "loading"}} diff --git a/templates/user/settings/keys_ssh.tmpl b/templates/user/settings/keys_ssh.tmpl index 077e40e015e18..699905ebe2b2f 100644 --- a/templates/user/settings/keys_ssh.tmpl +++ b/templates/user/settings/keys_ssh.tmpl @@ -20,7 +20,7 @@
- +
- +