2016-11-16 17:20:52 +01:00
|
|
|
import PureRenderMixin from 'react-addons-pure-render-mixin';
|
2016-11-13 19:08:52 +01:00
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
2016-11-16 17:20:52 +01:00
|
|
|
import IconButton from '../../../components/icon_button';
|
2016-11-18 15:36:16 +01:00
|
|
|
import { defineMessages, injectIntl } from 'react-intl';
|
|
|
|
|
|
|
|
const messages = defineMessages({
|
|
|
|
undo: { id: 'upload_form.undo', defaultMessage: 'Undo' }
|
|
|
|
});
|
2016-11-13 19:08:52 +01:00
|
|
|
|
|
|
|
const UploadForm = React.createClass({
|
|
|
|
|
|
|
|
propTypes: {
|
|
|
|
media: ImmutablePropTypes.list.isRequired,
|
|
|
|
is_uploading: React.PropTypes.bool,
|
|
|
|
onRemoveFile: React.PropTypes.func.isRequired
|
|
|
|
},
|
|
|
|
|
|
|
|
mixins: [PureRenderMixin],
|
|
|
|
|
|
|
|
render () {
|
2016-11-16 17:20:52 +01:00
|
|
|
const { intl } = this.props;
|
|
|
|
|
2016-11-13 19:08:52 +01:00
|
|
|
const uploads = this.props.media.map(attachment => (
|
|
|
|
<div key={attachment.get('id')} style={{ borderRadius: '4px', marginBottom: '10px' }} className='transparent-background'>
|
|
|
|
<div style={{ width: '100%', height: '100px', borderRadius: '4px', background: `url(${attachment.get('preview_url')}) no-repeat center`, backgroundSize: 'cover' }}>
|
2016-11-18 15:36:16 +01:00
|
|
|
<IconButton icon='times' title={intl.formatMessage(messages.undo)} size={36} onClick={this.props.onRemoveFile.bind(this, attachment.get('id'))} />
|
2016-11-13 19:08:52 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
));
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div style={{ marginBottom: '20px', padding: '10px', overflow: 'hidden' }}>
|
|
|
|
{uploads}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2016-11-16 17:20:52 +01:00
|
|
|
export default injectIntl(UploadForm);
|