]> source.dussan.org Git - gitea.git/commitdiff
Add comment replies (#5104)
authorJonas Franz <info@jonasfranz.software>
Mon, 22 Oct 2018 20:13:35 +0000 (22:13 +0200)
committertechknowlogick <hello@techknowlogick.com>
Mon, 22 Oct 2018 20:13:35 +0000 (16:13 -0400)
* Add comment replies

* Replace reviewID with review.ID

modules/auth/repo_form.go
routers/repo/pull_review.go
templates/repo/diff/box.tmpl
templates/repo/diff/comment_form.tmpl
templates/repo/diff/section_unified.tmpl
templates/repo/issue/view_content/comments.tmpl

index a819a60491b9292ca139a8aea1011c99b1463489..a4a00d53b4f4cf3fc946651fafbc6c1af27bad8d 100644 (file)
@@ -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
index 91257fea33958859c76646b1777d076e2a54d8b8..7576ebe90bbf6bb401f35ef956e2924054374094 100644 (file)
@@ -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)
        }
 
index b5bc3ee07377c9d5340f7362f63fd18963cd3f4b..729e37c8b940b9f05799dcf670f88422b552a112 100644 (file)
                                                                                                                                                        {{ 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>
                                                                                                                                                        {{ 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>
index 9683c3e4017b9f5433f42a0b0b7449207f0d3fd3..9eb557d86b4ddabdd47cdede2be64f849278a32e 100644 (file)
                <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}}
index c65b8bdf3e1a2679ffb8c5c5c50542a455efb2f9..53ccaedbc242a6761b312b98af02e7b47e240a10 100644 (file)
@@ -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>
index ee10ff56f04aa42e9bdf94edaa5c0fc38afe3e4d..4e79fd866c19e1444e613bbd765cd5ab8cbcaa85 100644 (file)
                                                                                </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}}