diff options
author | Jonas Franz <info@jonasfranz.software> | 2018-10-22 22:13:35 +0200 |
---|---|---|
committer | techknowlogick <hello@techknowlogick.com> | 2018-10-22 16:13:35 -0400 |
commit | f38fce916ec92cb9ac9fe78fb5284bc8b55a726f (patch) | |
tree | 6516aead70b3ea1a95d9ff1aa42669c07a4d24dd | |
parent | 9458880c068c985692a49caf608f0057c73790bf (diff) | |
download | gitea-f38fce916ec92cb9ac9fe78fb5284bc8b55a726f.tar.gz gitea-f38fce916ec92cb9ac9fe78fb5284bc8b55a726f.zip |
Add comment replies (#5104)
* Add comment replies
* Replace reviewID with review.ID
-rw-r--r-- | modules/auth/repo_form.go | 1 | ||||
-rw-r--r-- | routers/repo/pull_review.go | 5 | ||||
-rw-r--r-- | templates/repo/diff/box.tmpl | 4 | ||||
-rw-r--r-- | templates/repo/diff/comment_form.tmpl | 10 | ||||
-rw-r--r-- | templates/repo/diff/section_unified.tmpl | 2 | ||||
-rw-r--r-- | 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 a819a60491..a4a00d53b4 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 91257fea33..7576ebe90b 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.NotifyCreateIssueComment(ctx.User, issue.Repo, issue, comment) } diff --git a/templates/repo/diff/box.tmpl b/templates/repo/diff/box.tmpl index b5bc3ee073..729e37c8b9 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}} </ui> </div> - {{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)}} </div> {{end}} </td> @@ -164,7 +164,7 @@ {{ template "repo/diff/comments" dict "root" $ "comments" $line.Comments}} </ui> </div> - {{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)}} </div> {{end}} </td> diff --git a/templates/repo/diff/comment_form.tmpl b/templates/repo/diff/comment_form.tmpl index 9683c3e401..9eb557d86b 100644 --- a/templates/repo/diff/comment_form.tmpl +++ b/templates/repo/diff/comment_form.tmpl @@ -25,19 +25,19 @@ <div class="footer"> <span class="markdown-info"><i class="octicon octicon-markdown"></i> {{$.root.i18n.Tr "repo.diff.comment.markdown_info"}}</span> <div class="ui right floated"> - {{if not $.reply}} + {{if $.reply}} + <button name="reply" value="{{$.reply}}" class="ui submit green tiny button btn-reply">{{$.root.i18n.Tr "repo.diff.comment.reply"}}</button> + {{else}} {{if $.root.CurrentReview}} <button name="is_review" value="true" type="submit" class="ui submit green tiny button btn-add-comment">{{$.root.i18n.Tr "repo.diff.comment.add_review_comment"}}</button> {{else}} <button name="is_review" value="true" type="submit" class="ui submit green tiny button btn-start-review">{{$.root.i18n.Tr "repo.diff.comment.start_review"}}</button> + <button type="submit" + class="ui submit tiny basic button btn-add-single">{{$.root.i18n.Tr "repo.diff.comment.add_single_comment"}}</button> {{end}} {{end}} - {{if not $.root.CurrentReview}} - <button type="submit" - class="ui submit tiny basic button btn-add-single">{{$.root.i18n.Tr "repo.diff.comment.add_single_comment"}}</button> - {{end}} {{if or (not $.HasComments) $.hidden}} <button type="button" class="ui submit tiny basic button btn-cancel" onclick="cancelCodeComment(this);">{{$.root.i18n.Tr "cancel"}}</button> {{end}} diff --git a/templates/repo/diff/section_unified.tmpl b/templates/repo/diff/section_unified.tmpl index c65b8bdf3e..53ccaedbc2 100644 --- a/templates/repo/diff/section_unified.tmpl +++ b/templates/repo/diff/section_unified.tmpl @@ -32,7 +32,7 @@ {{ template "repo/diff/comments" dict "root" $.root "comments" $line.Comments}} </ui> </div> - {{template "repo/diff/comment_form_datahandler" dict "hidden" true "root" $.root "comment" (index $line.Comments 0)}} + {{template "repo/diff/comment_form_datahandler" dict "hidden" true "reply" (index $line.Comments 0).ReviewID "root" $.root "comment" (index $line.Comments 0)}} </div> </td> </tr> diff --git a/templates/repo/issue/view_content/comments.tmpl b/templates/repo/issue/view_content/comments.tmpl index ee10ff56f0..4e79fd866c 100644 --- a/templates/repo/issue/view_content/comments.tmpl +++ b/templates/repo/issue/view_content/comments.tmpl @@ -342,7 +342,7 @@ </div> {{end}} </div> - {{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)}} </div> </div> {{end}} |