]> source.dussan.org Git - gitea.git/commitdiff
Reply button is not removed when deleting a code review comment (#13774)
authorJimmy Praet <jimmy.praet@ksz-bcss.fgov.be>
Thu, 3 Dec 2020 15:05:27 +0000 (16:05 +0100)
committerGitHub <noreply@github.com>
Thu, 3 Dec 2020 15:05:27 +0000 (17:05 +0200)
Co-authored-by: mrsdizzie <info@mrsdizzie.com>
templates/repo/diff/box.tmpl
templates/repo/diff/conversation.tmpl [new file with mode: 0644]
templates/repo/diff/section_unified.tmpl
web_src/js/index.js

index d278e94457027dd9c8f65d5c8d58646575840e36..bbb2cc41d758368a6c203fc805148425dfb991a5 100644 (file)
                                                                                                                        {{end}}
                                                                                                                </tr>
                                                                                                                {{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))}}
                                                                                                                        <tr class="add-code-comment">
                                                                                                                                <td class="lines-num"></td>
                                                                                                                                <td class="lines-type-marker"></td>
                                                                                                                                <td class="add-comment-left">
-                                                                                                                                       {{if and $resolved  (eq $line.GetCommentSide "previous")}}
-                                                                                                                                               <div class="ui top attached header resolved-placeholder">
-                                                                                                                                                       <span class="ui grey text left"><b>{{$resolveDoer.Name}}</b> {{$.i18n.Tr "repo.issues.review.resolved_by"}}</span>
-                                                                                                                                                       <button id="show-outdated-{{(index $line.Comments 0).ID}}" data-comment="{{(index $line.Comments 0).ID}}" class="ui tiny right labeled button show-outdated">
-                                                                                                                                                               {{svg "octicon-unfold"}}
-                                                                                                                                                               {{$.i18n.Tr "repo.issues.review.show_resolved"}}
-                                                                                                                                                       </button>
-                                                                                                                                                       <button id="hide-outdated-{{(index $line.Comments 0).ID}}" data-comment="{{(index $line.Comments 0).ID}}" class="hide ui tiny right labeled button hide-outdated">
-                                                                                                                                                               {{svg "octicon-fold"}}
-                                                                                                                                                               {{$.i18n.Tr "repo.issues.review.hide_resolved"}}
-                                                                                                                                                       </button>
-                                                                                                                                               </div>
-                                                                                                                                       {{end}}
                                                                                                                                        {{if eq $line.GetCommentSide "previous"}}
-                                                                                                                                               <div id="code-comments-{{(index  $line.Comments 0).ID}}" class="field comment-code-cloud {{if $resolved}}hide{{end}}">
-                                                                                                                                                       <div class="comment-list">
-                                                                                                                                                               <ui class="ui comments">
-                                                                                                                                                               {{ template "repo/diff/comments" dict "root" $ "comments" $line.Comments}}
-                                                                                                                                                               </ui>
-                                                                                                                                                       </div>
-                                                                                                                                               {{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}}
-                                                                                                                                                               <button class="ui icon tiny button resolve-conversation" data-action="{{if not $resolved}}Resolve{{else}}UnResolve{{end}}" data-comment-id="{{(index $line.Comments 0).ID}}" data-update-url="{{$.RepoLink}}/issues/resolve_conversation" >
-                                                                                                                                                                       {{if $resolved}}
-                                                                                                                                                                               {{$.i18n.Tr "repo.issues.review.un_resolve_conversation"}}
-                                                                                                                                                                       {{else}}
-                                                                                                                                                                               {{$.i18n.Tr "repo.issues.review.resolve_conversation"}}
-                                                                                                                                                                       {{end}}
-                                                                                                                                                               </button>
-                                                                                                                                                       {{end}}
-                                                                                                                                               </div>
+                                                                                                                                               {{template "repo/diff/conversation" mergeinto $ "comments" $line.Comments}}
                                                                                                                                        {{end}}
                                                                                                                                </td>
                                                                                                                                <td class="lines-num"></td>
                                                                                                                                <td class="lines-type-marker"></td>
