icon.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import React from 'react';
  2. export default class extends React.Component {
  3. getClassName() {
  4. if (this.props.thread.is_read) {
  5. return 'read-status item-read';
  6. } else {
  7. return 'read-status item-new';
  8. }
  9. }
  10. getTitle() {
  11. if (this.props.thread.is_closed) {
  12. if (this.props.thread.is_read) {
  13. return gettext("This thread has no new posts. (closed)");
  14. } else {
  15. return gettext("This thread has new posts. (closed)");
  16. }
  17. } else {
  18. if (this.props.thread.is_read) {
  19. return gettext("This thread has no new posts.");
  20. } else {
  21. return gettext("This thread has new posts.");
  22. }
  23. }
  24. }
  25. getIcon() {
  26. if (this.props.thread.is_read) {
  27. return 'chat_bubble_outline';
  28. } else {
  29. return 'chat_bubble';
  30. }
  31. }
  32. getUrl() {
  33. if (this.props.thread.is_read) {
  34. return this.props.thread.last_post_url;
  35. } else {
  36. return this.props.thread.new_post_url;
  37. }
  38. }
  39. render() {
  40. /* jshint ignore:start */
  41. return <a className={this.getClassName()} href={this.getUrl()} title={this.getTitle()}>
  42. <span className="material-icon">
  43. {this.getIcon()}
  44. </span>
  45. </a>;
  46. /* jshint ignore:end */
  47. }
  48. }