import React from 'react';
import { Link } from 'react-router'; // jshint ignore:line
import ReadIcon from 'misago/components/threads-list/read-icon'; // jshint ignore:line
import ThreadOptions from 'misago/components/threads-list/thread-options'; // jshint ignore:line
import escapeHtml from 'misago/utils/escape-html';
const LAST_POSTER_URL = '%(user)s';
const LAST_POSTER_SPAN = '%(user)s';
const LAST_REPLY_URL = '%(relative)s';
export class Category extends React.Component {
getClassName() {
if (this.props.category.css_class) {
return 'thread-category thread-category-' + this.props.category.css_class;
} else {
return 'thread-category';
}
}
getUrl() {
return this.props.category.absolute_url + this.props.list.path;
}
render() {
/* jshint ignore:start */
return
{this.props.category.name}
;
/* jshint ignore:end */
}
}
export default class extends React.Component {
constructor(props) {
super(props);
this.state = {
isSelected: false
};
}
getNewLabel() {
if (!this.props.thread.is_read) {
/* jshint ignore:start */
return
comment
{gettext("New posts")}
;
/* jshint ignore:end */
} else {
return null;
}
}
getPinnedLabel() {
if (this.props.thread.weight === 2) {
/* jshint ignore:start */
return
bookmark_border
{gettext("Pinned globally")}
;
/* jshint ignore:end */
} else if (this.props.thread.weight === 1) {
/* jshint ignore:start */
return
bookmark_border
{gettext("Pinned locally")}
;
/* jshint ignore:end */
} else {
return null;
}
}
getClosedLabel() {
if (this.props.thread.is_closed) {
/* jshint ignore:start */
return
lock_outline
{gettext("Closed")}
;
/* jshint ignore:end */
} else {
return null;
}
}
getPath() {
let top = this.props.categories[this.props.thread.top_category];
let bottom = this.props.categories[this.props.thread.category];
if (top && bottom && top.id !== bottom.id) {
/* jshint ignore:start */
return
arrow_forward
;
/* jshint ignore:end */
} else if (top || bottom) {
/* jshint ignore:start */
return
;
/* jshint ignore:end */
} else {
return null;
}
}
getRepliesCount() {
/* jshint ignore:start */
let message = ngettext(
"%(replies)s reply",
"%(replies)s replies",
this.props.thread.replies);
return
forum
{interpolate(message, {
replies: this.props.thread.replies,
}, true)}
;
/* jshint ignore:end */
}
getLastReplyDate() {
return interpolate(LAST_REPLY_URL, {
url: escapeHtml(this.props.thread.last_post_url),
absolute: escapeHtml(this.props.thread.last_post_on.format('LLL')),
relative: escapeHtml(this.props.thread.last_post_on.fromNow())
}, true);
}
getLastPoster() {
if (this.props.thread.last_poster_url) {
return interpolate(LAST_POSTER_URL, {
url: escapeHtml(this.props.thread.last_poster_url),
user: escapeHtml(this.props.thread.last_poster_name)
}, true);
} else {
return interpolate(LAST_POSTER_SPAN, {
user: escapeHtml(this.props.thread.last_poster_name)
}, true);
}
}
getLastReply() {
/* jshint ignore:start */
return ;
/* jshint ignore:end */
}
getOptions() {
if (this.props.user.id) {
/* jshint ignore:start */
return ;
/* jshint ignore:end */
} else {
return null;
}
}
getClassName() {
if (this.props.thread.is_read) {
if (this.props.isBusy) {
return 'list-group-item thread-read thread-busy';
} else if (this.props.isSelected) {
return 'list-group-item thread-read thread-selected';
} else {
return 'list-group-item thread-read';
}
} else {
if (this.props.isBusy) {
return 'list-group-item thread-new thread-busy';
} else if (this.props.isSelected) {
return 'list-group-item thread-new thread-selected';
} else {
return 'list-group-item thread-new';
}
}
}
render () {
/* jshint ignore:start */
return
{this.props.thread.title}
{this.getNewLabel()}
{this.getPinnedLabel()}
{this.getClosedLabel()}
{this.getPath()}
{this.getRepliesCount()}
{this.getLastReply()}
{this.getOptions()}
;
/* jshint ignore:end */
}
}