container.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import React from 'react';
  2. import PageLead from 'misago/components/page-lead'; // jshint ignore:line
  3. import Toolbar from 'misago/components/threads/toolbar'; // jshint ignore:line
  4. export default class extends React.Component {
  5. getCategoryDescription() {
  6. if (this.props.pageLead) {
  7. /* jshint ignore:start */
  8. return (
  9. <div className="category-description">
  10. <div className="page-lead">
  11. <p>{this.props.pageLead}</p>
  12. </div>
  13. </div>
  14. );
  15. /* jshint ignore:end */
  16. } else if (this.props.route.category.description) {
  17. /* jshint ignore:start */
  18. return (
  19. <div className="category-description">
  20. <PageLead copy={this.props.route.category.description.html} />
  21. </div>
  22. );
  23. /* jshint ignore:end */
  24. } else {
  25. return null;
  26. }
  27. }
  28. getDisableToolbar() {
  29. return !this.props.isLoaded || this.props.isBusy || this.props.busyThreads.length;
  30. }
  31. getToolbar() {
  32. const isVisible = this.props.subcategories.length || this.props.user.id;
  33. if (!isVisible) return null;
  34. /* jshint ignore:start */
  35. return (
  36. <Toolbar
  37. subcategories={this.props.subcategories}
  38. categories={this.props.route.categories}
  39. categoriesMap={this.props.route.categoriesMap}
  40. list={this.props.route.list}
  41. threads={this.props.threads}
  42. moderation={this.props.moderation}
  43. selection={this.props.selection}
  44. selectAllThreads={this.props.selectAllThreads}
  45. selectNoneThreads={this.props.selectNoneThreads}
  46. addThreads={this.props.addThreads}
  47. freezeThread={this.props.freezeThread}
  48. deleteThread={this.props.deleteThread}
  49. updateThread={this.props.updateThread}
  50. api={this.props.api}
  51. route={this.props.route}
  52. disabled={this.getDisableToolbar()}
  53. user={this.props.user}
  54. />
  55. );
  56. /* jshint ignore:end */
  57. }
  58. render() {
  59. /* jshint ignore:start */
  60. return (
  61. <div className="container">
  62. {this.getCategoryDescription()}
  63. {this.getToolbar()}
  64. {this.props.children}
  65. </div>
  66. );
  67. /* jshint ignore:end */
  68. }
  69. }