mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Adopt post list component and new posts route front-end (#30604)
Recently we introduced a new `PostList` component (d886c55f63). In this update, we make broader adoption of this component. In particular, these areas include using the new component in the user activity stream pages, user's deleted posts, and pending posts page. This update also takes the existing `posts` route and adds a barebones front-end for it to view posts all in one page.
---------
Co-authored-by: David Taylor <david@taylorhq.com>
This commit is contained in:
@@ -5,15 +5,43 @@ require_relative "post_item_excerpt"
|
||||
class GroupPostSerializer < ApplicationSerializer
|
||||
include PostItemExcerpt
|
||||
|
||||
attributes :id, :created_at, :title, :url, :category_id, :post_number, :topic_id, :post_type
|
||||
attributes :id,
|
||||
:created_at,
|
||||
:topic_id,
|
||||
:topic_title,
|
||||
:topic_slug,
|
||||
:topic_html_title,
|
||||
:url,
|
||||
:category_id,
|
||||
:post_number,
|
||||
:posts_count,
|
||||
:post_type,
|
||||
:username,
|
||||
:name,
|
||||
:avatar_template,
|
||||
:user_title,
|
||||
:primary_group_name
|
||||
|
||||
# TODO(keegan): Remove `embed: :object` after updating references in discourse-reactions
|
||||
has_one :user, serializer: GroupPostUserSerializer, embed: :object
|
||||
has_one :topic, serializer: BasicTopicSerializer, embed: :object
|
||||
|
||||
def title
|
||||
def topic_title
|
||||
object.topic.title
|
||||
end
|
||||
|
||||
def topic_html_title
|
||||
object.topic.fancy_title
|
||||
end
|
||||
|
||||
def topic_slug
|
||||
object.topic.slug
|
||||
end
|
||||
|
||||
def posts_count
|
||||
object.topic.posts_count
|
||||
end
|
||||
|
||||
def include_user_long_name?
|
||||
SiteSetting.enable_names?
|
||||
end
|
||||
@@ -21,4 +49,24 @@ class GroupPostSerializer < ApplicationSerializer
|
||||
def category_id
|
||||
object.topic.category_id
|
||||
end
|
||||
|
||||
def username
|
||||
object&.user&.username
|
||||
end
|
||||
|
||||
def name
|
||||
object&.user&.name
|
||||
end
|
||||
|
||||
def avatar_template
|
||||
object&.user&.avatar_template
|
||||
end
|
||||
|
||||
def user_title
|
||||
object&.user&.title
|
||||
end
|
||||
|
||||
def primary_group_name
|
||||
object&.user&.primary_group&.name
|
||||
end
|
||||
end
|
||||
|
||||
@@ -17,6 +17,7 @@ class PostSerializer < BasicPostSerializer
|
||||
|
||||
attributes :post_number,
|
||||
:post_type,
|
||||
:posts_count,
|
||||
:updated_at,
|
||||
:reply_count,
|
||||
:reply_to_post_number,
|
||||
@@ -84,12 +85,14 @@ class PostSerializer < BasicPostSerializer
|
||||
:last_wiki_edit,
|
||||
:locked,
|
||||
:excerpt,
|
||||
:truncated,
|
||||
:reviewable_id,
|
||||
:reviewable_score_count,
|
||||
:reviewable_score_pending_count,
|
||||
:user_suspended,
|
||||
:user_status,
|
||||
:mentioned_users
|
||||
:mentioned_users,
|
||||
:post_url
|
||||
|
||||
def initialize(object, opts)
|
||||
super(object, opts)
|
||||
@@ -99,6 +102,10 @@ class PostSerializer < BasicPostSerializer
|
||||
end
|
||||
end
|
||||
|
||||
def post_url
|
||||
object&.url
|
||||
end
|
||||
|
||||
def topic_slug
|
||||
topic&.slug
|
||||
end
|
||||
@@ -119,6 +126,14 @@ class PostSerializer < BasicPostSerializer
|
||||
@add_excerpt
|
||||
end
|
||||
|
||||
def include_truncated?
|
||||
@add_excerpt
|
||||
end
|
||||
|
||||
def truncated
|
||||
true
|
||||
end
|
||||
|
||||
def topic_title
|
||||
topic&.title
|
||||
end
|
||||
@@ -127,6 +142,10 @@ class PostSerializer < BasicPostSerializer
|
||||
topic&.fancy_title
|
||||
end
|
||||
|
||||
def posts_count
|
||||
topic&.posts_count
|
||||
end
|
||||
|
||||
def category_id
|
||||
topic&.category_id
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user