Skip to content

Commit 47e4d1a

Browse files
jpraetmrsdizzie
andauthored
Reply button is not removed when deleting a code review comment (#13774)
Co-authored-by: mrsdizzie <[email protected]>
1 parent 4353cf9 commit 47e4d1a

File tree

4 files changed

+43
-97
lines changed

4 files changed

+43
-97
lines changed

templates/repo/diff/box.tmpl

Lines changed: 3 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -150,80 +150,19 @@
150150
{{end}}
151151
</tr>
152152
{{if gt (len $line.Comments) 0}}
153-
{{$resolved := (index $line.Comments 0).IsResolved}}
154-
{{$resolveDoer := (index $line.Comments 0).ResolveDoer}}
155-
{{$isNotPending := (not (eq (index $line.Comments 0).Review.Type 0))}}
156153
<tr class="add-code-comment">
157154
<td class="lines-num"></td>
158155
<td class="lines-type-marker"></td>
159156
<td class="add-comment-left">
160-
{{if and $resolved (eq $line.GetCommentSide "previous")}}
161-
<div class="ui top attached header resolved-placeholder">
162-
<span class="ui grey text left"><b>{{$resolveDoer.Name}}</b> {{$.i18n.Tr "repo.issues.review.resolved_by"}}</span>
163-
<button id="show-outdated-{{(index $line.Comments 0).ID}}" data-comment="{{(index $line.Comments 0).ID}}" class="ui tiny right labeled button show-outdated">
164-
{{svg "octicon-unfold"}}
165-
{{$.i18n.Tr "repo.issues.review.show_resolved"}}
166-
</button>
167-
<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">
168-
{{svg "octicon-fold"}}
169-
{{$.i18n.Tr "repo.issues.review.hide_resolved"}}
170-
</button>
171-
</div>
172-
{{end}}
173157
{{if eq $line.GetCommentSide "previous"}}
174-
<div id="code-comments-{{(index $line.Comments 0).ID}}" class="field comment-code-cloud {{if $resolved}}hide{{end}}">
175-
<div class="comment-list">
176-
<ui class="ui comments">
177-
{{ template "repo/diff/comments" dict "root" $ "comments" $line.Comments}}
178-
</ui>
179-
</div>
180-
{{template "repo/diff/comment_form_datahandler" dict "reply" (index $line.Comments 0).ReviewID "hidden" true "root" $ "comment" (index $line.Comments 0)}}
181-
{{if and $.CanMarkConversation $isNotPending}}
182-
<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" >
183-
{{if $resolved}}
184-
{{$.i18n.Tr "repo.issues.review.un_resolve_conversation"}}
185-
{{else}}
186-
{{$.i18n.Tr "repo.issues.review.resolve_conversation"}}
187-
{{end}}
188-
</button>
189-
{{end}}
190-
</div>
158+
{{template "repo/diff/conversation" mergeinto $ "comments" $line.Comments}}
191159
{{end}}
192160
</td>
193161
<td class="lines-num"></td>
194162
<td class="lines-type-marker"></td>
195-
<td class="add-comment-right resolved-placeholder">
196-
{{if and $resolved (eq $line.GetCommentSide "proposed")}}
197-
<div class="ui top attached header">
198-
<span class="ui grey text left"><b>{{$resolveDoer.Name}}</b> {{$.i18n.Tr "repo.issues.review.resolved_by"}}</span>
199-
<button id="show-outdated-{{(index $line.Comments 0).ID}}" data-comment="{{(index $line.Comments 0).ID}}" class="ui tiny right labeled button show-outdated">
200-
{{svg "octicon-unfold"}}
201-
{{$.i18n.Tr "repo.issues.review.show_resolved"}}
202-
</button>
203-
<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">
204-
{{svg "octicon-fold"}}
205-
{{$.i18n.Tr "repo.issues.review.hide_resolved"}}
206-
</button>
207-
</div>
208-
{{end}}
163+
<td class="add-comment-right">
209164
{{if eq $line.GetCommentSide "proposed"}}
210-
<div id="code-comments-{{(index $line.Comments 0).ID}}" class="field comment-code-cloud {{if $resolved}}hide{{end}}">
211-
<div class="comment-list">
212-
<ui class="ui comments">
213-
{{ template "repo/diff/comments" dict "root" $ "comments" $line.Comments}}
214-
</ui>
215-
</div>
216-
{{template "repo/diff/comment_form_datahandler" dict "reply" (index $line.Comments 0).ReviewID "hidden" true "root" $ "comment" (index $line.Comments 0)}}
217-
{{if and $.CanMarkConversation $isNotPending}}
218-
<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" >
219-
{{if $resolved}}
220-
{{$.i18n.Tr "repo.issues.review.un_resolve_conversation"}}
221-
{{else}}
222-
{{$.i18n.Tr "repo.issues.review.resolve_conversation"}}
223-
{{end}}
224-
</button>
225-
{{end}}
226-
</div>
165+
{{template "repo/diff/conversation" mergeinto $ "comments" $line.Comments}}
227166
{{end}}
228167
</td>
229168
</tr>

templates/repo/diff/conversation.tmpl

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{{$resolved := (index .comments 0).IsResolved}}
2+
{{$resolveDoer := (index .comments 0).ResolveDoer}}
3+
{{$isNotPending := (not (eq (index .comments 0).Review.Type 0))}}
4+
<div class="conversation-holder">
5+
{{if $resolved}}
6+
<div class="ui attached header resolved-placeholder">
7+
<span class="ui grey text left"><b>{{$resolveDoer.Name}}</b> {{$.i18n.Tr "repo.issues.review.resolved_by"}}</span>
8+
<button id="show-outdated-{{(index .comments 0).ID}}" data-comment="{{(index .comments 0).ID}}" class="ui tiny right labeled button show-outdated">
9+
{{svg "octicon-unfold"}}
10+
{{$.i18n.Tr "repo.issues.review.show_resolved"}}
11+
</button>
12+
<button id="hide-outdated-{{(index .comments 0).ID}}" data-comment="{{(index .comments 0).ID}}" class="hide ui tiny right labeled button hide-outdated">
13+
{{svg "octicon-fold"}}
14+
{{$.i18n.Tr "repo.issues.review.hide_resolved"}}
15+
</button>
16+
</div>
17+
{{end}}
18+
<div id="code-comments-{{(index .comments 0).ID}}" class="field comment-code-cloud {{if $resolved}}hide{{end}}">
19+
<div class="comment-list">
20+
<ui class="ui comments">
21+
{{template "repo/diff/comments" dict "root" $ "comments" .comments}}
22+
</ui>
23+
</div>
24+
{{template "repo/diff/comment_form_datahandler" dict "hidden" true "reply" (index .comments 0).ReviewID "root" $ "comment" (index .comments 0)}}
25+
{{if and $.CanMarkConversation $isNotPending}}
26+
<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" >
27+
{{if $resolved}}
28+
{{$.i18n.Tr "repo.issues.review.un_resolve_conversation"}}
29+
{{else}}
30+
{{$.i18n.Tr "repo.issues.review.resolve_conversation"}}
31+
{{end}}
32+
</button>
33+
{{end}}
34+
</div>
35+
</div>

templates/repo/diff/section_unified.tmpl

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -33,42 +33,10 @@
3333
{{end}}
3434
</tr>
3535
{{if gt (len $line.Comments) 0}}
36-
{{$resolved := (index $line.Comments 0).IsResolved}}
37-
{{$resolveDoer := (index $line.Comments 0).ResolveDoer}}
38-
{{$isNotPending := (not (eq (index $line.Comments 0).Review.Type 0))}}
3936
<tr>
4037
<td colspan="2" class="lines-num"></td>
4138
<td class="add-comment-left add-comment-right" colspan="2">
42-
{{if $resolved}}
43-
<div class="ui attached header resolved-placeholder">
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 tiny 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 tiny 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>
70-
{{end}}
71-
</div>
39+
{{template "repo/diff/conversation" mergeinto $.root "comments" $line.Comments}}
7240
</td>
7341
</tr>
7442
{{end}}

web_src/js/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,7 +1094,11 @@ async function initRepository() {
10941094
$.post($this.data('url'), {
10951095
_csrf: csrf
10961096
}).done(() => {
1097+
const $conversationHolder = $this.closest('.conversation-holder');
10971098
$(`#${$this.data('comment-id')}`).remove();
1099+
if ($conversationHolder.length && !$conversationHolder.find('.comment').length) {
1100+
$conversationHolder.remove();
1101+
}
10981102
});
10991103
}
11001104
return false;

0 commit comments

Comments
 (0)