From 274ff0d011775c67dc3666986b8d7ca57182fbcc Mon Sep 17 00:00:00 2001 From: Jonas Franz Date: Tue, 23 Oct 2018 16:38:06 +0200 Subject: [PATCH] Add comment replies (#5147) * Add comment replies Signed-off-by: Jonas Franz * Use review.ID instead Signed-off-by: Jonas Franz --- modules/auth/repo_form.go | 1 + routers/repo/pull_review.go | 5 ++++- templates/repo/diff/box.tmpl | 4 ++-- templates/repo/diff/comment_form.tmpl | 10 +++++----- templates/repo/diff/section_unified.tmpl | 2 +- templates/repo/issue/view_content/comments.tmpl | 2 +- 6 files changed, 14 insertions(+), 10 deletions(-) diff --git a/modules/auth/repo_form.go b/modules/auth/repo_form.go index a819a6049..a4a00d53b 100644 --- a/modules/auth/repo_form.go +++ b/modules/auth/repo_form.go @@ -377,6 +377,7 @@ type CodeCommentForm struct { Line int64 TreePath string `form:"path" binding:"Required"` IsReview bool `form:"is_review"` + Reply int64 `form:"reply"` } // Validate validates the fields diff --git a/routers/repo/pull_review.go b/routers/repo/pull_review.go index 9d1db3ff4..9125f4249 100644 --- a/routers/repo/pull_review.go +++ b/routers/repo/pull_review.go @@ -63,6 +63,9 @@ func CreateCodeComment(ctx *context.Context, form auth.CodeCommentForm) { } } } + if review.ID == 0 { + review.ID = form.Reply + } //FIXME check if line, commit and treepath exist comment, err := models.CreateCodeComment( ctx.User, @@ -78,7 +81,7 @@ func CreateCodeComment(ctx *context.Context, form auth.CodeCommentForm) { return } // Send no notification if comment is pending - if !form.IsReview { + if !form.IsReview || form.Reply != 0 { notification.Service.NotifyIssue(issue, ctx.User.ID) } diff --git a/templates/repo/diff/box.tmpl b/templates/repo/diff/box.tmpl index b5bc3ee07..729e37c8b 100644 --- a/templates/repo/diff/box.tmpl +++ b/templates/repo/diff/box.tmpl @@ -151,7 +151,7 @@ {{ template "repo/diff/comments" dict "root" $ "comments" $line.Comments}} - {{template "repo/diff/comment_form_datahandler" dict "hidden" true "root" $ "comment" (index $line.Comments 0)}} + {{template "repo/diff/comment_form_datahandler" dict "reply" (index $line.Comments 0).ReviewID "hidden" true "root" $ "comment" (index $line.Comments 0)}} {{end}} @@ -164,7 +164,7 @@ {{ template "repo/diff/comments" dict "root" $ "comments" $line.Comments}} - {{template "repo/diff/comment_form_datahandler" dict "hidden" true "root" $ "comment" (index $line.Comments 0)}} + {{template "repo/diff/comment_form_datahandler" dict "reply" (index $line.Comments 0).ReviewID "hidden" true "root" $ "comment" (index $line.Comments 0)}} {{end}} diff --git a/templates/repo/diff/comment_form.tmpl b/templates/repo/diff/comment_form.tmpl index 9683c3e40..9eb557d86 100644 --- a/templates/repo/diff/comment_form.tmpl +++ b/templates/repo/diff/comment_form.tmpl @@ -25,19 +25,19 @@ diff --git a/templates/repo/issue/view_content/comments.tmpl b/templates/repo/issue/view_content/comments.tmpl index ee10ff56f..4e79fd866 100644 --- a/templates/repo/issue/view_content/comments.tmpl +++ b/templates/repo/issue/view_content/comments.tmpl @@ -342,7 +342,7 @@ {{end}} - {{template "repo/diff/comment_form_datahandler" dict "hidden" true "reply" true "root" $ "comment" (index $comms 0)}} + {{template "repo/diff/comment_form_datahandler" dict "hidden" true "reply" (index $comms 0).ReviewID "root" $ "comment" (index $comms 0)}} {{end}}