PageListMeta.jsx 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import { templateChecker, pagePathUtils } from '@growi/core';
  4. const { isTopPage } = pagePathUtils;
  5. const { checkTemplatePath } = templateChecker;
  6. export class PageListMeta extends React.Component {
  7. render() {
  8. const { page } = this.props;
  9. // top check
  10. let topLabel;
  11. if (isTopPage(page.path)) {
  12. topLabel = <span className="badge badge-info">TOP</span>;
  13. }
  14. // template check
  15. let templateLabel;
  16. if (checkTemplatePath(page.path)) {
  17. templateLabel = <span className="badge badge-info">TMPL</span>;
  18. }
  19. let commentCount;
  20. if (page.commentCount != null && page.commentCount > 0) {
  21. commentCount = <span><i className="icon-bubble" />{page.commentCount}</span>;
  22. }
  23. let likerCount;
  24. if (page.liker != null && page.liker.length > 0) {
  25. likerCount = <span><i className="icon-like" />{page.liker.length}</span>;
  26. }
  27. let locked;
  28. if (page.grant !== 1) {
  29. locked = <span><i className="icon-lock" /></span>;
  30. }
  31. let bookmarkCount;
  32. if (this.props.bookmarkCount > 0) {
  33. bookmarkCount = <span><i className="icon-star" />{this.props.bookmarkCount}</span>;
  34. }
  35. return (
  36. <span className="page-list-meta">
  37. {topLabel}
  38. {templateLabel}
  39. {commentCount}
  40. {likerCount}
  41. {locked}
  42. {bookmarkCount}
  43. </span>
  44. );
  45. }
  46. }
  47. PageListMeta.propTypes = {
  48. page: PropTypes.object.isRequired,
  49. bookmarkCount: PropTypes.number,
  50. };
  51. PageListMeta.defaultProps = {
  52. };