1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-06-19 11:52:41 +00:00
seahub/frontend/src/components/dialog/sysadmin-dialog/set-quota.js
杨顺强 ccab6f1552
Update react version 3 (#7453)
* update react version

* update reactstrap

* optimize code

* update react-select version

* update react-responsive

* update react-chartjs version

* update qrocde version

* update seafile-editor version

* update tldraw editor version

* fix code bug
2025-02-14 14:04:25 +08:00

84 lines
2.2 KiB
JavaScript

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 = {
toggle: PropTypes.func.isRequired,
updateQuota: PropTypes.func.isRequired
};
class SetQuotaDialog extends React.Component {
constructor(props) {
super(props);
this.state = {
quota: '',
isSubmitBtnActive: false
};
}
toggle = () => {
this.props.toggle();
};
handleQuotaChange = (e) => {
const value = e.target.value;
this.setState({
quota: value,
isSubmitBtnActive: value.trim() != ''
});
};
handleKeyDown = (e) => {
if (e.key == 'Enter') {
this.handleSubmit();
e.preventDefault();
}
};
handleSubmit = () => {
this.props.updateQuota(this.state.quota.trim());
this.toggle();
};
render() {
const { quota, isSubmitBtnActive } = this.state;
return (
<Modal isOpen={true} toggle={this.toggle}>
<SeahubModalHeader toggle={this.toggle}>{gettext('Set Quota')}</SeahubModalHeader>
<ModalBody>
<Form>
<FormGroup>
<InputGroup>
<Input
type="text"
className="form-control"
value={quota}
onKeyDown={this.handleKeyDown}
onChange={this.handleQuotaChange}
/>
<InputGroupText>MB</InputGroupText>
</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>
);
}
}
SetQuotaDialog.propTypes = propTypes;
export default SetQuotaDialog;