From 4147d572d4db30dfcce73196bca82b45b41fa52f Mon Sep 17 00:00:00 2001 From: Andrew Thornton Date: Wed, 5 Aug 2020 13:40:18 +0100 Subject: [PATCH 1/4] 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 --- templates/repo/diff/section_unified.tmpl | 30 +++++++++++++----------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/templates/repo/diff/section_unified.tmpl b/templates/repo/diff/section_unified.tmpl index 0f561a8a8479c..fdc6618584f83 100644 --- a/templates/repo/diff/section_unified.tmpl +++ b/templates/repo/diff/section_unified.tmpl @@ -4,20 +4,22 @@ {{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}} - + {{if $.root.AfterCommitID}} + {{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}} {{end}} {{else}} From a79a791390c9ccff00c8afdaf9d396a33523bdf1 Mon Sep 17 00:00:00 2001 From: Andrew Thornton Date: Wed, 5 Aug 2020 15:47:16 +0100 Subject: [PATCH 2/4] as per @silverwind Signed-off-by: Andrew Thornton --- templates/repo/diff/section_unified.tmpl | 136 +++++++++++------------ 1 file changed, 68 insertions(+), 68 deletions(-) diff --git a/templates/repo/diff/section_unified.tmpl b/templates/repo/diff/section_unified.tmpl index fdc6618584f83..37357327b6f27 100644 --- a/templates/repo/diff/section_unified.tmpl +++ b/templates/repo/diff/section_unified.tmpl @@ -1,77 +1,77 @@ {{$file := .file}} {{range $j, $section := $file.Sections}} {{range $k, $line := $section.Lines}} - - {{if eq .GetType 4}} - - {{if $.root.AfterCommitID}} - {{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}} + {{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}} - - {{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"}} - - -
+ + {{if eq .GetType 4}} + {{$section.GetComputedInlineDiffFor $line}} + {{else}} + {{if and $.root.SignedUserID $line.CanComment $.root.PageIsPullFiles}}{{end}}{{$section.GetComputedInlineDiffFor $line}} {{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}} From c4e412024caa3cbf025aa890e7302887c76027d5 Mon Sep 17 00:00:00 2001 From: Andrew Thornton Date: Wed, 5 Aug 2020 15:48:02 +0100 Subject: [PATCH 3/4] one more indentation fix Signed-off-by: Andrew Thornton --- templates/repo/diff/section_unified.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/repo/diff/section_unified.tmpl b/templates/repo/diff/section_unified.tmpl index 37357327b6f27..9987598201b86 100644 --- a/templates/repo/diff/section_unified.tmpl +++ b/templates/repo/diff/section_unified.tmpl @@ -44,7 +44,7 @@ {{$resolveDoer.Name}} {{$.root.i18n.Tr "repo.issues.review.resolved_by"}}