2019-08-12 15:21:42 +00:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import { Link } from 'react-router';
|
2019-09-10 22:42:23 +00:00
|
|
|
import InlineSVG from 'react-inlinesvg';
|
2019-08-12 15:21:42 +00:00
|
|
|
import FileUploader from './FileUploader';
|
|
|
|
import { getreachedTotalSizeLimit } from '../selectors/users';
|
|
|
|
|
2019-09-10 22:42:23 +00:00
|
|
|
import exitUrl from '../../../images/exit.svg';
|
|
|
|
|
2019-08-12 15:21:42 +00:00
|
|
|
class UploadFileModal extends React.Component {
|
|
|
|
propTypes = {
|
2019-09-10 22:42:23 +00:00
|
|
|
reachedTotalSizeLimit: PropTypes.bool.isRequired,
|
|
|
|
closeModal: PropTypes.func.isRequired
|
|
|
|
}
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
this.focusOnModal();
|
2019-08-12 15:21:42 +00:00
|
|
|
}
|
|
|
|
|
2019-09-10 22:42:23 +00:00
|
|
|
focusOnModal = () => {
|
|
|
|
this.modal.focus();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-08-12 15:21:42 +00:00
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<section className="modal" ref={(element) => { this.modal = element; }}>
|
2019-09-10 22:42:23 +00:00
|
|
|
<div className="modal-content">
|
|
|
|
<div className="modal__header">
|
|
|
|
<h2 className="modal__title">Upload File</h2>
|
|
|
|
<button className="modal__exit-button" onClick={this.props.closeModal}>
|
|
|
|
<InlineSVG src={exitUrl} alt="Close New File Modal" />
|
|
|
|
</button>
|
2019-08-12 15:21:42 +00:00
|
|
|
</div>
|
2019-09-10 22:42:23 +00:00
|
|
|
{ this.props.reachedTotalSizeLimit &&
|
|
|
|
<p>
|
|
|
|
{
|
|
|
|
`You have reached the size limit for the number of files you can upload to your account.
|
|
|
|
If you would like to upload more, please remove the ones you aren't using anymore by
|
|
|
|
looking through your `
|
|
|
|
}
|
|
|
|
<Link to="/assets">assets</Link>
|
|
|
|
{'.'}
|
|
|
|
</p>
|
|
|
|
}
|
|
|
|
{ !this.props.reachedTotalSizeLimit &&
|
|
|
|
<div>
|
|
|
|
<FileUploader />
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
</div>
|
2019-08-12 15:21:42 +00:00
|
|
|
</section>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function mapStateToProps(state) {
|
|
|
|
return {
|
|
|
|
reachedTotalSizeLimit: getreachedTotalSizeLimit(state)
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export default connect(mapStateToProps)(UploadFileModal);
|