From b2092fe2f8bd1dcb2d660f98a22847aee1e9a4de Mon Sep 17 00:00:00 2001 From: Jonas Franz Date: Fri, 6 Jul 2018 19:33:42 +0200 Subject: [PATCH] Fix: add comment icon is only shown on code lines --- models/git_diff.go | 4 ++++ templates/repo/diff/box.tmpl | 4 ++-- templates/repo/diff/section_unified.tmpl | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/models/git_diff.go b/models/git_diff.go index f72e8e1b3..44027bec6 100644 --- a/models/git_diff.go +++ b/models/git_diff.go @@ -67,6 +67,10 @@ func (d *DiffLine) GetType() int { return int(d.Type) } +func (d *DiffLine) CanComment() bool { + return len(d.Comments) == 0 && d.Type != DiffLineSection +} + // GetCommentSide returns the comment side of the first comment, if not set returns empty string func (d *DiffLine) GetCommentSide() string { if len(d.Comments) == 0 { diff --git a/templates/repo/diff/box.tmpl b/templates/repo/diff/box.tmpl index 39a66a734..77a0e955e 100644 --- a/templates/repo/diff/box.tmpl +++ b/templates/repo/diff/box.tmpl @@ -106,7 +106,7 @@ - {{if and $.SignedUserID (not (len $line.Comments))}} + {{if and $.root.SignedUserID $line.CanComment}} + {{end}}
{{if $line.LeftIdx}}{{$section.GetComputedInlineDiffFor $line}}{{end}}
@@ -116,7 +116,7 @@ - {{if and $.SignedUserID (not (len $line.Comments))}} + {{if and $.root.SignedUserID $line.CanComment}} + {{end}}
{{if $line.RightIdx}}{{$section.GetComputedInlineDiffFor $line}}{{end}}
diff --git a/templates/repo/diff/section_unified.tmpl b/templates/repo/diff/section_unified.tmpl index f089df4c2..491572cde 100644 --- a/templates/repo/diff/section_unified.tmpl +++ b/templates/repo/diff/section_unified.tmpl @@ -16,7 +16,7 @@ {{end}} - {{if and $.root.SignedUserID (not (len $line.Comments))}} + {{if and $.root.SignedUserID $line.CanComment}} + {{end}}
{{$section.GetComputedInlineDiffFor $line}}