Skip to content

Commit 33176e8

Browse files
mschoettlezeripath
andauthored
Improve representation of attachments in issues (#11141)
* Improves representation of attachments in issues to a list showing the file name and file size (see #6500 and #6089). Signed-off-by: Matthias Schoettle <[email protected]> * Fixes indentation. Co-authored-by: zeripath <[email protected]>
1 parent 50475ff commit 33176e8

File tree

3 files changed

+25
-21
lines changed

3 files changed

+25
-21
lines changed

templates/repo/issue/view_content.tmpl

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,20 +55,19 @@
5555
</div>
5656
<div id="comment-{{.Issue.ID}}" class="raw-content hide">{{.Issue.Content}}</div>
5757
<div class="edit-content-zone hide" data-write="issue-{{.Issue.ID}}-write" data-preview="issue-{{.Issue.ID}}-preview" data-update-url="{{$.RepoLink}}/issues/{{.Issue.Index}}/content" data-context="{{.RepoLink}}" data-attachment-url="{{$.RepoLink}}/issues/{{.Issue.Index}}/attachments" data-view-attachment-url="{{$.RepoLink}}/issues/{{.Issue.Index}}/view-attachments"></div>
58+
{{if .Issue.Attachments}}
59+
<div class="ui clearing divider"></div>
60+
<div class="ui middle aligned padded grid">
61+
{{template "repo/issue/view_content/attachments" Dict "ctx" $ "Attachments" .Issue.Attachments}}
62+
</div>
63+
{{end}}
5864
</div>
5965
{{$reactions := .Issue.Reactions.GroupByType}}
6066
{{if $reactions}}
6167
<div class="ui attached segment reactions">
6268
{{template "repo/issue/view_content/reactions" Dict "ctx" $ "ActionURL" (Printf "%s/issues/%d/reactions" $.RepoLink .Issue.Index) "Reactions" $reactions}}
6369
</div>
6470
{{end}}
65-
{{if .Issue.Attachments}}
66-
<div class="ui bottom attached segment">
67-
<div class="ui small images">
68-
{{template "repo/issue/view_content/attachments" Dict "ctx" $ "Attachments" .Issue.Attachments}}
69-
</div>
70-
</div>
71-
{{end}}
7271
</div>
7372
</div>
7473

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
{{range .Attachments}}
2-
<a target="_blank" rel="noopener noreferrer" href="{{.DownloadURL}}">
3-
{{if FilenameIsImage .Name}}
4-
<img class="ui image" src="{{.DownloadURL}}" title='{{$.ctx.i18n.Tr "repo.issues.attachment.open_tab" .Name}}'>
5-
{{else}}
6-
<span class="ui image" title='{{$.ctx.i18n.Tr "repo.issues.attachment.download" .Name}}'>{{svg "octicon-desktop-download" 16}}</span>
7-
{{end}}
8-
</a>
2+
<div class="twelve wide column" style="padding: 6px;">
3+
<a target="_blank" rel="noopener noreferrer" href="{{.DownloadURL}}" title='{{$.ctx.i18n.Tr "repo.issues.attachment.open_tab" .Name}}'>
4+
{{if FilenameIsImage .Name}}
5+
<span class="ui image">{{svg "octicon-file-media" 16}}</span>
6+
{{else}}
7+
<span class="ui image">{{svg "octicon-desktop-download" 16}}</span>
8+
{{end}}
9+
<span><strong>{{.Name}}</strong></span>
10+
</a>
11+
</div>
12+
<div class="four wide column" style="padding: 0px;">
13+
<span class="ui text grey right">{{.Size | FileSize}}</span>
14+
</div>
915
{{end}}

templates/repo/issue/view_content/comments.tmpl

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,19 @@
5252
</div>
5353
<div id="comment-{{.ID}}" class="raw-content hide">{{.Content}}</div>
5454
<div class="edit-content-zone hide" data-write="issuecomment-{{.ID}}-write" data-preview="issuecomment-{{.ID}}-preview" data-update-url="{{$.RepoLink}}/comments/{{.ID}}" data-context="{{$.RepoLink}}" data-attachment-url="{{$.RepoLink}}/comments/{{.ID}}/attachments"></div>
55+
{{if .Issue.Attachments}}
56+
<div class="ui clearing divider"></div>
57+
<div class="ui middle aligned padded grid">
58+
{{template "repo/issue/view_content/attachments" Dict "ctx" $ "Attachments" .Issue.Attachments}}
59+
</div>
60+
{{end}}
5561
</div>
5662
{{$reactions := .Reactions.GroupByType}}
5763
{{if $reactions}}
5864
<div class="ui attached segment reactions">
5965
{{template "repo/issue/view_content/reactions" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID) "Reactions" $reactions}}
6066
</div>
6167
{{end}}
62-
{{if .Attachments}}
63-
<div class="ui bottom attached segment">
64-
<div class="ui small images">
65-
{{template "repo/issue/view_content/attachments" Dict "ctx" $ "Attachments" .Attachments}}
66-
</div>
67-
</div>
68-
{{end}}
6968
</div>
7069
</div>
7170
{{else if eq .Type 1}}

0 commit comments

Comments
 (0)