Skip to content

Commit 10fff12

Browse files
authored
Reply button is not removed when deleting a code review comment (#13824)
Backport #13774
1 parent 0d43a2a commit 10fff12

File tree

3 files changed

+100
-90
lines changed

3 files changed

+100
-90
lines changed

templates/repo/diff/box.tmpl

Lines changed: 66 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -166,74 +166,78 @@
166166
<td class="lines-num"></td>
167167
<td class="lines-type-marker"></td>
168168
<td class="add-comment-left">
169-
{{if and $resolved (eq $line.GetCommentSide "previous")}}
170-
<div class="ui top attached header">
171-
<span class="ui grey text left"><b>{{$resolveDoer.Name}}</b> {{$.i18n.Tr "repo.issues.review.resolved_by"}}</span>
172-
<button id="show-outdated-{{(index $line.Comments 0).ID}}" data-comment="{{(index $line.Comments 0).ID}}" class="ui compact right labeled button show-outdated">
173-
{{svg "octicon-unfold"}}
174-
{{$.i18n.Tr "repo.issues.review.show_resolved"}}
175-
</button>
176-
<button id="hide-outdated-{{(index $line.Comments 0).ID}}" data-comment="{{(index $line.Comments 0).ID}}" class="hide ui compact right labeled button hide-outdated">
177-
{{svg "octicon-fold"}}
178-
{{$.i18n.Tr "repo.issues.review.hide_resolved"}}
179-
</button>
180-
</div>
181-
{{end}}
182-
{{if eq $line.GetCommentSide "previous"}}
183-
<div id="code-comments-{{(index $line.Comments 0).ID}}" class="field comment-code-cloud {{if $resolved}}hide{{end}}">
184-
<div class="comment-list">
185-
<ui class="ui comments">
186-
{{ template "repo/diff/comments" dict "root" $ "comments" $line.Comments}}
187-
</ui>
188-
</div>
189-
{{template "repo/diff/comment_form_datahandler" dict "reply" (index $line.Comments 0).ReviewID "hidden" true "root" $ "comment" (index $line.Comments 0)}}
190-
{{if and $.CanMarkConversation $isNotPending}}
191-
<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" >
192-
{{if $resolved}}
193-
{{$.i18n.Tr "repo.issues.review.un_resolve_conversation"}}
194-
{{else}}
195-
{{$.i18n.Tr "repo.issues.review.resolve_conversation"}}
196-
{{end}}
169+
<div class="conversation-holder">
170+
{{if and $resolved (eq $line.GetCommentSide "previous")}}
171+
<div class="ui top attached header">
172+
<span class="ui grey text left"><b>{{$resolveDoer.Name}}</b> {{$.i18n.Tr "repo.issues.review.resolved_by"}}</span>
173+
<button id="show-outdated-{{(index $line.Comments 0).ID}}" data-comment="{{(index $line.Comments 0).ID}}" class="ui compact right labeled button show-outdated">
174+
{{svg "octicon-unfold"}}
175+
{{$.i18n.Tr "repo.issues.review.show_resolved"}}
197176
</button>
198-
{{end}}
199-
</div>
200-
{{end}}
177+
<button id="hide-outdated-{{(index $line.Comments 0).ID}}" data-comment="{{(index $line.Comments 0).ID}}" class="hide ui compact right labeled button hide-outdated">
178+
{{svg "octicon-fold"}}
179+
{{$.i18n.Tr "repo.issues.review.hide_resolved"}}
180+
</button>
181+
</div>
182+
{{end}}
183+
{{if eq $line.GetCommentSide "previous"}}
184+
<div id="code-comments-{{(index $line.Comments 0).ID}}" class="field comment-code-cloud {{if $resolved}}hide{{end}}">
185+
<div class="comment-list">
186+
<ui class="ui comments">
187+
{{ template "repo/diff/comments" dict "root" $ "comments" $line.Comments}}
188+
</ui>
189+
</div>
190+
{{template "repo/diff/comment_form_datahandler" dict "reply" (index $line.Comments 0).ReviewID "hidden" true "root" $ "comment" (index $line.Comments 0)}}
191+
{{if and $.CanMarkConversation $isNotPending}}
192+
<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" >
193+
{{if $resolved}}
194+
{{$.i18n.Tr "repo.issues.review.un_resolve_conversation"}}
195+
{{else}}
196+
{{$.i18n.Tr "repo.issues.review.resolve_conversation"}}
197+
{{end}}
198+
</button>
199+
{{end}}
200+
</div>
201+
{{end}}
202+
</div>
201203
</td>
202204
<td class="lines-num"></td>
203205
<td class="lines-type-marker"></td>
204206
<td class="add-comment-right">
205-
{{if and $resolved (eq $line.GetCommentSide "proposed")}}
206-
<div class="ui top attached header">
207-
<span class="ui grey text left"><b>{{$resolveDoer.Name}}</b> {{$.i18n.Tr "repo.issues.review.resolved_by"}}</span>
208-
<button id="show-outdated-{{(index $line.Comments 0).ID}}" data-comment="{{(index $line.Comments 0).ID}}" class="ui compact right labeled button show-outdated">
209-
{{svg "octicon-unfold"}}
210-
{{$.i18n.Tr "repo.issues.review.show_resolved"}}
211-
</button>
212-
<button id="hide-outdated-{{(index $line.Comments 0).ID}}" data-comment="{{(index $line.Comments 0).ID}}" class="hide ui compact right labeled button hide-outdated">
213-
{{svg "octicon-fold"}}
214-
{{$.i18n.Tr "repo.issues.review.hide_resolved"}}
215-
</button>
216-
</div>
217-
{{end}}
218-
{{if eq $line.GetCommentSide "proposed"}}
219-
<div id="code-comments-{{(index $line.Comments 0).ID}}" class="field comment-code-cloud {{if $resolved}}hide{{end}}">
220-
<div class="comment-list">
221-
<ui class="ui comments">
222-
{{ template "repo/diff/comments" dict "root" $ "comments" $line.Comments}}
223-
</ui>
224-
</div>
225-
{{template "repo/diff/comment_form_datahandler" dict "reply" (index $line.Comments 0).ReviewID "hidden" true "root" $ "comment" (index $line.Comments 0)}}
226-
{{if and $.CanMarkConversation $isNotPending}}
227-
<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" >
228-
{{if $resolved}}
229-
{{$.i18n.Tr "repo.issues.review.un_resolve_conversation"}}
230-
{{else}}
231-
{{$.i18n.Tr "repo.issues.review.resolve_conversation"}}
232-
{{end}}
207+
<div class="conversation-holder">
208+
{{if and $resolved (eq $line.GetCommentSide "proposed")}}
209+
<div class="ui top attached header">
210+
<span class="ui grey text left"><b>{{$resolveDoer.Name}}</b> {{$.i18n.Tr "repo.issues.review.resolved_by"}}</span>
211+
<button id="show-outdated-{{(index $line.Comments 0).ID}}" data-comment="{{(index $line.Comments 0).ID}}" class="ui compact right labeled button show-outdated">
212+
{{svg "octicon-unfold"}}
213+
{{$.i18n.Tr "repo.issues.review.show_resolved"}}
233214
</button>
234-
{{end}}
235-
</div>
236-
{{end}}
215+
<button id="hide-outdated-{{(index $line.Comments 0).ID}}" data-comment="{{(index $line.Comments 0).ID}}" class="hide ui compact right labeled button hide-outdated">
216+
{{svg "octicon-fold"}}
217+
{{$.i18n.Tr "repo.issues.review.hide_resolved"}}
218+
</button>
219+
</div>
220+
{{end}}
221+
{{if eq $line.GetCommentSide "proposed"}}
222+
<div id="code-comments-{{(index $line.Comments 0).ID}}" class="field comment-code-cloud {{if $resolved}}hide{{end}}">
223+
<div class="comment-list">
224+
<ui class="ui comments">
225+
{{ template "repo/diff/comments" dict "root" $ "comments" $line.Comments}}
226+
</ui>
227+
</div>
228+
{{template "repo/diff/comment_form_datahandler" dict "reply" (index $line.Comments 0).ReviewID "hidden" true "root" $ "comment" (index $line.Comments 0)}}
229+
{{if and $.CanMarkConversation $isNotPending}}
230+
<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" >
231+
{{if $resolved}}
232+
{{$.i18n.Tr "repo.issues.review.un_resolve_conversation"}}
233+
{{else}}
234+
{{$.i18n.Tr "repo.issues.review.resolve_conversation"}}
235+
{{end}}
236+
</button>
237+
{{end}}
238+
</div>
239+
{{end}}
240+
</div>
237241
</td>
238242
</tr>
239243
{{end}}

templates/repo/diff/section_unified.tmpl

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -39,35 +39,37 @@
3939
<tr>
4040
<td colspan="2" class="lines-num"></td>
4141
<td class="add-comment-left add-comment-right" colspan="2">
42-
{{if $resolved}}
43-
<div class = "ui attached header">
44-
<span class="ui grey text left"><b>{{$resolveDoer.Name}}</b> {{$.root.i18n.Tr "repo.issues.review.resolved_by"}}</span>
45-
<button id="show-outdated-{{(index $line.Comments 0).ID}}" data-comment="{{(index $line.Comments 0).ID}}" class="ui compact right labeled button show-outdated">
46-
{{svg "octicon-unfold"}}
47-
{{$.root.i18n.Tr "repo.issues.review.show_resolved"}}
48-
</button>
49-
<button id="hide-outdated-{{(index $line.Comments 0).ID}}" data-comment="{{(index $line.Comments 0).ID}}" class="hide ui compact right labeled button hide-outdated">
50-
{{svg "octicon-fold"}}
51-
{{$.root.i18n.Tr "repo.issues.review.hide_resolved"}}
52-
</button>
53-
</div>
54-
{{end}}
55-
<div id="code-comments-{{(index $line.Comments 0).ID}}" class="field comment-code-cloud {{if $resolved}}hide{{end}}">
56-
<div class="comment-list">
57-
<ui class="ui comments">
58-
{{ template "repo/diff/comments" dict "root" $.root "comments" $line.Comments}}
59-
</ui>
60-
</div>
61-
{{template "repo/diff/comment_form_datahandler" dict "hidden" true "reply" (index $line.Comments 0).ReviewID "root" $.root "comment" (index $line.Comments 0)}}
62-
{{if and $.root.CanMarkConversation $isNotPending}}
63-
<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" >
64-
{{if $resolved}}
65-
{{$.root.i18n.Tr "repo.issues.review.un_resolve_conversation"}}
66-
{{else}}
67-
{{$.root.i18n.Tr "repo.issues.review.resolve_conversation"}}
68-
{{end}}
69-
</button>
42+
<div class="conversation-holder">
43+
{{if $resolved}}
44+
<div class = "ui attached header">
45+
<span class="ui grey text left"><b>{{$resolveDoer.Name}}</b> {{$.root.i18n.Tr "repo.issues.review.resolved_by"}}</span>
46+
<button id="show-outdated-{{(index $line.Comments 0).ID}}" data-comment="{{(index $line.Comments 0).ID}}" class="ui compact right labeled button show-outdated">
47+
{{svg "octicon-unfold"}}
48+
{{$.root.i18n.Tr "repo.issues.review.show_resolved"}}
49+
</button>
50+
<button id="hide-outdated-{{(index $line.Comments 0).ID}}" data-comment="{{(index $line.Comments 0).ID}}" class="hide ui compact right labeled button hide-outdated">
51+
{{svg "octicon-fold"}}
52+
{{$.root.i18n.Tr "repo.issues.review.hide_resolved"}}
53+
</button>
54+
</div>
7055
{{end}}
56+
<div id="code-comments-{{(index $line.Comments 0).ID}}" class="field comment-code-cloud {{if $resolved}}hide{{end}}">
57+
<div class="comment-list">
58+
<ui class="ui comments">
59+
{{ template "repo/diff/comments" dict "root" $.root "comments" $line.Comments}}
60+
</ui>
61+
</div>
62+
{{template "repo/diff/comment_form_datahandler" dict "hidden" true "reply" (index $line.Comments 0).ReviewID "root" $.root "comment" (index $line.Comments 0)}}
63+
{{if and $.root.CanMarkConversation $isNotPending}}
64+
<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" >
65+
{{if $resolved}}
66+
{{$.root.i18n.Tr "repo.issues.review.un_resolve_conversation"}}
67+
{{else}}
68+
{{$.root.i18n.Tr "repo.issues.review.resolve_conversation"}}
69+
{{end}}
70+
</button>
71+
{{end}}
72+
</div>
7173
</div>
7274
</td>
7375
</tr>

web_src/js/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,7 +1055,11 @@ async function initRepository() {
10551055
$.post($this.data('url'), {
10561056
_csrf: csrf
10571057
}).done(() => {
1058+
const $conversationHolder = $this.closest('.conversation-holder');
10581059
$(`#${$this.data('comment-id')}`).remove();
1060+
if ($conversationHolder.length && !$conversationHolder.find('.comment').length) {
1061+
$conversationHolder.remove();
1062+
}
10591063
});
10601064
}
10611065
return false;

0 commit comments

Comments
 (0)