From 96add8c319bd8299bfb8fdd4d98c6f71407e2475 Mon Sep 17 00:00:00 2001 From: zeripath Date: Sat, 8 Aug 2020 02:22:34 +0100 Subject: [PATCH] Do not show arrows on comment diffs on pull comment pages (#12434) * Do not show arrows on comment diffs on pull comment pages Prior to this PR it was possible that an expansion arrow could be displayed on comment diffs displayed on the comments pages of pulls These arrows would not successfully work because they were not attached to a commit id - nor can they necessarily be. This PR prevents these from being shown. Fix #10851 Signed-off-by: Andrew Thornton * as per @silverwind Signed-off-by: Andrew Thornton * one more indentation fix Signed-off-by: Andrew Thornton * one more indentation fix Signed-off-by: Andrew Thornton --- templates/repo/diff/section_unified.tmpl | 134 ++++++++++++----------- 1 file changed, 68 insertions(+), 66 deletions(-) diff --git a/templates/repo/diff/section_unified.tmpl b/templates/repo/diff/section_unified.tmpl index 0f561a8a84..5f87a4176c 100644 --- a/templates/repo/diff/section_unified.tmpl +++ b/templates/repo/diff/section_unified.tmpl @@ -1,75 +1,77 @@ {{$file := .file}} {{range $j, $section := $file.Sections}} {{range $k, $line := $section.Lines}} - - {{if eq .GetType 4}} - - {{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 5) }} - - {{svg "octicon-fold-down" 16}} - + {{if or $.root.AfterCommitID (ne .GetType 4)}} + + {{if eq .GetType 4}} + + {{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 5) }} + + {{svg "octicon-fold-down" 16}} + + {{end}} + {{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 4) }} + + {{svg "octicon-fold-up" 16}} + + {{end}} + {{if eq $line.GetExpandDirection 2}} + + {{svg "octicon-fold" 16}} + + {{end}} + + {{else}} + + {{end}} - {{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 4) }} - - {{svg "octicon-fold-up" 16}} - + + {{if eq .GetType 4}} + {{$section.GetComputedInlineDiffFor $line}} + {{else}} + {{if and $.root.SignedUserID $line.CanComment $.root.PageIsPullFiles}}{{end}}{{$section.GetComputedInlineDiffFor $line}} {{end}} - {{if eq $line.GetExpandDirection 2}} - - {{svg "octicon-fold" 16}} - - {{end}} - - {{else}} - - - {{end}} - - {{if eq .GetType 4}} - {{$section.GetComputedInlineDiffFor $line}} - {{else}} - {{if and $.root.SignedUserID $line.CanComment $.root.PageIsPullFiles}}{{end}}{{$section.GetComputedInlineDiffFor $line}} - {{end}} - - {{if gt (len $line.Comments) 0}} - {{$resolved := (index $line.Comments 0).IsResolved}} - {{$resolveDoer := (index $line.Comments 0).ResolveDoer}} - {{$isNotPending := (not (eq (index $line.Comments 0).Review.Type 0))}} - - - - {{if $resolved}} -
- {{$resolveDoer.Name}} {{$.root.i18n.Tr "repo.issues.review.resolved_by"}} - - -
- {{end}} -
-
- - {{ template "repo/diff/comments" dict "root" $.root "comments" $line.Comments}} - -
- {{template "repo/diff/comment_form_datahandler" dict "hidden" true "reply" (index $line.Comments 0).ReviewID "root" $.root "comment" (index $line.Comments 0)}} - {{if and $.root.CanMarkConversation $isNotPending}} - + +
+ {{end}} +
+
+ + {{ template "repo/diff/comments" dict "root" $.root "comments" $line.Comments}} + +
+ {{template "repo/diff/comment_form_datahandler" dict "hidden" true "reply" (index $line.Comments 0).ReviewID "root" $.root "comment" (index $line.Comments 0)}} + {{if and $.root.CanMarkConversation $isNotPending}} + {{end}} - - {{end}} -
- - + + + + {{end}} {{end}} {{end}} {{end}}