header.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. import React from 'react';
  2. import Avatar from 'misago/components/avatar'; // jshint ignore:line
  3. import FollowButton from 'misago/components/profile/follow-button'; // jshint ignore:line
  4. import ModerationNav from 'misago/components/profile/moderation/nav'; // jshint ignore:line
  5. import Status, { StatusIcon, StatusLabel } from 'misago/components/user-status'; // jshint ignore:line
  6. export default class extends React.Component {
  7. getUserStatus() {
  8. /* jshint ignore:start */
  9. return <li className="user-status-display">
  10. <Status user={this.props.profile} status={this.props.profile.status}>
  11. <StatusIcon user={this.props.profile}
  12. status={this.props.profile.status} />
  13. <StatusLabel user={this.props.profile}
  14. status={this.props.profile.status}
  15. className="status-label" />
  16. </Status>
  17. </li>;
  18. /* jshint ignore:end */
  19. }
  20. getUserRank() {
  21. if (this.props.profile.rank.is_tab) {
  22. /* jshint ignore:start */
  23. return <li className="user-rank">
  24. <a href={this.props.profile.rank.absolute_url} className="item-title">
  25. {this.props.profile.rank.name}
  26. </a>
  27. </li>;
  28. /* jshint ignore:end */
  29. } else {
  30. /* jshint ignore:start */
  31. return <li className="user-rank">
  32. <span className="item-title">{this.props.profile.rank.name}</span>
  33. </li>;
  34. /* jshint ignore:end */
  35. }
  36. }
  37. getUserTitle() {
  38. if (this.props.profile.title) {
  39. /* jshint ignore:start */
  40. return <li className="user-title">
  41. {this.props.profile.title}
  42. </li>;
  43. /* jshint ignore:end */
  44. } else if (this.props.profile.rank.title) {
  45. /* jshint ignore:start */
  46. return <li className="user-title">
  47. {this.props.profile.rank.title}
  48. </li>;
  49. /* jshint ignore:end */
  50. } else {
  51. return null;
  52. }
  53. }
  54. getJoinedOn() {
  55. /* jshint ignore:start */
  56. let title = interpolate(gettext("Joined on %(joined_on)s"), {
  57. 'joined_on': this.props.profile.joined_on.format('LL, LT')
  58. }, true);
  59. let age = interpolate(gettext("Joined %(joined_on)s"), {
  60. 'joined_on': this.props.profile.joined_on.fromNow()
  61. }, true);
  62. return <li className="user-joined-on">
  63. <abbr title={title}>
  64. {age}
  65. </abbr>
  66. </li>;
  67. /* jshint ignore:end */
  68. }
  69. getEmail() {
  70. if (this.props.profile.email) {
  71. /* jshint ignore:start */
  72. return <li className="user-email">
  73. <a href={'mailto:' + this.props.profile.email} className="item-title">
  74. {this.props.profile.email}
  75. </a>
  76. </li>;
  77. /* jshint ignore:end */
  78. } else {
  79. return null;
  80. }
  81. }
  82. getFollowButton() {
  83. if (this.props.profile.acl.can_follow) {
  84. /* jshint ignore:start */
  85. return <FollowButton className="btn btn-aligned hidden-xs hidden-sm"
  86. profile={this.props.profile} />;
  87. /* jshint ignore:end */
  88. } else {
  89. return null;
  90. }
  91. }
  92. getModerationButton() {
  93. if (this.props.profile.acl.can_moderate) {
  94. /* jshint ignore:start */
  95. return <div className="btn-group btn-aligned hidden-xs hidden-sm">
  96. <button className="btn btn-default btn-moderate dropdown-toggle"
  97. type="button"
  98. data-toggle="dropdown"
  99. aria-haspopup="true"
  100. aria-expanded="false">
  101. <span className="material-icon">
  102. tonality
  103. </span>
  104. {gettext("Moderation")}
  105. </button>
  106. <ModerationNav profile={this.props.profile} />
  107. </div>;
  108. /* jshint ignore:end */
  109. } else {
  110. return null;
  111. }
  112. }
  113. render() {
  114. /* jshint ignore:start */
  115. return<div className="page-header">
  116. <div className="container">
  117. <div className="row">
  118. <div className="col-md-9 col-md-offset-3">
  119. <h1 className="pull-left">
  120. <Avatar user={this.props.profile} size="100" />
  121. <span className="user-name">{this.props.profile.username}</span>
  122. </h1>
  123. {this.getFollowButton()}
  124. {this.getModerationButton()}
  125. <button className="btn btn-default btn-aligned btn-icon btn-dropdown-toggle hidden-md hidden-lg"
  126. type="button"
  127. onClick={this.props.toggleNav}
  128. aria-haspopup="true"
  129. aria-expanded={this.props.dropdown ? 'true' : 'false'}>
  130. <i className="material-icon">
  131. menu
  132. </i>
  133. </button>
  134. </div>
  135. </div>
  136. </div>
  137. <div className="header-stats">
  138. <div className="container">
  139. <div className="row">
  140. <div className="col-md-9 col-md-offset-3">
  141. <ul className="list-inline">
  142. {this.getUserStatus()}
  143. {this.getUserRank()}
  144. {this.getUserTitle()}
  145. {this.getJoinedOn()}
  146. {this.getEmail()}
  147. </ul>
  148. </div>
  149. </div>
  150. </div>
  151. </div>
  152. </div>;
  153. /* jshint ignore:end */
  154. }
  155. }