Skip to content

Commit 232159c

Browse files
committed
Add attached patches to message view
Also let the user expand/collapse them by clicking.
1 parent 67a4c9e commit 232159c

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

app/assets/stylesheets/components/messages.css

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,18 +224,23 @@
224224

225225
.attachment-info {
226226
display: flex;
227-
gap: var(--spacing-3);
228227
align-items: center;
229228
font-size: var(--font-size-sm);
230229
}
231230

231+
summary.attachment-info {
232+
cursor: pointer;
233+
display: list-item;
234+
}
235+
232236
.filename {
233237
font-weight: var(--font-weight-medium);
234238
color: var(--color-text-primary);
235239
}
236240

237241
.content-type {
238242
color: var(--color-text-muted);
243+
margin-left: var(--spacing-3);
239244
}
240245

241246
.import-metadata {

app/views/topics/_message.html.slim

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,19 @@
4141
.message-attachments
4242
h4 Attachments:
4343
- message.attachments.each do |attachment|
44-
.attachment
45-
.attachment-info
46-
span.filename = attachment.file_name
47-
span.content-type = attachment.content_type if attachment.content_type
44+
- if attachment.patch?
45+
details class="attachment"
46+
summary class="attachment-info"
47+
span.filename = attachment.file_name
48+
span.content-type = attachment.content_type if attachment.content_type
49+
pre class="attachment-content"
50+
code class="language-diff"
51+
= attachment.decoded_body
52+
- else
53+
.attachment
54+
.attachment-info
55+
span.filename = attachment.file_name
56+
span.content-type = attachment.content_type if attachment.content_type
4857

4958
- if message.import_log.present?
5059
.import-metadata

0 commit comments

Comments
 (0)