PageListMeta.jsx 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import templateChecker from '@commons/util/template-checker';
  4. import { isTopPage } from '@commons/util/path-utils';
  5. export default class PageListMeta extends React.Component {
  6. render() {
  7. const { page } = this.props;
  8. // portal check
  9. let portalLabel;
  10. if (isTopPage(page.path)) {
  11. portalLabel = <span className="badge badge-info">PORTAL</span>;
  12. }
  13. // template check
  14. let templateLabel;
  15. if (templateChecker(page.path)) {
  16. templateLabel = <span className="badge badge-info">TMPL</span>;
  17. }
  18. let commentCount;
  19. if (page.commentCount > 0) {
  20. commentCount = <span><i className="icon-bubble" />{page.commentCount}</span>;
  21. }
  22. let likerCount;
  23. if (page.liker.length > 0) {
  24. likerCount = <span><i className="icon-like" />{page.liker.length}</span>;
  25. }
  26. let locked;
  27. if (page.grant !== 1) {
  28. locked = <span><i className="icon-lock" /></span>;
  29. }
  30. return (
  31. <span className="page-list-meta">
  32. {portalLabel}
  33. {templateLabel}
  34. {commentCount}
  35. {likerCount}
  36. {locked}
  37. </span>
  38. );
  39. }
  40. }
  41. PageListMeta.propTypes = {
  42. page: PropTypes.object.isRequired,
  43. };
  44. PageListMeta.defaultProps = {
  45. };