From 10fff12da4d12b26779c54297605d127d1b3fb71 Mon Sep 17 00:00:00 2001 From: Jimmy Praet Date: Thu, 3 Dec 2020 21:26:47 +0100 Subject: [PATCH] Reply button is not removed when deleting a code review comment (#13824) Backport #13774 --- templates/repo/diff/box.tmpl | 128 ++++++++++++----------- templates/repo/diff/section_unified.tmpl | 58 +++++----- web_src/js/index.js | 4 + 3 files changed, 100 insertions(+), 90 deletions(-) diff --git a/templates/repo/diff/box.tmpl b/templates/repo/diff/box.tmpl index 8301dbb05..f6e49126b 100644 --- a/templates/repo/diff/box.tmpl +++ b/templates/repo/diff/box.tmpl @@ -166,74 +166,78 @@ - {{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}} -
- {{end}} + + + {{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}} +
+ {{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}} -
- {{end}} + + + {{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}} +
+ {{end}} + {{end}} diff --git a/templates/repo/diff/section_unified.tmpl b/templates/repo/diff/section_unified.tmpl index 1a461c7ad..d606a1d74 100644 --- a/templates/repo/diff/section_unified.tmpl +++ b/templates/repo/diff/section_unified.tmpl @@ -39,35 +39,37 @@ - {{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}} - +
+ {{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}} +
diff --git a/web_src/js/index.js b/web_src/js/index.js index 2e7b13cb6..8ffd56cfb 100644 --- a/web_src/js/index.js +++ b/web_src/js/index.js @@ -1055,7 +1055,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;