route.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. import React from 'react'; // jshint ignore:line
  2. import { Link } from 'react-router'; // jshint ignore:line
  3. import DropdownToggle from 'misago/components/dropdown-toggle'; // jshint ignore:line
  4. import { TabsNav, CompactNav } from 'misago/components/threads/navs'; // jshint ignore:line
  5. import { getPageTitle, getTitle } from 'misago/components/threads/title-utils';
  6. import ThreadsList from 'misago/components/threads-list/root'; // jshint ignore:line
  7. import WithDropdown from 'misago/components/with-dropdown';
  8. import title from 'misago/services/page-title';
  9. export default class extends WithDropdown {
  10. componentDidMount() {
  11. title.set(getPageTitle(this.props.route));
  12. }
  13. getTitle() {
  14. return getTitle(this.props.route);
  15. }
  16. getClassName() {
  17. let className = 'page page-threads';
  18. className += ' page-threads-' + this.props.route.list;
  19. if (this.props.route.category.css_class) {
  20. className += ' page-' + this.props.route.category.css_class;
  21. }
  22. return className;
  23. }
  24. getHeaderClassName() {
  25. if (this.props.route.lists.length > 1) {
  26. return 'page-header tabbed';
  27. } else {
  28. return 'page-header';
  29. }
  30. }
  31. getGoBackButton() {
  32. if (this.props.route.category.parent) {
  33. /* jshint ignore:start */
  34. return <Link className="btn btn-default btn-aligned btn-icon btn-go-back pull-left"
  35. to={this.props.route.category.parent.absolute_url + this.props.route.list.path}>
  36. <span className="material-icon">
  37. keyboard_arrow_left
  38. </span>
  39. </Link>;
  40. /* jshint ignore:end */
  41. } else {
  42. return null;
  43. }
  44. }
  45. getTabsNav() {
  46. if (this.props.route.lists.length > 1) {
  47. /* jshint ignore:start */
  48. return <TabsNav baseUrl={this.props.route.category.absolute_url}
  49. list={this.props.route.list}
  50. lists={this.props.route.lists}
  51. hideNav={this.hideNav} />;
  52. /* jshint ignore:end */
  53. } else {
  54. return null;
  55. }
  56. }
  57. getCompactNavToggle() {
  58. if (this.props.route.lists.length > 1) {
  59. /* jshint ignore:start */
  60. return <DropdownToggle toggleNav={this.toggleNav}
  61. dropdown={this.state.dropdown} />;
  62. /* jshint ignore:end */
  63. } else {
  64. return null;
  65. }
  66. }
  67. getCompactNav() {
  68. if (this.props.route.lists.length > 1) {
  69. /* jshint ignore:start */
  70. return <CompactNav baseUrl={this.props.route.category.absolute_url}
  71. list={this.props.route.list}
  72. lists={this.props.route.lists}
  73. hideNav={this.hideNav} />;
  74. /* jshint ignore:end */
  75. } else {
  76. return null;
  77. }
  78. }
  79. render() {
  80. /* jshint ignore:start */
  81. return <div className={this.getClassName()}>
  82. <div className={this.getHeaderClassName()}>
  83. <div className="container">
  84. {this.getGoBackButton()}
  85. <h1 className="pull-left">{this.getTitle()}</h1>
  86. {this.getCompactNavToggle()}
  87. </div>
  88. {this.getTabsNav()}
  89. </div>
  90. <div className={this.getCompactNavClassName()}>
  91. {this.getCompactNav()}
  92. </div>
  93. <div className="container">
  94. <ThreadsList />
  95. </div>
  96. </div>;
  97. /* jshint ignore:end */
  98. }
  99. }