forked from hackorum-dev/hackorum
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshow.html.slim
More file actions
216 lines (202 loc) · 11.1 KB
/
show.html.slim
File metadata and controls
216 lines (202 loc) · 11.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
- content_for :title, @topic.title
- content_for :sidebar do
.sidebar
- if @commitfest_sidebar_entries.present?
details.sidebar-section open=true
summary.sidebar-heading Commitfests
.sidebar-section
.commitfest-list
- @commitfest_sidebar_entries.each do |entry|
.commitfest-entry
.commitfest-entry-header
= link_to entry[:commitfest_name], "https://commitfest.postgresql.org/#{entry[:commitfest_external_id]}/", target: "_blank", rel: "noopener", class: "commitfest-link"
span.commitfest-status = entry[:status].presence || "Unknown"
- if entry[:patch_title].present?
.commitfest-patch
= link_to entry[:patch_title], "https://commitfest.postgresql.org/patch/#{entry[:patch_external_id]}/", target: "_blank", rel: "noopener", class: "commitfest-patch-link"
- if entry[:tags].present?
.commitfest-tags
- entry[:tags].each do |tag|
span.commitfest-tag = tag
- if @commitfest_reviewers.present?
details.sidebar-section open=true
summary.sidebar-heading Reviewers
.sidebar-section
ul.commitfest-reviewers
- @commitfest_reviewers.each do |reviewer|
li = reviewer
- if @commitfest_committers.present?
details.sidebar-section open=true
summary.sidebar-heading Committer
.sidebar-section
ul.commitfest-committers
- @commitfest_committers.each do |committer|
li = committer
- if user_signed_in?
- note_map = @notes_by_message || {}
- message_note_entries = note_map.keys.filter_map do |key|
- next unless key.is_a?(Integer)
- notes = note_map[key]
- next if notes.blank?
- number = @message_numbers[key]
- next unless number
- [key, number, notes]
- message_note_entries = message_note_entries.sort_by { |entry| entry[1] }
- if message_note_entries.any?
details.sidebar-section open=true
summary.sidebar-heading Notes
.sidebar-section
ul.note-overview
- message_note_entries.each do |message_id, number, notes|
li
= link_to "#message-#{message_id}", class: "note-overview-link" do
span.note-overview-target = "##{number}"
span.note-overview-count = "(#{notes.size})"
details.sidebar-section open=true
summary.sidebar-heading Participants
.sidebar-section
- if @participants.present?
.participants-list
- max_participants = 12
- @participants.first(max_participants).each do |participant|
= render partial: "participant_row", locals: { participant: participant, avatar_size: 40 }
- if @participants.size > max_participants
.participant-more "+ #{(@participants.size - max_participants)} more"
- else
p No participants yet
- attachment_messages = @messages.select { |msg| msg.attachments.any? }
details.sidebar-section open=true
summary.sidebar-heading Attachments
.sidebar-section
- if @has_patches
.download-patchset style="margin-bottom: 1rem;"
= link_to latest_patchset_topic_path(@topic), class: "button download-button", download: "topic-#{@topic.id}-patchset.tar.gz", data: { turbo: false } do
i.fas.fa-download
span Download Latest Patchset
- if attachment_messages.any?
ul.attachments-list
- attachment_messages.sort_by(&:created_at).reverse_each do |msg|
- number = @message_numbers[msg.id]
li
= link_to "#message-#{msg.id}-attachments", class: "attachment-link" do
span.attachment-target = "##{number}"
span.attachment-date = smart_time_display(msg.created_at)
- names = msg.attachments.map(&:file_name)
- names.first(2).each do |name|
.attachment-name = name
- if names.size > 2
.attachment-more = "+ #{names.size - 2} more"
- else
p No attachments in this thread
details.sidebar-section open=true
summary.sidebar-heading Thread Outline
- if @thread_outline.present?
.thread-outline data-controller="thread-outline"
- @thread_outline.chunk_while { |a, b| a[:branch_segment_index] == b[:branch_segment_index] }.each do |segment|
- first = segment.first
- first_msg = first[:message]
- segment_size = segment.size
- is_reply = first_msg.reply_to_id.present?
- branch_class = "branch-#{first[:branch_index]}"
- can_toggle = @has_multiple_branches && segment_size > 1
- details_classes = ["branch-details", branch_class, ("reply" if is_reply)].compact.join(" ")
- details_open = !@has_multiple_branches
- indent_px = first[:branch_depth].to_i * 10
- first_num = segment.first[:message_number]
- last_num = segment.last[:message_number]
- number_range = first_num == last_num ? "##{first_num}" : "##{first_num}...##{last_num}"
- participants = segment.map { |entry| entry[:message].sender_display_alias }.uniq(&:id).first(6)
- if can_toggle
details class=details_classes open=(details_open ? true : nil) style="margin-left: #{indent_px}px"
summary class="outline-summary" title="Toggle branch with #{segment_size} messages"
.outline-content
.outline-meta
span.outline-number = number_range
.outline-avatars
- participants.each do |participant|
= link_to person_path(participant.email), class: "outline-avatar-link" do
= image_tag participant.display_gravatar_url(size: 24), class: "outline-avatar", alt: participant.name, title: participant.name
- if is_reply
span.outline-icon ↳
span.branch-toggle = "▸"
- if is_reply && first_msg.reply_to
- parent_num = @message_numbers[first_msg.reply_to.id]
span.outline-parent = "to #{first_msg.reply_to.sender_display_alias.name} (##{parent_num})"
.outline-time = smart_time_display(first_msg.created_at)
- segment.each do |entry|
- msg = entry[:message]
- msg_display = msg.sender_display_alias
- is_reply = msg.reply_to_id.present?
- branch_class = "branch-#{entry[:branch_index]}"
- item_indent = entry[:branch_depth].to_i * 10
= link_to "#message-#{msg.id}", class: ["outline-item", ("reply" if is_reply), branch_class, ("branch-start" if entry[:branch_start])].compact.join(" ") do
.outline-content
.outline-meta
span.outline-number = "##{entry[:message_number]}"
= image_tag msg_display.display_gravatar_url(size: 32), class: "outline-avatar", alt: msg_display.name
- if is_reply
span.outline-icon ↳
span.outline-author = msg_display.name
- if is_reply && msg.reply_to
- parent_num = @message_numbers[msg.reply_to.id]
span.outline-parent = "to #{msg.reply_to.sender_display_alias.name} (##{parent_num})"
.outline-time = smart_time_display(msg.created_at)
- else
- segment.each do |entry|
- msg = entry[:message]
- msg_display = msg.sender_display_alias
- is_reply = msg.reply_to_id.present?
- branch_class = "branch-#{entry[:branch_index]}"
- item_indent = entry[:branch_depth].to_i * 10
= link_to "#message-#{msg.id}", class: ["outline-item", ("reply" if is_reply), branch_class, ("branch-start" if entry[:branch_start])].compact.join(" "), style: "margin-left: #{item_indent}px" do
.outline-content
.outline-meta
span.outline-number = "##{entry[:message_number]}"
= image_tag msg_display.display_gravatar_url(size: 32), class: "outline-avatar", alt: msg_display.name
- if is_reply
span.outline-icon ↳
span.outline-author = msg_display.name
- if is_reply && msg.reply_to
- parent_num = @message_numbers[msg.reply_to.id]
span.outline-parent = "to #{msg.reply_to.sender_display_alias.name} (##{parent_num})"
.outline-time = smart_time_display(msg.created_at)
- else
p No messages yet
.topic-header
.topic-title-section
.topic-title-with-star
- if user_signed_in?
= render "star_button", topic: @topic, starred: @is_starred
h1 = @topic.title
.topic-meta
span.creator Started by #{@topic.creator_display_alias.name}
span.date #{time_ago_in_words(@topic.created_at)} ago
span.message-count #{@messages.size} messages
- if current_admin?
.admin-actions
= link_to new_admin_topic_merge_path(@topic), class: "button button-secondary button-small" do
i.fas.fa-compress-arrows-alt
| Merge Topic
- if user_signed_in?
- thread_notes = @notes_by_message&.[](:thread) || []
.thread-notes-container
= render "notes/note_stack", topic: @topic, message: nil, notes: thread_notes
.messages-container.flat.asc
- last_message = @messages.last
- if last_message.present?
.thread-actions data-controller="thread-actions" data-thread-actions-topic-id-value=@topic.id data-thread-actions-read-all-url-value=read_all_topic_path(@topic, format: :json)
- if user_signed_in?
button.button.button-secondary.button-small data-action="click->thread-actions#markAllRead" Mark all messages read
= link_to "Jump to latest", "#message-#{last_message.id}", class: "button button-secondary button-small", title: "Jump to latest message", "aria-label": "Jump to latest message"
- if user_signed_in?
= link_to "Jump to unread", "#first-unread", class: "button button-secondary button-small", title: "Jump to first unread message", "aria-label": "Jump to first unread message"
- first_unread_found = false
- @messages.each do |message|
- is_first_unread = false
- if user_signed_in? && !first_unread_found && !@read_message_ids&.dig(message.id)
- is_first_unread = true
- first_unread_found = true
- branch_index = @message_branch_index&.dig(message.id)
= render 'message', message: message, number: @message_numbers[message.id], is_first_unread: is_first_unread, branch_index: branch_index
.topic-navigation
= link_to "← Back to Topics", topics_path, class: "back-link"