import React from 'react'; import PropTypes from 'prop-types'; import { Modal, ModalBody, ModalFooter, Button, Form, FormGroup, Input, InputGroup, InputGroupText } from 'reactstrap'; import { gettext } from '../../../utils/constants'; import SeahubModalHeader from '@/components/common/seahub-modal-header'; const propTypes = { uploadOrDownload: PropTypes.string.isRequired, toggle: PropTypes.func.isRequired, updateUploadDownloadRateLimit: PropTypes.func.isRequired }; class SysAdminSetUploadDownloadRateLimitDialog extends React.Component { constructor(props) { super(props); this.state = { rateLimit: '', isSubmitBtnActive: false }; } toggle = () => { this.props.toggle(); }; handleRateLimitChange = (e) => { const value = e.target.value; this.setState({ rateLimit: value, isSubmitBtnActive: value.trim() != '' }); }; handleKeyDown = (e) => { if (e.key == 'Enter') { this.handleSubmit(); e.preventDefault(); } }; handleSubmit = () => { this.props.updateUploadDownloadRateLimit(this.props.uploadOrDownload, this.state.rateLimit.trim()); this.toggle(); }; render() { const { rateLimit, isSubmitBtnActive } = this.state; return ( {this.props.uploadOrDownload == 'upload' ? gettext('Set Upload Rate Limit') : gettext('Set Download Rate Limit')}
kB/s

{gettext('An integer that is greater than or equal to 0.')}
{gettext('Tip: 0 means default limit')}

); } } SysAdminSetUploadDownloadRateLimitDialog.propTypes = propTypes; export default SysAdminSetUploadDownloadRateLimitDialog;