Skip to content

Commit 2478e3d

Browse files
committed
fix
1 parent 34290a0 commit 2478e3d

File tree

3 files changed

+38
-26
lines changed

3 files changed

+38
-26
lines changed

templates/repo/diff/comments.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
{{ctx.Locale.Tr "repo.issues.review.outdated"}}
3838
</a>
3939
{{end}}
40-
{{if and .Review}}
40+
{{if .Review}}
4141
{{if eq .Review.Type 0}}
4242
<div class="ui label basic small yellow pending-label" data-tooltip-content="{{ctx.Locale.Tr "repo.issues.review.pending.tooltip" (ctx.Locale.Tr "repo.diff.review") (ctx.Locale.Tr "repo.diff.review.approve") (ctx.Locale.Tr "repo.diff.review.comment") (ctx.Locale.Tr "repo.diff.review.reject")}}">
4343
{{ctx.Locale.Tr "repo.issues.review.pending"}}

templates/repo/diff/conversation.tmpl

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
{{$resolved := (index .comments 0).IsResolved}}
2-
{{$invalid := (index .comments 0).Invalidated}}
3-
{{$resolveDoer := (index .comments 0).ResolveDoer}}
4-
{{$isNotPending := (not (eq (index .comments 0).Review.Type 0))}}
5-
{{$referenceUrl := printf "%s#%s" $.Issue.Link (index .comments 0).HashTag}}
6-
<div class="conversation-holder" data-path="{{(index .comments 0).TreePath}}" data-side="{{if lt (index .comments 0).Line 0}}left{{else}}right{{end}}" data-idx="{{(index .comments 0).UnsignedLine}}">
1+
{{$comment := index .comments 0}}
2+
{{if $comment}}
3+
{{$resolved := $comment.IsResolved}}
4+
{{$invalid := $comment.Invalidated}}
5+
{{$resolveDoer := $comment.ResolveDoer}}
6+
{{$hasReview := and $comment.Review}}
7+
{{$isReviewPending := and $hasReview (eq $comment.Review.Type 0)}}
8+
{{$referenceUrl := printf "%s#%s" $.Issue.Link $comment.HashTag}}
9+
<div class="conversation-holder" data-path="{{$comment.TreePath}}" data-side="{{if lt $comment.Line 0}}left{{else}}right{{end}}" data-idx="{{$comment.UnsignedLine}}">
710
{{if $resolved}}
811
<div class="ui attached header resolved-placeholder gt-df gt-ac gt-sb">
912
<div class="ui grey text gt-df gt-ac gt-fw gt-gap-2">
@@ -20,18 +23,18 @@
2023
{{end}}
2124
</div>
2225
<div class="gt-df gt-ac gt-gap-3">
23-
<button id="show-outdated-{{(index .comments 0).ID}}" data-comment="{{(index .comments 0).ID}}" class="ui tiny labeled button show-outdated gt-df gt-ac">
26+
<button id="show-outdated-{{$comment.ID}}" data-comment="{{$comment.ID}}" class="ui tiny labeled button show-outdated gt-df gt-ac">
2427
{{svg "octicon-unfold" 16 "gt-mr-3"}}
2528
{{ctx.Locale.Tr "repo.issues.review.show_resolved"}}
2629
</button>
27-
<button id="hide-outdated-{{(index .comments 0).ID}}" data-comment="{{(index .comments 0).ID}}" class="ui tiny labeled button hide-outdated gt-df gt-ac gt-hidden">
30+
<button id="hide-outdated-{{$comment.ID}}" data-comment="{{$comment.ID}}" class="ui tiny labeled button hide-outdated gt-df gt-ac gt-hidden">
2831
{{svg "octicon-fold" 16 "gt-mr-3"}}
2932
{{ctx.Locale.Tr "repo.issues.review.hide_resolved"}}
3033
</button>
3134
</div>
3235
</div>
3336
{{end}}
34-
<div id="code-comments-{{(index .comments 0).ID}}" class="field comment-code-cloud {{if $resolved}}gt-hidden{{end}}">
37+
<div id="code-comments-{{$comment.ID}}" class="field comment-code-cloud {{if $resolved}}gt-hidden{{end}}">
3538
<div class="comment-list">
3639
<ui class="ui comments">
3740
{{template "repo/diff/comments" dict "root" $ "comments" .comments}}
@@ -46,8 +49,8 @@
4649
{{svg "octicon-arrow-down" 12 "icon"}} {{ctx.Locale.Tr "repo.issues.next"}}
4750
</button>
4851
</div>
49-
{{if and $.CanMarkConversation $isNotPending}}
50-
<button class="ui icon tiny basic button resolve-conversation" data-origin="diff" data-action="{{if not $resolved}}Resolve{{else}}UnResolve{{end}}" data-comment-id="{{(index .comments 0).ID}}" data-update-url="{{$.RepoLink}}/issues/resolve_conversation">
52+
{{if and $.CanMarkConversation $hasReview (not $isReviewPending)}}
53+
<button class="ui icon tiny basic button resolve-conversation" data-origin="diff" data-action="{{if not $resolved}}Resolve{{else}}UnResolve{{end}}" data-comment-id="{{$comment.ID}}" data-update-url="{{$.RepoLink}}/issues/resolve_conversation">
5154
{{if $resolved}}
5255
{{ctx.Locale.Tr "repo.issues.review.un_resolve_conversation"}}
5356
{{else}}
@@ -61,6 +64,9 @@
6164
</button>
6265
{{end}}
6366
</div>
64-
{{template "repo/diff/comment_form_datahandler" dict "hidden" true "reply" (index .comments 0).ReviewID "root" $ "comment" (index .comments 0)}}
67+
{{template "repo/diff/comment_form_datahandler" dict "hidden" true "reply" $comment.ReviewID "root" $ "comment" $comment}}
6568
</div>
6669
</div>
70+
{{else}}
71+
{{template "repo/diff/conversation_outdated"}}
72+
{{end}}

