Skip to content

Commit f38fce9

Browse files
jonasfranztechknowlogick
authored andcommitted
Add comment replies (#5104)
* Add comment replies * Replace reviewID with review.ID
1 parent 9458880 commit f38fce9

File tree

6 files changed

+14
-10
lines changed

6 files changed

+14
-10
lines changed

modules/auth/repo_form.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@ type CodeCommentForm struct {
377377
Line int64
378378
TreePath string `form:"path" binding:"Required"`
379379
IsReview bool `form:"is_review"`
380+
Reply int64 `form:"reply"`
380381
}
381382

382383
// Validate validates the fields

routers/repo/pull_review.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ func CreateCodeComment(ctx *context.Context, form auth.CodeCommentForm) {
6363
}
6464
}
6565
}
66+
if review.ID == 0 {
67+
review.ID = form.Reply
68+
}
6669
//FIXME check if line, commit and treepath exist
6770
comment, err := models.CreateCodeComment(
6871
ctx.User,
@@ -78,7 +81,7 @@ func CreateCodeComment(ctx *context.Context, form auth.CodeCommentForm) {
7881
return
7982
}
8083
// Send no notification if comment is pending
81-
if !form.IsReview {
84+
if !form.IsReview || form.Reply != 0 {
8285
notification.NotifyCreateIssueComment(ctx.User, issue.Repo, issue, comment)
8386
}
8487

templates/repo/diff/box.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@
151151
{{ template "repo/diff/comments" dict "root" $ "comments" $line.Comments}}
152152
</ui>
153153
</div>
154-
{{template "repo/diff/comment_form_datahandler" dict "hidden" true "root" $ "comment" (index $line.Comments 0)}}
154+
{{template "repo/diff/comment_form_datahandler" dict "reply" (index $line.Comments 0).ReviewID "hidden" true "root" $ "comment" (index $line.Comments 0)}}
155155
</div>
156156
{{end}}
157157
</td>
@@ -164,7 +164,7 @@
164164
{{ template "repo/diff/comments" dict "root" $ "comments" $line.Comments}}
165165
</ui>
166166
</div>
167-
{{template "repo/diff/comment_form_datahandler" dict "hidden" true "root" $ "comment" (index $line.Comments 0)}}
167+
{{template "repo/diff/comment_form_datahandler" dict "reply" (index $line.Comments 0).ReviewID "hidden" true "root" $ "comment" (index $line.Comments 0)}}
168168
</div>
169169
{{end}}
170170
</td>

templates/repo/diff/comment_form.tmpl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,19 @@
2525
<div class="footer">
2626
<span class="markdown-info"><i class="octicon octicon-markdown"></i> {{$.root.i18n.Tr "repo.diff.comment.markdown_info"}}</span>
2727
<div class="ui right floated">
28-
{{if not $.reply}}
28+
{{if $.reply}}
29+
<button name="reply" value="{{$.reply}}" class="ui submit green tiny button btn-reply">{{$.root.i18n.Tr "repo.diff.comment.reply"}}</button>
30+
{{else}}
2931
{{if $.root.CurrentReview}}
3032
<button name="is_review" value="true" type="submit"
3133
class="ui submit green tiny button btn-add-comment">{{$.root.i18n.Tr "repo.diff.comment.add_review_comment"}}</button>
3234
{{else}}
3335
<button name="is_review" value="true" type="submit"
3436
class="ui submit green tiny button btn-start-review">{{$.root.i18n.Tr "repo.diff.comment.start_review"}}</button>
37+
<button type="submit"
38+
class="ui submit tiny basic button btn-add-single">{{$.root.i18n.Tr "repo.diff.comment.add_single_comment"}}</button>
3539
{{end}}
3640
{{end}}
37-
{{if not $.root.CurrentReview}}
38-
<button type="submit"
39-
class="ui submit tiny basic button btn-add-single">{{$.root.i18n.Tr "repo.diff.comment.add_single_comment"}}</button>
40-
{{end}}
4141
{{if or (not $.HasComments) $.hidden}}
4242
<button type="button" class="ui submit tiny basic button btn-cancel" onclick="cancelCodeComment(this);">{{$.root.i18n.Tr "cancel"}}</button>
4343
{{end}}

templates/repo/diff/section_unified.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
{{ template "repo/diff/comments" dict "root" $.root "comments" $line.Comments}}
3333
</ui>
3434
</div>
35-
{{template "repo/diff/comment_form_datahandler" dict "hidden" true "root" $.root "comment" (index $line.Comments 0)}}
35+
{{template "repo/diff/comment_form_datahandler" dict "hidden" true "reply" (index $line.Comments 0).ReviewID "root" $.root "comment" (index $line.Comments 0)}}
3636
</div>
3737
</td>
3838
</tr>

templates/repo/issue/view_content/comments.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@
342342
</div>
343343
{{end}}
344344
</div>
345-
{{template "repo/diff/comment_form_datahandler" dict "hidden" true "reply" true "root" $ "comment" (index $comms 0)}}
345+
{{template "repo/diff/comment_form_datahandler" dict "hidden" true "reply" (index $comms 0).ReviewID "root" $ "comment" (index $comms 0)}}
346346
</div>
347347
</div>
348348
{{end}}

0 commit comments

Comments
 (0)