+ data-is-reported="<%= moderation_reports.pluck(:model_id).include?(forum_post.id) %>"
+ <% end %>
+ data-creator="<%= forum_post.creator.name %>">
+
+
+
+ <%= link_to_user forum_post.creator %>
+ <% if forum_post.is_deleted? %>
+ (deleted)
+ <% end %>
+
+ <%= link_to time_ago_in_words_tagged(forum_post.created_at), forum_post, class: "message-timestamp" %>
+
+
+
+
+ <%= format_text(forum_post.body, data: dtext_data) %>
+
+ <%= render "application/update_notice", record: forum_post %>
+
+
+ <%= render "forum_post_votes/list", votes: forum_post.votes, forum_post: forum_post %>
+
+ <% end %>
+
+
+ <% if policy(forum_post).update? %>
+ <% if forum_post.is_original_post?(original_forum_post_id) %>
+ <%= render "forum_topics/form", forum_topic: forum_post.topic %>
+ <% else %>
+ <%= render "forum_posts/partials/edit/form", forum_post: forum_post %>
+ <% end %>
+ <% end %>
+
+
diff --git a/app/components/forum_post_component/forum_post_component.scss b/app/components/forum_post_component/forum_post_component.scss
new file mode 100644
index 000000000..3aa1e0c2e
--- /dev/null
+++ b/app/components/forum_post_component/forum_post_component.scss
@@ -0,0 +1,33 @@
+article.forum-post {
+ &[data-is-reported="true"] {
+ border: var(--moderation-report-border);
+ }
+
+ a.voted {
+ font-weight: bold;
+ }
+
+ .vote-score-up {
+ color: var(--forum-vote-up-color);
+ }
+
+ .vote-score-meh {
+ color: var(--forum-vote-meh-color);
+ }
+
+ .vote-score-down {
+ color: var(--forum-vote-down-color);
+ }
+
+ div.content {
+ .edit_forum_post, .edit_forum_topic {
+ display: none;
+ }
+
+ menu {
+ ul.votes {
+ margin: 0.5em 0;
+ }
+ }
+ }
+}
diff --git a/app/javascript/src/styles/specific/forum.scss b/app/javascript/src/styles/specific/forum.scss
index c672db6e9..da7b75902 100644
--- a/app/javascript/src/styles/specific/forum.scss
+++ b/app/javascript/src/styles/specific/forum.scss
@@ -3,40 +3,6 @@ div.list-of-forum-posts {
font-weight: bold;
color: var(--moderation-report-text-color);
}
-
- article.forum-post {
- &[data-is-reported="true"] {
- border: var(--moderation-report-border);
- }
-
- a.voted {
- font-weight: bold;
- }
-
- .vote-score-up {
- color: var(--forum-vote-up-color);
- }
-
- .vote-score-meh {
- color: var(--forum-vote-meh-color);
- }
-
- .vote-score-down {
- color: var(--forum-vote-down-color);
- }
-
- div.content {
- .edit_forum_post, .edit_forum_topic {
- display: none;
- }
-
- menu {
- ul.votes {
- margin: 0.5em 0;
- }
- }
- }
- }
}
div#c-forum-topics {
diff --git a/app/views/forum_posts/_forum_post.html.erb b/app/views/forum_posts/_forum_post.html.erb
deleted file mode 100644
index 3904f112a..000000000
--- a/app/views/forum_posts/_forum_post.html.erb
+++ /dev/null
@@ -1,58 +0,0 @@
-<% if policy(forum_post).show_deleted? %>
-
- data-is-reported="<%= moderation_reports.pluck(:model_id).include?(forum_post.id) %>"
- <% end %>
- data-creator="<%= forum_post.creator.name %>">
-
-
- <%= link_to_user forum_post.creator %>
- <% if forum_post.is_deleted? %>
- (deleted)
- <% end %>
-
- <%= link_to time_ago_in_words_tagged(forum_post.created_at), forum_post, class: "message-timestamp" %>
-
-
-
- <%= format_text(forum_post.body, data: dtext_data) %>
-
- <%= render "application/update_notice", record: forum_post %>
-
- <%= render "forum_post_votes/list", votes: forum_post.votes, forum_post: forum_post %>
-
- <% end %>
-
- <% if policy(forum_post).update? %>
- <% if forum_post.is_original_post?(original_forum_post_id) %>
- <%= render "forum_topics/form", :forum_topic => forum_post.topic %>
- <% else %>
- <%= render "forum_posts/partials/edit/form", :forum_post => forum_post %>
- <% end %>
- <% end %>
-
-
-<% end %>
diff --git a/app/views/forum_posts/_listing.html.erb b/app/views/forum_posts/_listing.html.erb
index 5bea63030..86130e94f 100644
--- a/app/views/forum_posts/_listing.html.erb
+++ b/app/views/forum_posts/_listing.html.erb
@@ -12,7 +12,5 @@
<% end %>
- <% forum_posts.each do |forum_post| %>
- <%= render "forum_posts/forum_post", forum_post: forum_post, original_forum_post_id: original_forum_post_id, dtext_data: dtext_data, moderation_reports: moderation_reports %>
- <% end %>
+ <%= render ForumPostComponent.with_collection(forum_posts, original_forum_post_id: original_forum_post_id, dtext_data: dtext_data, moderation_reports: moderation_reports, current_user: CurrentUser.user) %>