PageAttachmentList.jsx 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import Attachment from './Attachment';
  4. export default class PageAttachmentList extends React.Component {
  5. render() {
  6. if (this.props.attachments <= 0) {
  7. return null;
  8. }
  9. const attachmentList = this.props.attachments.map((attachment, idx) => {
  10. return (
  11. <Attachment
  12. key={`page:attachment:${attachment._id}`}
  13. attachment={attachment}
  14. inUse={this.props.inUse[attachment._id] || false}
  15. onAttachmentDeleteClicked={this.props.onAttachmentDeleteClicked}
  16. isUserLoggedIn={this.props.isUserLoggedIn}
  17. />
  18. );
  19. });
  20. return (
  21. <div>
  22. <ul className="pl-2">
  23. {attachmentList}
  24. </ul>
  25. </div>
  26. );
  27. }
  28. }
  29. PageAttachmentList.propTypes = {
  30. attachments: PropTypes.arrayOf(PropTypes.object),
  31. inUse: PropTypes.objectOf(PropTypes.bool),
  32. onAttachmentDeleteClicked: PropTypes.func,
  33. isUserLoggedIn: PropTypes.bool,
  34. };
  35. PageAttachmentList.defaultProps = {
  36. attachments: [],
  37. inUse: {},
  38. };