full.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import React from "react"
  2. import Options from "misago/components/threads-list/thread/subscription/options"
  3. export default class extends React.Component {
  4. getIcon() {
  5. if (this.props.thread.subscription === true) {
  6. return "star"
  7. } else if (this.props.thread.subscription === false) {
  8. return "star_half"
  9. }
  10. return "star_border"
  11. }
  12. getClassName() {
  13. if (this.props.thread.subscription === true) {
  14. return "btn btn-default btn-icon btn-block btn-subscribe btn-subscribe-full dropdown-toggle"
  15. } else if (this.props.thread.subscription === false) {
  16. return "btn btn-default btn-icon btn-block btn-subscribe btn-subscribe-half dropdown-toggle"
  17. }
  18. return "btn btn-default btn-icon btn-block btn-subscribe dropdown-toggle"
  19. }
  20. render() {
  21. const { moderation, subscription } = this.props.thread
  22. const fullwidth = !moderation.length
  23. let className = fullwidth ? "col-xs-12" : "col-xs-6"
  24. className += " hidden-xs hidden-sm"
  25. return (
  26. <div className={className}>
  27. <div className="btn-group btn-group-justified">
  28. <div className="btn-group">
  29. <button
  30. type="button"
  31. className={this.getClassName()}
  32. disabled={this.props.disabled}
  33. data-toggle="dropdown"
  34. aria-haspopup="true"
  35. aria-expanded="false"
  36. >
  37. <span className="material-icon">{this.getIcon()}</span>
  38. <Label moderation={moderation} subscription={subscription} />
  39. </button>
  40. <Options
  41. className="dropdown-menu dropdown-menu-right"
  42. thread={this.props.thread}
  43. />
  44. </div>
  45. </div>
  46. </div>
  47. )
  48. }
  49. }
  50. export function Label({ moderation, subscription }) {
  51. if (moderation.length) return null
  52. let text = gettext("Disabled")
  53. if (subscription === true) {
  54. text = gettext("E-mail")
  55. } else if (subscription === false) {
  56. text = gettext("Enabled")
  57. }
  58. return <span className="btn-text">{text}</span>
  59. }