gab-social/app/javascript/gabsocial/features/compose/components/upload_form/upload_form.js

54 lines
1.3 KiB
JavaScript
Raw Normal View History

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'
2020-03-27 22:57:03 +00:00
import Upload from '../media_upload_item'
2020-03-26 03:11:32 +00:00
import SensitiveMediaButton from '../sensitive_media_button'
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']),
});
2020-02-25 16:04:44 +00:00
export default
@connect(mapStateToProps)
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,
2020-04-08 02:06:59 +01:00
uploadProgress,
2020-03-26 03:11:32 +00:00
} = 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
}
}