2019-10-21 01:45:00 +00:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2025-02-14 06:04:25 +00:00
|
|
|
import { Modal, ModalBody, ModalFooter, Button, Form, FormGroup, Input, InputGroup, InputGroupText } from 'reactstrap';
|
2019-10-21 01:45:00 +00:00
|
|
|
import { gettext } from '../../../utils/constants';
|
2024-12-24 03:20:40 +00:00
|
|
|
import SeahubModalHeader from '@/components/common/seahub-modal-header';
|
2019-10-21 01:45:00 +00:00
|
|
|
|
|
|
|
const propTypes = {
|
|
|
|
toggle: PropTypes.func.isRequired,
|
|
|
|
updateQuota: PropTypes.func.isRequired
|
|
|
|
};
|
|
|
|
|
2019-10-28 02:29:20 +00:00
|
|
|
class SetQuotaDialog extends React.Component {
|
2019-10-21 01:45:00 +00:00
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.state = {
|
|
|
|
quota: '',
|
|
|
|
isSubmitBtnActive: false
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
toggle = () => {
|
|
|
|
this.props.toggle();
|
2023-09-13 00:40:50 +00:00
|
|
|
};
|
2019-10-21 01:45:00 +00:00
|
|
|
|
|
|
|
handleQuotaChange = (e) => {
|
2019-11-18 09:26:28 +00:00
|
|
|
const value = e.target.value;
|
2019-10-21 01:45:00 +00:00
|
|
|
this.setState({
|
|
|
|
quota: value,
|
2019-11-18 09:26:28 +00:00
|
|
|
isSubmitBtnActive: value.trim() != ''
|
2019-10-21 01:45:00 +00:00
|
|
|
});
|
2023-09-13 00:40:50 +00:00
|
|
|
};
|
2019-10-21 01:45:00 +00:00
|
|
|
|
2023-11-14 12:25:25 +00:00
|
|
|
handleKeyDown = (e) => {
|
2019-10-21 01:45:00 +00:00
|
|
|
if (e.key == 'Enter') {
|
|
|
|
this.handleSubmit();
|
|
|
|
e.preventDefault();
|
|
|
|
}
|
2023-09-13 00:40:50 +00:00
|
|
|
};
|
2019-10-21 01:45:00 +00:00
|
|
|
|
|
|
|
handleSubmit = () => {
|
2019-11-18 09:26:28 +00:00
|
|
|
this.props.updateQuota(this.state.quota.trim());
|
2019-10-21 01:45:00 +00:00
|
|
|
this.toggle();
|
2023-09-13 00:40:50 +00:00
|
|
|
};
|
2019-10-21 01:45:00 +00:00
|
|
|
|
|
|
|
render() {
|
|
|
|
const { quota, isSubmitBtnActive } = this.state;
|
|
|
|
return (
|
|
|
|
<Modal isOpen={true} toggle={this.toggle}>
|
2024-12-24 03:20:40 +00:00
|
|
|
<SeahubModalHeader toggle={this.toggle}>{gettext('Set Quota')}</SeahubModalHeader>
|
2019-10-21 01:45:00 +00:00
|
|
|
<ModalBody>
|
|
|
|
<Form>
|
|
|
|
<FormGroup>
|
|
|
|
<InputGroup>
|
|
|
|
<Input
|
|
|
|
type="text"
|
|
|
|
className="form-control"
|
|
|
|
value={quota}
|
2023-11-14 12:25:25 +00:00
|
|
|
onKeyDown={this.handleKeyDown}
|
2019-10-21 01:45:00 +00:00
|
|
|
onChange={this.handleQuotaChange}
|
|
|
|
/>
|
2025-02-14 06:04:25 +00:00
|
|
|
<InputGroupText>MB</InputGroupText>
|
2019-10-21 01:45:00 +00:00
|
|
|
</InputGroup>
|
|
|
|
<p className="small text-secondary mt-2 mb-2">
|
|
|
|
{gettext('An integer that is greater than or equal to 0.')}
|
|
|
|
<br />
|
|
|
|
{gettext('Tip: 0 means default limit')}
|
|
|
|
</p>
|
|
|
|
</FormGroup>
|
|
|
|
</Form>
|
|
|
|
</ModalBody>
|
|
|
|
<ModalFooter>
|
|
|
|
<Button color="secondary" onClick={this.toggle}>{gettext('Cancel')}</Button>
|
|
|
|
<Button color="primary" onClick={this.handleSubmit} disabled={!isSubmitBtnActive}>{gettext('Submit')}</Button>
|
|
|
|
</ModalFooter>
|
|
|
|
</Modal>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-28 02:29:20 +00:00
|
|
|
SetQuotaDialog.propTypes = propTypes;
|
2019-10-21 01:45:00 +00:00
|
|
|
|
2019-10-28 02:29:20 +00:00
|
|
|
export default SetQuotaDialog;
|