1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

Improved comment rendering in "Files" view by adding Comments to DiffLine

Signed-off-by: Jonas Franz <info@jonasfranz.software>
This commit is contained in:
Jonas Franz
2018-05-12 19:09:42 +02:00
parent 58fb672d0d
commit 066086c390
9 changed files with 112 additions and 26 deletions

View File

@@ -114,26 +114,29 @@
<a class="ui green button add-code-comment add-code-comment-right" data-side="right" data-idx="{{$line.RightIdx}}">+</a>
{{end}}
</td>
{{if index $.CodeComments $file.Name (mul $line.LeftIdx -1)}}
<td class="add-comment-left add-comment-right">
<div class="field comment-code-cloud">
<div class="comment-list">
<ui class="ui comments">
{{ template "repo/diff/comments" dict "root" $ "comments" (index $.CodeComments $file.Name (mul $line.LeftIdx -1))}}
</ui>
</div>
{{template "repo/diff/comment_form" $}}
</div>
</td>
{{end}}
<td class="lines-code lines-code-new halfwidth">
<pre><code class="wrap {{if $highlightClass}}language-{{$highlightClass}}{{else}}nohighlight{{end}}">{{if $line.RightIdx}}{{$section.GetComputedInlineDiffFor $line}}{{end}}</code></pre>
</td>
</tr>
{{if gt (len $line.Comments) 0}}
<tr>
<td colspan="4" class="add-comment-left add-comment-right">
<div class="field comment-code-cloud">
<div class="comment-list">
<ui class="ui comments">
{{ template "repo/diff/comments" dict "root" $ "comments" $line.Comments}}
</ui>
</div>
{{template "repo/diff/comment_form" $}}
</div>
</td>
</tr>
{{end}}
{{end}}
{{end}}
{{else}}
{{template "repo/diff/section_unified" .}}
{{template "repo/diff/section_unified" dict "file" . "root" $}}
{{end}}
</tbody>
</table>

View File

@@ -9,10 +9,16 @@
<div class="ui top attached header">
<span class="text grey"><a {{if gt .Poster.ID 0}}href="{{.Poster.HomeLink}}"{{end}}>{{.Poster.Name}}</a> {{$.root.i18n.Tr "repo.issues.commented_at" .HashTag $createdStr | Safe}}</span>
<div class="ui right actions">
{{if eq .Review.Type 0}}
<div class="item warning tag">
{{$.root.i18n.Tr "repo.issues.review.pending"}}
</div>
{{if and .Review}}
{{if eq .Review.Type 0}}
<div class="item tag">
{{$.root.i18n.Tr "repo.issues.review.pending"}}
</div>
{{else}}
<div class="item tag">
{{$.root.i18n.Tr "repo.issues.review.review"}}
</div>
{{end}}
{{end}}
{{template "repo/issue/view_content/add_reaction" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.root.RepoLink .ID) }}
{{if or $.root.IsRepositoryAdmin (eq .Poster.ID $.root.SignedUserID)}}

View File

@@ -1,4 +1,4 @@
{{$file := .}}
{{$file := .file}}
{{$highlightClass := $file.GetHighlightClass}}
{{range $j, $section := $file.Sections}}
{{range $k, $line := $section.Lines}}
@@ -20,5 +20,19 @@
<pre><code class="wrap {{if $highlightClass}}language-{{$highlightClass}}{{else}}nohighlight{{end}}">{{$section.GetComputedInlineDiffFor $line}}</code></pre>
</td>
</tr>
{{if gt (len $line.Comments) 0}}
<tr>
<td colspan="4" class="add-comment-left add-comment-right">
<div class="field comment-code-cloud">
<div class="comment-list">
<ui class="ui comments">
{{ template "repo/diff/comments" dict "root" $.root "comments" $line.Comments}}
</ui>
</div>
{{template "repo/diff/comment_form" $.root }}
</div>
</td>
</tr>
{{end}}
{{end}}
{{end}}