-                                                                                                                               <td class="add-comment-right resolved-placeholder">
-                                                                                                                                       {{if and $resolved (eq $line.GetCommentSide "proposed")}}
-                                                                                                                                               <div class="ui top attached header">
-                                                                                                                                                       <span class="ui grey text left"><b>{{$resolveDoer.Name}}</b> {{$.i18n.Tr "repo.issues.review.resolved_by"}}</span>
-                                                                                                                                                       <button id="show-outdated-{{(index $line.Comments 0).ID}}" data-comment="{{(index $line.Comments 0).ID}}" class="ui tiny right labeled button show-outdated">
-                                                                                                                                                               {{svg "octicon-unfold"}}
-                                                                                                                                                               {{$.i18n.Tr "repo.issues.review.show_resolved"}}
-                                                                                                                                                       </button>
-                                                                                                                                                       <button id="hide-outdated-{{(index $line.Comments 0).ID}}" data-comment="{{(index $line.Comments 0).ID}}" class="hide ui tiny right labeled button hide-outdated">
-                                                                                                                                                               {{svg "octicon-fold"}}
-                                                                                                                                                               {{$.i18n.Tr "repo.issues.review.hide_resolved"}}
-                                                                                                                                                       </button>
-                                                                                                                                               </div>
-                                                                                                                                       {{end}}
+                                                                                                                               <td class="add-comment-right">
                                                                                                                                        {{if eq $line.GetCommentSide "proposed"}}
-                                                                                                                                               <div id="code-comments-{{(index  $line.Comments 0).ID}}" class="field comment-code-cloud {{if $resolved}}hide{{end}}">
-                                                                                                                                                       <div class="comment-list">
-                                                                                                                                                               <ui class="ui comments">
-                                                                                                                                                               {{ template "repo/diff/comments" dict "root" $ "comments" $line.Comments}}
-                                                                                                                                                               </ui>
-                                                                                                                                                       </div>
-                                                                                                                                                       {{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}}
-                                                                                                                                                               <button class="ui icon tiny button resolve-conversation" data-action="{{if not $resolved}}Resolve{{else}}UnResolve{{end}}" data-comment-id="{{(index $line.Comments 0).ID}}" data-update-url="{{$.RepoLink}}/issues/resolve_conversation" >
-                                                                                                                                                                       {{if $resolved}}
-                                                                                                                                                                               {{$.i18n.Tr "repo.issues.review.un_resolve_conversation"}}
-                                                                                                                                                                       {{else}}
-                                                                                                                                                                               {{$.i18n.Tr "repo.issues.review.resolve_conversation"}}
-                                                                                                                                                                       {{end}}
-                                                                                                                                                               </button>
-                                                                                                                                                       {{end}}
-                                                                                                                                               </div>
+                                                                                                                                               {{template "repo/diff/conversation" mergeinto $ "comments" $line.Comments}}
                                                                                                                                        {{end}}
                                                                                                                                </td>
                                                                                                                        </tr>
