diff --git a/framework/core/js/forum/src/components/post-activity.js b/framework/core/js/forum/src/components/post-activity.js new file mode 100644 index 000000000..8cbf66263 --- /dev/null +++ b/framework/core/js/forum/src/components/post-activity.js @@ -0,0 +1,38 @@ +import Component from 'flarum/component'; +import humanTime from 'flarum/helpers/human-time'; +import avatar from 'flarum/helpers/avatar'; +import listItems from 'flarum/helpers/list-items'; +import ItemList from 'flarum/utils/item-list'; + +export default class PostActivity extends Component { + view() { + var activity = this.props.activity; + var user = activity.user(); + var post = activity.post(); + var discussion = post.discussion(); + + return m('div', [ + avatar(user, {className: 'activity-icon'}), + m('div.activity-info', [ + m('strong', post.number() == 1 ? 'Started a discussion' : 'Posted a reply'), + humanTime(activity.time()) + ]), + m('a.activity-content.post-activity', {href: app.route('discussion.near', { + id: discussion.id(), + slug: discussion.slug(), + near: post.number() + }), config: m.route}, [ + m('ul.list-inline', listItems(this.headerItems().toArray())), + m('div.body', m.trust(post.contentHtml())) + ]) + ]); + } + + headerItems() { + var items = new ItemList(); + + items.add('title', m('h3.title', this.props.activity.post().discussion().title())); + + return items; + } +}