diff --git a/templates/repo/diff/box.tmpl b/templates/repo/diff/box.tmpl index d278e94457..bbb2cc41d7 100644 --- a/templates/repo/diff/box.tmpl +++ b/templates/repo/diff/box.tmpl @@ -150,80 +150,19 @@ {{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 and $resolved (eq $line.GetCommentSide "previous")}} -
- {{$resolveDoer.Name}} {{$.i18n.Tr "repo.issues.review.resolved_by"}} - - -
- {{end}} {{if eq $line.GetCommentSide "previous"}} -
-
- - {{ template "repo/diff/comments" dict "root" $ "comments" $line.Comments}} - -
- {{template "repo/diff/comment_form_datahandler" dict "reply" (index $line.Comments 0).ReviewID "hidden" true "root" $ "comment" (index $line.Comments 0)}} - {{if and $.CanMarkConversation $isNotPending}} - - {{end}} -
+ {{template "repo/diff/conversation" mergeinto $ "comments" $line.Comments}} {{end}} - - {{if and $resolved (eq $line.GetCommentSide "proposed")}} -
- {{$resolveDoer.Name}} {{$.i18n.Tr "repo.issues.review.resolved_by"}} - - -
- {{end}} + {{if eq $line.GetCommentSide "proposed"}} -
-
- - {{ template "repo/diff/comments" dict "root" $ "comments" $line.Comments}} - -
- {{template "repo/diff/comment_form_datahandler" dict "reply" (index $line.Comments 0).ReviewID "hidden" true "root" $ "comment" (index $line.Comments 0)}} - {{if and $.CanMarkConversation $isNotPending}} - - {{end}} -
+ {{template "repo/diff/conversation" mergeinto $ "comments" $line.Comments}} {{end}} diff --git a/templates/repo/diff/conversation.tmpl b/templates/repo/diff/conversation.tmpl new file mode 100644 index 0000000000..98898eee60 --- /dev/null +++ b/templates/repo/diff/conversation.tmpl @@ -0,0 +1,35 @@ +{{$resolved := (index .comments 0).IsResolved}} +{{$resolveDoer := (index .comments 0).ResolveDoer}} +{{$isNotPending := (not (eq (index .comments 0).Review.Type 0))}} +
+ {{if $resolved}} +
+ {{$resolveDoer.Name}} {{$.i18n.Tr "repo.issues.review.resolved_by"}} + + +
+ {{end}} +
+
+ + {{template "repo/diff/comments" dict "root" $ "comments" .comments}} + +
+ {{template "repo/diff/comment_form_datahandler" dict "hidden" true "reply" (index .comments 0).ReviewID "root" $ "comment" (index .comments 0)}} + {{if and $.CanMarkConversation $isNotPending}} + + {{end}} +
+
\ No newline at end of file diff --git a/templates/repo/diff/section_unified.tmpl b/templates/repo/diff/section_unified.tmpl index b9bdc86cc5..5376e77630 100644 --- a/templates/repo/diff/section_unified.tmpl +++ b/templates/repo/diff/section_unified.tmpl @@ -33,42 +33,10 @@ {{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/conversation" mergeinto $.root "comments" $line.Comments}} {{end}} diff --git a/web_src/js/index.js b/web_src/js/index.js index 8f2de67db0..ef865529db 100644 --- a/web_src/js/index.js +++ b/web_src/js/index.js @@ -1094,7 +1094,11 @@ async function initRepository() { $.post($this.data('url'), { _csrf: csrf }).done(() => { + const $conversationHolder = $this.closest('.conversation-holder'); $(`#${$this.data('comment-id')}`).remove(); + if ($conversationHolder.length && !$conversationHolder.find('.comment').length) { + $conversationHolder.remove(); + } }); } return false;