mirror of
https://github.com/flarum/framework.git
synced 2025-05-22 14:49:57 +08:00
Reuse CommentPost component for PostsUserPage
This commit is contained in:
@ -1,56 +0,0 @@
|
||||
import Activity from 'flarum/components/Activity';
|
||||
import listItems from 'flarum/helpers/listItems';
|
||||
import ItemList from 'flarum/utils/ItemList';
|
||||
import { truncate } from 'flarum/utils/string';
|
||||
|
||||
/**
|
||||
* The `PostedActivity` component displays an activity feed item for when a user
|
||||
* started or posted in a discussion.
|
||||
*
|
||||
* ### Props
|
||||
*
|
||||
* - All of the props for Activity
|
||||
*/
|
||||
export default class PostedActivity extends Activity {
|
||||
user() {
|
||||
return this.props.post.user();
|
||||
}
|
||||
|
||||
time() {
|
||||
return this.props.post.time();
|
||||
}
|
||||
|
||||
description() {
|
||||
return app.trans(this.props.post.number() === 1 ? 'core.started_a_discussion' : 'core.posted_a_reply');
|
||||
}
|
||||
|
||||
content() {
|
||||
const post = this.props.post;
|
||||
|
||||
return (
|
||||
<a className="Activity-content PostedActivity-preview"
|
||||
href={app.route.post(post)}
|
||||
config={m.route}>
|
||||
<ul className="PostedActivity-header">
|
||||
{listItems(this.headerItems().toArray())}
|
||||
</ul>
|
||||
<div className="PostedActivity-body">
|
||||
{m.trust(truncate(post.contentPlain(), 200))}
|
||||
</div>
|
||||
</a>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build an item list for the header of the post preview.
|
||||
*
|
||||
* @return {[type]}
|
||||
*/
|
||||
headerItems() {
|
||||
const items = new ItemList();
|
||||
|
||||
items.add('title', <h3>{this.props.post.discussion().title()}</h3>);
|
||||
|
||||
return items;
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
import UserPage from 'flarum/components/UserPage';
|
||||
import LoadingIndicator from 'flarum/components/LoadingIndicator';
|
||||
import Button from 'flarum/components/Button';
|
||||
import PostedActivity from 'flarum/components/PostedActivity';
|
||||
import CommentPost from 'flarum/components/CommentPost';
|
||||
|
||||
/**
|
||||
* The `PostsUserPage` component shows a user's activity feed inside of their
|
||||
@ -61,10 +61,15 @@ export default class PostsUserPage extends UserPage {
|
||||
|
||||
return (
|
||||
<div className="PostsUserPage">
|
||||
<ul className="PostsUserPage-list ActivityList">
|
||||
{this.posts.map(post => {
|
||||
return <li>{PostedActivity.component({post})}</li>;
|
||||
})}
|
||||
<ul className="PostsUserPage-list">
|
||||
{this.posts.map(post => (
|
||||
<li>
|
||||
<div className="PostsUserPage-discussion">
|
||||
In <a href={app.route.post(post)} config={m.route}>{post.discussion().title()}</a>
|
||||
</div>
|
||||
{CommentPost.component({post, showDiscussionTitle: true})}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
{footer}
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user