ready.js 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. import React from 'react';
  2. import Loader from 'misago/components/loader'; // jshint ignore:line
  3. import DetailsCompact from 'misago/components/threads-list/thread/details/compact'; // jshint ignore:line
  4. import DetailsFull from 'misago/components/threads-list/thread/details/full'; // jshint ignore:line
  5. import Flags from 'misago/components/threads-list/thread/flags'; // jshint ignore:line
  6. import Icon from 'misago/components/threads-list/thread/icon'; // jshint ignore:line
  7. import ThreadOptions from 'misago/components/threads-list/thread/options'; // jshint ignore:line
  8. export default class extends React.Component {
  9. getIcon() {
  10. if (this.props.isBusy) {
  11. /* jshint ignore:start */
  12. return <Loader />;
  13. /* jshint ignore:end */
  14. } else {
  15. /* jshint ignore:start */
  16. return <Icon thread={this.props.thread} />;
  17. /* jshint ignore:end */
  18. }
  19. }
  20. getOptions() {
  21. if (this.props.showOptions) {
  22. /* jshint ignore:start */
  23. return <ThreadOptions thread={this.props.thread}
  24. disabled={this.props.isBusy}
  25. isSelected={this.props.isSelected} />;
  26. /* jshint ignore:end */
  27. } else {
  28. return null;
  29. }
  30. }
  31. getClassName() {
  32. let styles = ['list-group-item'];
  33. if (this.props.thread.is_read) {
  34. styles.push('thread-read');
  35. } else {
  36. styles.push('thread-new');
  37. }
  38. if (this.props.isBusy) {
  39. styles.push('thread-busy');
  40. } else if (this.props.isSelected) {
  41. styles.push('thread-selected');
  42. }
  43. if (this.props.showOptions) {
  44. if (this.props.thread.moderation.length) {
  45. styles.push('thread-ops-two');
  46. } else {
  47. styles.push('thread-ops-one');
  48. }
  49. }
  50. return styles.join(' ');
  51. }
  52. render () {
  53. /* jshint ignore:start */
  54. return <li className={this.getClassName()}>
  55. <div className="thread-icon">
  56. {this.getIcon()}
  57. <Flags thread={this.props.thread} />
  58. </div>
  59. {this.getOptions()}
  60. <div className="thread-main">
  61. <a href={this.props.thread.url.index} className="item-title thread-title">
  62. {this.props.thread.title}
  63. </a>
  64. <DetailsFull categories={this.props.categories}
  65. list={this.props.list}
  66. thread={this.props.thread} />
  67. <DetailsCompact categories={this.props.categories}
  68. list={this.props.list}
  69. thread={this.props.thread} />
  70. </div>
  71. <div className="clearfix" />
  72. </li>;
  73. /* jshint ignore:end */
  74. }
  75. }