templates/repo/issue/view_content/comments.tmpl

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -371,27 +371,31 @@
371371
{{else if eq .Type 22}}
372372
<div class="timeline-item-group" id="{{.HashTag}}">
373373
<div class="timeline-item event">
374+
{{$reviewType := -1}}
375+
{{if .Review}}{{$reviewType = .Review.Type}}{{end}}
374376
{{if not .OriginalAuthor}}
375377
{{/* Some timeline avatars need a offset to correctly align with their speech
376378
bubble. The condition depends on review type and for positive reviews whether
377379
there is a comment element or not */}}
378-
<a class="timeline-avatar{{if or (and (eq .Review.Type 1) (or .Content .Attachments)) (and (eq .Review.Type 2) (or .Content .Attachments)) (eq .Review.Type 3)}} timeline-avatar-offset{{end}}"{{if gt .Poster.ID 0}} href="{{.Poster.HomeLink}}"{{end}}>
380+
<a class="timeline-avatar{{if or (and (eq $reviewType 1) (or .Content .Attachments)) (and (eq $reviewType 2) (or .Content .Attachments)) (eq $reviewType 3)}} timeline-avatar-offset{{end}}"{{if gt .Poster.ID 0}} href="{{.Poster.HomeLink}}"{{end}}>
379381
{{ctx.AvatarUtils.Avatar .Poster 40}}
380382
</a>
381383
{{end}}
382-
<span class="badge{{if eq .Review.Type 1}} tw-bg-green tw-text-white{{else if eq .Review.Type 3}} tw-bg-red tw-text-white{{end}}">{{svg (printf "octicon-%s" .Review.Type.Icon)}}</span>
384+
<span class="badge{{if eq $reviewType 1}} tw-bg-green tw-text-white{{else if eq $reviewType 3}} tw-bg-red tw-text-white{{end}}">
385+
{{if .Review}}{{svg (printf "octicon-%s" .Review.Type.Icon)}}{{end}}
386+
</span>
383387
<span class="text grey muted-links">
384388
{{template "repo/issue/view_content/comments_authorlink" dict "ctxData" $ "comment" .}}
385-
{{if eq .Review.Type 1}}
389+
{{if eq $reviewType 1}}
386390
{{ctx.Locale.Tr "repo.issues.review.approve" $createdStr}}
387-
{{else if eq .Review.Type 2}}
391+
{{else if eq $reviewType 2}}
388392
{{ctx.Locale.Tr "repo.issues.review.comment" $createdStr}}
389-
{{else if eq .Review.Type 3}}
393+
{{else if eq $reviewType 3}}
390394
{{ctx.Locale.Tr "repo.issues.review.reject" $createdStr}}
391395
{{else}}
392396
{{ctx.Locale.Tr "repo.issues.review.comment" $createdStr}}
393397
{{end}}
394-
{{if .Review.Dismissed}}
398+
{{if and .Review .Review.Dismissed}}
395399
<div class="ui small label">{{ctx.Locale.Tr "repo.issues.review.dismissed_label"}}</div>
396400
{{end}}
397401
</span>
@@ -451,7 +455,7 @@
451455
</div>
452456
{{end}}
453457

454-
{{if .Review.CodeComments}}
458+
{{if and .Review .Review.CodeComments}}
455459
<div class="timeline-item event">
456460
{{range $filename, $lines := .Review.CodeComments}}
457461
{{range $line, $comms := $lines}}
@@ -606,13 +610,15 @@
606610
<span class="badge grey">{{svg "octicon-x" 16}}</span>
607611
<span class="text grey muted-links">
608612
{{template "shared/user/authorlink" .Poster}}
609-
{{$reviewerName := ""}}
610-
{{if eq .Review.OriginalAuthor ""}}
611-
{{$reviewerName = .Review.Reviewer.Name}}
612-
{{else}}
613-
{{$reviewerName = .Review.OriginalAuthor}}
613+
{{if .Review}}
614+
{{$reviewerName := ""}}
615+
{{if eq .Review.OriginalAuthor ""}}
616+
{{$reviewerName = .Review.Reviewer.Name}}
617+
{{else}}
618+
{{$reviewerName = .Review.OriginalAuthor}}
619+
{{end}}
620+
{{ctx.Locale.Tr "repo.issues.review.dismissed" $reviewerName $createdStr}}
614621
{{end}}
615-
{{ctx.Locale.Tr "repo.issues.review.dismissed" $reviewerName $createdStr}}
616622
</span>
617623
</div>
618624
{{if .Content}}

0 commit comments

Comments
 (0)