Skip to content

Commit 96add8c

Browse files
authored
Do not show arrows on comment diffs on pull comment pages (#12434)
* Do not show arrows on comment diffs on pull comment pages Prior to this PR it was possible that an expansion arrow could be displayed on comment diffs displayed on the comments pages of pulls These arrows would not successfully work because they were not attached to a commit id - nor can they necessarily be. This PR prevents these from being shown. Fix #10851 Signed-off-by: Andrew Thornton <art27@cantab.net> * as per @silverwind Signed-off-by: Andrew Thornton <art27@cantab.net> * one more indentation fix Signed-off-by: Andrew Thornton <art27@cantab.net> * one more indentation fix Signed-off-by: Andrew Thornton <art27@cantab.net>
1 parent e770c2b commit 96add8c

File tree

1 file changed

+68
-66
lines changed

1 file changed

+68
-66
lines changed
+68-66
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,77 @@
11
{{$file := .file}}
22
{{range $j, $section := $file.Sections}}
33
{{range $k, $line := $section.Lines}}
4-
<tr class="{{DiffLineTypeToStr .GetType}}-code nl-{{$k}} ol-{{$k}}">
5-
{{if eq .GetType 4}}
6-
<td colspan="2" class="lines-num">
7-
{{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 5) }}
8-
<a role="button" class="blob-excerpt" data-url="{{$.root.RepoLink}}/blob_excerpt/{{$.root.AfterCommitID}}" data-query="{{$line.GetBlobExcerptQuery}}&style=unified&direction=down" data-anchor="diff-{{Sha1 $file.Name}}K{{$line.SectionInfo.RightIdx}}">
9-
{{svg "octicon-fold-down" 16}}
10-
</a>
4+
{{if or $.root.AfterCommitID (ne .GetType 4)}}
5+
<tr class="{{DiffLineTypeToStr .GetType}}-code nl-{{$k}} ol-{{$k}}">
6+
{{if eq .GetType 4}}
7+
<td colspan="2" class="lines-num">
8+
{{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 5) }}
9+
<a role="button" class="blob-excerpt" data-url="{{$.root.RepoLink}}/blob_excerpt/{{$.root.AfterCommitID}}" data-query="{{$line.GetBlobExcerptQuery}}&style=unified&direction=down" data-anchor="diff-{{Sha1 $file.Name}}K{{$line.SectionInfo.RightIdx}}">
10+
{{svg "octicon-fold-down" 16}}
11+
</a>
12+
{{end}}
13+
{{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 4) }}
14+
<a role="button" class="blob-excerpt" data-url="{{$.root.RepoLink}}/blob_excerpt/{{$.root.AfterCommitID}}" data-query="{{$line.GetBlobExcerptQuery}}&style=unified&direction=up" data-anchor="diff-{{Sha1 $file.Name}}K{{$line.SectionInfo.RightIdx}}">
15+
{{svg "octicon-fold-up" 16}}
16+
</a>
17+
{{end}}
18+
{{if eq $line.GetExpandDirection 2}}
19+
<a role="button" class="blob-excerpt" data-url="{{$.root.RepoLink}}/blob_excerpt/{{$.root.AfterCommitID}}" data-query="{{$line.GetBlobExcerptQuery}}&style=unified&direction=" data-anchor="diff-{{Sha1 $file.Name}}K{{$line.SectionInfo.RightIdx}}">
20+
{{svg "octicon-fold" 16}}
21+
</a>
22+
{{end}}
23+
</td>
24+
{{else}}
25+
<td class="lines-num lines-num-old" data-line-num="{{if $line.LeftIdx}}{{$line.LeftIdx}}{{end}}"><span rel="{{if $line.LeftIdx}}diff-{{Sha1 $file.Name}}L{{$line.LeftIdx}}{{end}}"></span></td>
26+
<td class="lines-num lines-num-new" data-line-num="{{if $line.RightIdx}}{{$line.RightIdx}}{{end}}"><span rel="{{if $line.RightIdx}}diff-{{Sha1 $file.Name}}R{{$line.RightIdx}}{{end}}"></span></td>
1127
{{end}}
12-
{{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 4) }}
13-
<a role="button" class="blob-excerpt" data-url="{{$.root.RepoLink}}/blob_excerpt/{{$.root.AfterCommitID}}" data-query="{{$line.GetBlobExcerptQuery}}&style=unified&direction=up" data-anchor="diff-{{Sha1 $file.Name}}K{{$line.SectionInfo.RightIdx}}">
14-
{{svg "octicon-fold-up" 16}}
15-
</a>
28+
<td class="lines-type-marker"><span class="mono" data-type-marker="{{$line.GetLineTypeMarker}}"></span></td>
29+
{{if eq .GetType 4}}
30+
<td class="chroma lines-code blob-hunk"><span class="mono wrap">{{$section.GetComputedInlineDiffFor $line}}</span></td>
31+
{{else}}
32+
<td class="chroma lines-code{{if (not $line.RightIdx)}} lines-code-old{{end}}">{{if and $.root.SignedUserID $line.CanComment $.root.PageIsPullFiles}}<a class="ui green button add-code-comment add-code-comment-{{if $line.RightIdx}}right{{else}}left{{end}}" data-path="{{$file.Name}}" data-side="{{if $line.RightIdx}}right{{else}}left{{end}}" data-idx="{{if $line.RightIdx}}{{$line.RightIdx}}{{else}}{{$line.LeftIdx}}{{end}}" data-type-marker="+"></a>{{end}}<span class="mono wrap">{{$section.GetComputedInlineDiffFor $line}}</span></td>
1633
{{end}}
17-
{{if eq $line.GetExpandDirection 2}}
18-
<a role="button" class="blob-excerpt" data-url="{{$.root.RepoLink}}/blob_excerpt/{{$.root.AfterCommitID}}" data-query="{{$line.GetBlobExcerptQuery}}&style=unified&direction=" data-anchor="diff-{{Sha1 $file.Name}}K{{$line.SectionInfo.RightIdx}}">
19-
{{svg "octicon-fold" 16}}
20-
</a>
21-
{{end}}
22-
</td>
23-
{{else}}
24-
<td class="lines-num lines-num-old" data-line-num="{{if $line.LeftIdx}}{{$line.LeftIdx}}{{end}}"><span rel="{{if $line.LeftIdx}}diff-{{Sha1 $file.Name}}L{{$line.LeftIdx}}{{end}}"></span></td>
25-
<td class="lines-num lines-num-new" data-line-num="{{if $line.RightIdx}}{{$line.RightIdx}}{{end}}"><span rel="{{if $line.RightIdx}}diff-{{Sha1 $file.Name}}R{{$line.RightIdx}}{{end}}"></span></td>
26-
{{end}}
27-
<td class="lines-type-marker"><span class="mono" data-type-marker="{{$line.GetLineTypeMarker}}"></span></td>
28-
{{if eq .GetType 4}}
29-
<td class="chroma lines-code blob-hunk"><span class="mono wrap">{{$section.GetComputedInlineDiffFor $line}}</span></td>
30-
{{else}}
31-
<td class="chroma lines-code{{if (not $line.RightIdx)}} lines-code-old{{end}}">{{if and $.root.SignedUserID $line.CanComment $.root.PageIsPullFiles}}<a class="ui green button add-code-comment add-code-comment-{{if $line.RightIdx}}right{{else}}left{{end}}" data-path="{{$file.Name}}" data-side="{{if $line.RightIdx}}right{{else}}left{{end}}" data-idx="{{if $line.RightIdx}}{{$line.RightIdx}}{{else}}{{$line.LeftIdx}}{{end}}" data-type-marker="+"></a>{{end}}<span class="mono wrap">{{$section.GetComputedInlineDiffFor $line}}</span></td>
32-
{{end}}
33-
</tr>
34-
{{if gt (len $line.Comments) 0}}
35-
{{$resolved := (index $line.Comments 0).IsResolved}}
36-
{{$resolveDoer := (index $line.Comments 0).ResolveDoer}}
37-
{{$isNotPending := (not (eq (index $line.Comments 0).Review.Type 0))}}
38-
<tr>
39-
<td colspan="2" class="lines-num"></td>
40-
<td class="add-comment-left add-comment-right" colspan="2">
41-
{{if $resolved}}
42-
<div class = "ui attached header">
43-
<span class="ui grey text left"><b>{{$resolveDoer.Name}}</b> {{$.root.i18n.Tr "repo.issues.review.resolved_by"}}</span>
44-
<button id="show-outdated-{{(index $line.Comments 0).ID}}" data-comment="{{(index $line.Comments 0).ID}}" class="ui compact right labeled button show-outdated">
45-
{{svg "octicon-unfold" 16}}
46-
{{$.root.i18n.Tr "repo.issues.review.show_resolved"}}
47-
</button>
48-
<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">
49-
{{svg "octicon-fold" 16}}
50-
{{$.root.i18n.Tr "repo.issues.review.hide_resolved"}}
51-
</button>
52-
</div>
53-
{{end}}
54-
<div id="code-comments-{{(index $line.Comments 0).ID}}" class="field comment-code-cloud {{if $resolved}}hide{{end}}">
55-
<div class="comment-list">
56-
<ui class="ui comments">
57-
{{ template "repo/diff/comments" dict "root" $.root "comments" $line.Comments}}
58-
</ui>
59-
</div>
60-
{{template "repo/diff/comment_form_datahandler" dict "hidden" true "reply" (index $line.Comments 0).ReviewID "root" $.root "comment" (index $line.Comments 0)}}
61-
{{if and $.root.CanMarkConversation $isNotPending}}
62-
<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" >
63-
{{if $resolved}}
64-
{{$.root.i18n.Tr "repo.issues.review.un_resolve_conversation"}}
65-
{{else}}
66-
{{$.root.i18n.Tr "repo.issues.review.resolve_conversation"}}
34+
</tr>
35+
{{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))}}
39+
<tr>
40+
<td colspan="2" class="lines-num"></td>
41+
<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" 16}}
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" 16}}
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>
6770
{{end}}
68-
</button>
69-
{{end}}
70-
</div>
71-
</td>
72-
</tr>
71+
</div>
72+
</td>
73+
</tr>
74+
{{end}}
7375
{{end}}
7476
{{end}}
7577
{{end}}

0 commit comments

Comments
 (0)