1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-22 03:47:09 +00:00

sysadmin reconstrcut orgs frontend (#4074)

* sysadmin reconstruct orgs page

* [system admin] orgs: refactored it
This commit is contained in:
Leo
2019-10-21 09:45:00 +08:00
committed by Daniel Pan
parent e9f511bcd9
commit 07059239d1
21 changed files with 2010 additions and 35 deletions

View File

@@ -0,0 +1,75 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Alert, Modal, ModalHeader, ModalBody, ModalFooter, Button, Form, FormGroup, Input, InputGroup, InputGroupAddon, InputGroupText } from 'reactstrap';
import { gettext } from '../../../utils/constants';
import { Utils } from '../../../utils/utils';
const propTypes = {
toggle: PropTypes.func.isRequired,
updateName: PropTypes.func.isRequired
};
class SysAdminSetOrgNameDialog extends React.Component {
constructor(props) {
super(props);
this.state = {
name: this.props.name,
isSubmitBtnActive: false
};
}
toggle = () => {
this.props.toggle();
}
handleInputChange = (e) => {
const value = e.target.value.trim();
this.setState({
name: value,
isSubmitBtnActive: value != ''
});
}
handleKeyPress = (e) => {
if (e.key == 'Enter') {
this.handleSubmit();
e.preventDefault();
}
}
handleSubmit = () => {
this.props.updateName(this.state.name);
this.toggle();
}
render() {
const { name, isSubmitBtnActive } = this.state;
return (
<Modal isOpen={true} toggle={this.toggle}>
<ModalHeader toggle={this.toggle}>{gettext('Set Name')}</ModalHeader>
<ModalBody>
<Form>
<FormGroup>
<Input
type="text"
className="form-control"
value={name}
onKeyPress={this.handleKeyPress}
onChange={this.handleInputChange}
/>
</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>
);
}
}
SysAdminSetOrgNameDialog.propTypes = propTypes;
export default SysAdminSetOrgNameDialog;