diff --git a/templates/repo/diff/conversation.tmpl b/templates/repo/diff/conversation.tmpl
new file mode 100644 (file)
index 0000000..98898ee
--- /dev/null
@@ -0,0 +1,35 @@
+{{$resolved := (index .comments 0).IsResolved}}
+{{$resolveDoer := (index .comments 0).ResolveDoer}}
+{{$isNotPending := (not (eq (index .comments 0).Review.Type 0))}}
+<div class="conversation-holder">
+       {{if $resolved}}
+               <div class="ui attached header resolved-placeholder">
+                       <span class="ui grey text left"><b>{{$resolveDoer.Name}}</b> {{$.i18n.Tr "repo.issues.review.resolved_by"}}</span>
+                       <button id="show-outdated-{{(index .comments 0).ID}}" data-comment="{{(index .comments 0).ID}}" class="ui tiny right labeled button show-outdated">
+                               {{svg "octicon-unfold"}}
+                               {{$.i18n.Tr "repo.issues.review.show_resolved"}}
+                       </button>
+                       <button id="hide-outdated-{{(index .comments 0).ID}}" data-comment="{{(index .comments 0).ID}}" class="hide ui tiny right labeled button hide-outdated">
+                               {{svg "octicon-fold"}}
+                               {{$.i18n.Tr "repo.issues.review.hide_resolved"}}
+                       </button>
+               </div>
+       {{end}}
+       <div id="code-comments-{{(index  .comments 0).ID}}" class="field comment-code-cloud {{if $resolved}}hide{{end}}">
+               <div class="comment-list">
+                       <ui class="ui comments">
+                               {{template "repo/diff/comments" dict "root" $ "comments" .comments}}
+                       </ui>
+               </div>
+               {{template "repo/diff/comment_form_datahandler" dict "hidden" true "reply" (index .comments 0).ReviewID "root" $ "comment" (index .comments 0)}}
+               {{if and $.CanMarkConversation $isNotPending}}
+                       <button class="ui icon tiny button resolve-conversation" data-action="{{if not $resolved}}Resolve{{else}}UnResolve{{end}}" data-comment-id="{{(index .comments 0).ID}}" data-update-url="{{$.RepoLink}}/issues/resolve_conversation" >
+                               {{if $resolved}}
+                                       {{$.i18n.Tr "repo.issues.review.un_resolve_conversation"}}
+                               {{else}}
+                                       {{$.i18n.Tr "repo.issues.review.resolve_conversation"}}
+                               {{end}}
+                       </button>
+               {{end}}
+       </div>
+</div>
\ No newline at end of file
index b9bdc86cc59fb16c8bd4401a7be514ee181e1b22..5376e77630a356f2d90502882efa95e4d4349692 100644 (file)
                                {{end}}
                        </tr>
                        {{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))}}
                                <tr>
                                        <td colspan="2" class="lines-num"></td>
                                        <td class="add-comment-left add-comment-right" colspan="2">
-                                               {{if $resolved}}
-                                                       <div class="ui attached header resolved-placeholder">
-                                                               <span class="ui grey text left"><b>{{$resolveDoer.Name}}</b> {{$.root.i18n.Tr "repo.issues.review.resolved_by"}}</span>
-                                                               <button id="show-outdated-{{(index $line.Comments 0).ID}}" data-comment="{{(index $line.Comments 0).ID}}" class="ui tiny right labeled button show-outdated">
-                                                                       {{svg "octicon-unfold"}}
-                                                                       {{$.root.i18n.Tr "repo.issues.review.show_resolved"}}
-                                                               </button>
-                                                               <button id="hide-outdated-{{(index $line.Comments 0).ID}}" data-comment="{{(index $line.Comments 0).ID}}" class="hide ui tiny right labeled button hide-outdated">
-                                                                       {{svg "octicon-fold"}}
-                                                                       {{$.root.i18n.Tr "repo.issues.review.hide_resolved"}}
-                                                               </button>
-                                                       </div>
-                                               {{end}}
-                                               <div id="code-comments-{{(index  $line.Comments 0).ID}}" class="field comment-code-cloud {{if $resolved}}hide{{end}}">
-                                                       <div class="comment-list">
-                                                               <ui class="ui comments">
-                                                                       {{ template "repo/diff/comments" dict "root" $.root "comments" $line.Comments}}
-                                                               </ui>
-                                                       </div>
-                                                       {{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}}
-                                                               <button class="ui icon tiny button resolve-conversation" data-action="{{if not $resolved}}Resolve{{else}}UnResolve{{end}}" data-comment-id="{{(index $line.Comments 0).ID}}" data-update-url="{{$.root.RepoLink}}/issues/resolve_conversation" >
-                                                                       {{if $resolved}}
-                                                                               {{$.root.i18n.Tr "repo.issues.review.un_resolve_conversation"}}
-                                                                       {{else}}
-                                                                               {{$.root.i18n.Tr "repo.issues.review.resolve_conversation"}}
-                                                                       {{end}}
-                                                               </button>
-                                                       {{end}}
-                                               </div>
+                                               {{template "repo/diff/conversation" mergeinto $.root "comments" $line.Comments}}
                                        </td>
                                </tr>
                        {{end}}
index 8f2de67db0c5528fd3b9cfa2582452af029f159a..ef865529db868be6b59d5556b69c9b4568e06b3f 100644 (file)
@@ -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;