toolbar-top-old.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /* jshint ignore:start */
  2. import React from 'react';
  3. import ReplyButton from './reply-button';
  4. import Subscription from './subscription';
  5. import AddParticipantModal from 'misago/components/add-participant';
  6. import modal from 'misago/services/modal';
  7. import posting from 'misago/services/posting';
  8. export default function(props) {
  9. return (
  10. <div className="toolbar">
  11. <ul className="list-inline">
  12. <GotoNew thread={props.thread} />
  13. <GotoUnapproved thread={props.thread} />
  14. <GotoLast thread={props.thread} />
  15. <Reply openReplyForm={props.openReplyForm} thread={props.thread} />
  16. <StartPoll poll={props.poll} thread={props.thread} />
  17. <AddParticipant thread={props.thread} />
  18. <SubscriptionMenu {...props} />
  19. </ul>
  20. </div>
  21. );
  22. }
  23. export function GotoNew(props) {
  24. if (props.thread.is_new) {
  25. return (
  26. <li>
  27. <a href={props.thread.url.new_post} className="btn btn-default" title={gettext('Go to first new post')}>
  28. {gettext("New")}
  29. </a>
  30. </li>
  31. );
  32. } else {
  33. return null;
  34. }
  35. }
  36. export function GotoUnapproved(props) {
  37. if (props.thread.has_unapproved_posts && props.thread.acl.can_approve) {
  38. return (
  39. <li>
  40. <a href={props.thread.url.unapproved_post} className="btn btn-default" title={gettext('Go to first unapproved post')}>
  41. {gettext("Unapproved")}
  42. </a>
  43. </li>
  44. );
  45. } else {
  46. return null;
  47. }
  48. }
  49. export function GotoLast(props) {
  50. return (
  51. <li>
  52. <a href={props.thread.url.last_post} className="btn btn-default" title={gettext('Go to last post')}>
  53. {gettext("Last")}
  54. </a>
  55. </li>
  56. );
  57. }
  58. export function SubscriptionMenu(props) {
  59. if (!props.user.id) {
  60. return null;
  61. }
  62. return (
  63. <li className="pull-right">
  64. <Subscription className="dropdown toolbar-right" {...props} />
  65. </li>
  66. )
  67. }
  68. export function Reply(props) {
  69. if (!props.thread.acl.can_reply) {
  70. return null;
  71. }
  72. return (
  73. <li className="pull-right">
  74. <ReplyButton onClick={props.openReplyForm} />
  75. </li>
  76. );
  77. }
  78. export class StartPoll extends React.Component {
  79. onClick = () => {
  80. posting.open({
  81. mode: 'POLL',
  82. submit: this.props.thread.api.poll,
  83. thread: this.props.thread,
  84. poll: null
  85. });
  86. }
  87. render() {
  88. if (!this.props.thread.acl.can_start_poll || this.props.thread.poll) {
  89. return null;
  90. }
  91. return (
  92. <li className="pull-right">
  93. <button
  94. className="btn btn-default"
  95. onClick={this.onClick}
  96. type="button"
  97. >
  98. <span className="material-icon">
  99. poll
  100. </span>
  101. {gettext("Add poll")}
  102. </button>
  103. </li>
  104. );
  105. }
  106. }
  107. export class AddParticipant extends React.Component {
  108. onClick = () => {
  109. modal.show(
  110. <AddParticipantModal thread={this.props.thread} />
  111. );
  112. }
  113. render() {
  114. if (!this.props.thread.acl.can_add_participants) return null;
  115. return (
  116. <li className="pull-right">
  117. <button
  118. className="btn btn-default"
  119. onClick={this.onClick}
  120. type="button"
  121. >
  122. <span className="material-icon">
  123. person_add
  124. </span>
  125. {gettext("Add participant")}
  126. </button>
  127. </li>
  128. );
  129. }
  130. }