From f86e1dddedc611fe0df8a58a26be482a66557e74 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Tue, 19 Mar 2024 00:01:00 +0800 Subject: [PATCH] fix --- templates/repo/diff/comments.tmpl | 2 +- templates/repo/diff/conversation.tmpl | 30 +++++++++++-------- .../repo/issue/view_content/comments.tmpl | 28 ++++++++++------- 3 files changed, 36 insertions(+), 24 deletions(-) diff --git a/templates/repo/diff/comments.tmpl b/templates/repo/diff/comments.tmpl index 47a4502efdad7..f47dad807e739 100644 --- a/templates/repo/diff/comments.tmpl +++ b/templates/repo/diff/comments.tmpl @@ -37,7 +37,7 @@ {{ctx.Locale.Tr "repo.issues.review.outdated"}} {{end}} - {{if and .Review}} + {{if .Review}} {{if eq .Review.Type 0}}
{{ctx.Locale.Tr "repo.issues.review.pending"}} diff --git a/templates/repo/diff/conversation.tmpl b/templates/repo/diff/conversation.tmpl index aaeac3c550dbd..d0bc0e020906d 100644 --- a/templates/repo/diff/conversation.tmpl +++ b/templates/repo/diff/conversation.tmpl @@ -1,9 +1,12 @@ -{{$resolved := (index .comments 0).IsResolved}} -{{$invalid := (index .comments 0).Invalidated}} -{{$resolveDoer := (index .comments 0).ResolveDoer}} -{{$isNotPending := (not (eq (index .comments 0).Review.Type 0))}} -{{$referenceUrl := printf "%s#%s" $.Issue.Link (index .comments 0).HashTag}} -
+{{$comment := index .comments 0}} +{{if $comment}} +{{$resolved := $comment.IsResolved}} +{{$invalid := $comment.Invalidated}} +{{$resolveDoer := $comment.ResolveDoer}} +{{$hasReview := and $comment.Review}} +{{$isReviewPending := and $hasReview (eq $comment.Review.Type 0)}} +{{$referenceUrl := printf "%s#%s" $.Issue.Link $comment.HashTag}} +
{{if $resolved}}
@@ -20,18 +23,18 @@ {{end}}
- -
{{end}} -
+
{{template "repo/diff/comments" dict "root" $ "comments" .comments}} @@ -46,8 +49,8 @@ {{svg "octicon-arrow-down" 12 "icon"}} {{ctx.Locale.Tr "repo.issues.next"}}
- {{if and $.CanMarkConversation $isNotPending}} - {{end}}
- {{template "repo/diff/comment_form_datahandler" dict "hidden" true "reply" (index .comments 0).ReviewID "root" $ "comment" (index .comments 0)}} + {{template "repo/diff/comment_form_datahandler" dict "hidden" true "reply" $comment.ReviewID "root" $ "comment" $comment}}
+{{else}} +{{template "repo/diff/conversation_outdated"}} +{{end}} diff --git a/templates/repo/issue/view_content/comments.tmpl b/templates/repo/issue/view_content/comments.tmpl index 4433d86fcc52d..218efe50e5406 100644 --- a/templates/repo/issue/view_content/comments.tmpl +++ b/templates/repo/issue/view_content/comments.tmpl @@ -365,16 +365,20 @@ {{else if eq .Type 22}}
+ {{$reviewType := -1}} + {{if .Review}}{{$reviewType = .Review.Type}}{{end}} {{if .OriginalAuthor}} {{else}} {{/* Some timeline avatars need a offset to correctly align with their speech bubble. The condition depends on review type and for positive reviews whether there is a comment element or not */}} - + {{ctx.AvatarUtils.Avatar .Poster 40}} {{end}} - {{svg (printf "octicon-%s" .Review.Type.Icon)}} + + {{if .Review}}{{svg (printf "octicon-%s" .Review.Type.Icon)}}{{end}} + {{if .OriginalAuthor}} @@ -387,16 +391,16 @@ {{template "shared/user/authorlink" .Poster}} {{end}} - {{if eq .Review.Type 1}} + {{if eq $reviewType 1}} {{ctx.Locale.Tr "repo.issues.review.approve" $createdStr | Safe}} - {{else if eq .Review.Type 2}} + {{else if eq $reviewType 2}} {{ctx.Locale.Tr "repo.issues.review.comment" $createdStr | Safe}} - {{else if eq .Review.Type 3}} + {{else if eq $reviewType 3}} {{ctx.Locale.Tr "repo.issues.review.reject" $createdStr | Safe}} {{else}} {{ctx.Locale.Tr "repo.issues.review.comment" $createdStr | Safe}} {{end}} - {{if .Review.Dismissed}} + {{if and .Review .Review.Dismissed}}
{{ctx.Locale.Tr "repo.issues.review.dismissed_label"}}
{{end}}
@@ -456,7 +460,7 @@
{{end}} - {{if .Review.CodeComments}} + {{if and .Review .Review.CodeComments}}
{{range $filename, $lines := .Review.CodeComments}} {{range $line, $comms := $lines}} @@ -610,10 +614,12 @@ {{template "shared/user/authorlink" .Poster}} {{$reviewerName := ""}} - {{if eq .Review.OriginalAuthor ""}} - {{$reviewerName = .Review.Reviewer.Name}} - {{else}} - {{$reviewerName = .Review.OriginalAuthor}} + {{if .Review}} + {{if eq .Review.OriginalAuthor ""}} + {{$reviewerName = .Review.Reviewer.Name}} + {{else}} + {{$reviewerName = .Review.OriginalAuthor}} + {{end}} {{end}} {{ctx.Locale.Tr "repo.issues.review.dismissed" ($reviewerName | Escape) $createdStr | Safe}}