2020-03-26 03:11:32 +00:00
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes'
|
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component'
|
|
|
|
import ProgressBar from '../../../../components/progress_bar'
|
|
|
|
import Upload from '../upload'
|
|
|
|
import SensitiveMediaButton from '../sensitive_media_button'
|
2019-08-09 17:06:27 +01:00
|
|
|
|
2019-08-07 06:02:36 +01:00
|
|
|
const mapStateToProps = state => ({
|
|
|
|
mediaIds: state.getIn(['compose', 'media_attachments']).map(item => item.get('id')),
|
2020-03-26 03:11:32 +00:00
|
|
|
isUploading: state.getIn(['compose', 'is_uploading']),
|
|
|
|
uploadProgress: state.getIn(['compose', 'progress']),
|
2019-08-07 06:02:36 +01:00
|
|
|
});
|
|
|
|
|
2020-02-25 16:04:44 +00:00
|
|
|
export default
|
|
|
|
@connect(mapStateToProps)
|
2019-08-07 06:02:36 +01:00
|
|
|
class UploadForm extends ImmutablePureComponent {
|
2019-07-02 08:10:25 +01:00
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
mediaIds: ImmutablePropTypes.list.isRequired,
|
2020-03-26 03:11:32 +00:00
|
|
|
isUploading: PropTypes.bool,
|
|
|
|
uploadProgress: PropTypes.number,
|
2019-07-02 08:10:25 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
render () {
|
2020-03-26 03:11:32 +00:00
|
|
|
const {
|
|
|
|
mediaIds,
|
|
|
|
isUploading,
|
|
|
|
uploadProgress
|
|
|
|
} = this.props
|
2019-07-02 08:10:25 +01:00
|
|
|
|
|
|
|
return (
|
2020-03-26 03:11:32 +00:00
|
|
|
<div className={_s.default}>
|
|
|
|
<div className={[_s.default, _s.flexRow, _s.flexWrap].join(' ')}>
|
|
|
|
{
|
|
|
|
mediaIds.map(id => (
|
|
|
|
<Upload id={id} key={id} />
|
|
|
|
))
|
|
|
|
}
|
2019-07-02 08:10:25 +01:00
|
|
|
</div>
|
|
|
|
|
2020-03-26 03:11:32 +00:00
|
|
|
{
|
|
|
|
!mediaIds.isEmpty() &&
|
|
|
|
<SensitiveMediaButton />
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
isUploading &&
|
|
|
|
<ProgressBar small progress={uploadProgress} />
|
|
|
|
}
|
2019-07-02 08:10:25 +01:00
|
|
|
</div>
|
2020-03-26 03:11:32 +00:00
|
|
|
)
|
2019-07-02 08:10:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|