You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.4 KiB

  1. import PureRenderMixin from 'react-addons-pure-render-mixin';
  2. import ImmutablePropTypes from 'react-immutable-proptypes';
  3. import IconButton from '../../../components/icon_button';
  4. import { defineMessages, injectIntl } from 'react-intl';
  5. const messages = defineMessages({
  6. undo: { id: 'upload_form.undo', defaultMessage: 'Undo' }
  7. });
  8. const UploadForm = React.createClass({
  9. propTypes: {
  10. media: ImmutablePropTypes.list.isRequired,
  11. is_uploading: React.PropTypes.bool,
  12. onRemoveFile: React.PropTypes.func.isRequired,
  13. intl: React.PropTypes.object.isRequired
  14. },
  15. mixins: [PureRenderMixin],
  16. render () {
  17. const { intl, media } = this.props;
  18. if (!media.size) {
  19. return null;
  20. }
  21. const uploads = media.map(attachment => (
  22. <div key={attachment.get('id')} style={{ borderRadius: '4px', marginBottom: '10px' }} className='transparent-background'>
  23. <div style={{ width: '100%', height: '100px', borderRadius: '4px', background: `url(${attachment.get('preview_url')}) no-repeat center`, backgroundSize: 'cover' }}>
  24. <IconButton icon='times' title={intl.formatMessage(messages.undo)} size={36} onClick={this.props.onRemoveFile.bind(this, attachment.get('id'))} />
  25. </div>
  26. </div>
  27. ));
  28. return (
  29. <div style={{ marginBottom: '20px', padding: '10px', overflow: 'hidden', flexShrink: '0' }}>
  30. {uploads}
  31. </div>
  32. );
  33. }
  34. });
  35. export default injectIntl(UploadForm);