Page.jsx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import UserPicture from '../User/UserPicture';
  4. import PageListMeta from './PageListMeta';
  5. import PagePath from './PagePath';
  6. export default class Page extends React.Component {
  7. render() {
  8. const page = this.props.page;
  9. let link = this.props.linkTo;
  10. if (link === '') {
  11. link = page.path;
  12. }
  13. const styleFlex = {
  14. flex: 1,
  15. };
  16. const hasChildren = this.props.children != null;
  17. return (
  18. <li className="page-list-li d-flex align-items-center">
  19. <UserPicture user={page.lastUpdateUser} />
  20. <a className="page-list-link" href={link}>
  21. <PagePath page={page} excludePathString={this.props.excludePathString} />
  22. </a>
  23. <PageListMeta page={page} />
  24. { hasChildren && (
  25. <React.Fragment>
  26. <a style={styleFlex} href={link}>&nbsp;</a>
  27. {this.props.children}
  28. </React.Fragment>
  29. ) }
  30. </li>
  31. );
  32. }
  33. }
  34. Page.propTypes = {
  35. page: PropTypes.object.isRequired,
  36. linkTo: PropTypes.string,
  37. excludePathString: PropTypes.string,
  38. children: PropTypes.array,
  39. };
  40. Page.defaultProps = {
  41. linkTo: '',
  42. excludePathString: '',
  43. };