Page.jsx 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 hasChildren = this.props.children != null;
  14. return (
  15. <li className="nav-item page-list-li w-100">
  16. <a className="nav-link page-list-link d-flex align-items-center" href={link}>
  17. <UserPicture user={page.lastUpdateUser} />
  18. <PagePath page={page} excludePathString={this.props.excludePathString} />
  19. <PageListMeta page={page} />
  20. { hasChildren && (
  21. <React.Fragment>
  22. {this.props.children}
  23. </React.Fragment>
  24. )}
  25. </a>
  26. </li>
  27. );
  28. }
  29. }
  30. Page.propTypes = {
  31. page: PropTypes.object.isRequired,
  32. linkTo: PropTypes.string,
  33. excludePathString: PropTypes.string,
  34. children: PropTypes.array,
  35. };
  36. Page.defaultProps = {
  37. linkTo: '',
  38. excludePathString: '',
  39. };