1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-04 00:20:07 +00:00
Files
seahub/frontend/src/components/dialog/sysadmin-dialog/sysadmin-user-set-name-dialog.js
Leo 852fe1b8ee sysadmin reconstruct user page (#4030)
* sysadmin reconstruct user page

* [system admin] users: refactored it
2019-10-28 10:29:20 +08:00

69 lines
1.6 KiB
JavaScript

import React from 'react';
import PropTypes from 'prop-types';
import { Modal, ModalHeader, ModalBody, ModalFooter, Button, Form, FormGroup, Label, Input } from 'reactstrap';
import { gettext } from '../../../utils/constants';
const propTypes = {
toggle: PropTypes.func.isRequired,
onNameChanged: PropTypes.func.isRequired
};
class SysAdminUserSetNameDialog extends React.Component {
constructor(props) {
super(props);
this.state = {
name: '',
};
}
toggle = () => {
this.props.toggle();
}
handleNameChange = (e) => {
this.setState({name: e.target.value.trim()});
}
handleKeyPress = (e) => {
if (e.key === 'Enter') {
this.handleSubmit();
e.preventDefault();
}
}
handleSubmit = () => {
let { name } = this.state;
this.props.onNameChanged(name);
}
render() {
let { name } = this.state;
return (
<Modal isOpen={true} toggle={this.toggle}>
<ModalHeader toggle={this.toggle}>{gettext('Set user name')}</ModalHeader>
<ModalBody>
<Form>
<FormGroup>
<Input
id="repoName"
onKeyPress={this.handleKeyPress}
value={name}
onChange={this.handleNameChange}
/>
</FormGroup>
</Form>
</ModalBody>
<ModalFooter>
<Button color="secondary" onClick={this.toggle}>{gettext('Cancel')}</Button>
<Button color="primary" onClick={this.handleSubmit}>{gettext('Submit')}</Button>
</ModalFooter>
</Modal>
);
}
}
SysAdminUserSetNameDialog.propTypes = propTypes;
export default SysAdminUserSetNameDialog;