1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-06 09:21:54 +00:00

add-group

This commit is contained in:
Michael18811380328
2018-12-12 18:24:47 +08:00
parent a088b50514
commit 88b5f119d1
3 changed files with 137 additions and 3 deletions

View File

@@ -0,0 +1,62 @@
import React from 'react';
import PropTypes from 'prop-types';
import { gettext } from '../../utils/constants';
import { seafileAPI } from '../../utils/seafile-api';
import { Modal, ModalHeader, ModalBody, ModalFooter, Input, Button } from 'reactstrap';
class CreateGroupDialog extends React.Component {
constructor(props) {
super(props);
this.state = {
groupName: '',
};
}
handleGroupChange = (event) => {
let name = event.target.value.trim();
this.setState({
groupName: name
});
}
handleSubmitGroup = () => {
let name = this.state.groupName.trim();
if (name) {
let that = this;
seafileAPI.createGroup(name).then((res)=> {
that.props.listGroups();
});
}
this.setState({
groupName: '',
});
this.props.toggleAddGroupModal();
}
render() {
return(
<Modal isOpen={this.props.showAddGroupModal} toggle={this.props.toggleAddGroupModal}>
<ModalHeader toggle={this.toggle}>{gettext('New group')}</ModalHeader>
<ModalBody>
<label htmlFor="groupName">{gettext('Name')}</label>
<Input type="text" id="groupName" value={this.state.groupName} onChange={this.handleGroupChange}/>
</ModalBody>
<ModalFooter>
<Button color="primary" onClick={this.handleSubmitGroup}>{gettext('Submit')}</Button>
<Button color="secondary" onClick={this.props.toggleAddGroupModal}>{gettext('Cancel')}</Button>
</ModalFooter>
</Modal>
);
}
}
const CreateGroupDialogPropTypes = {
toggleAddGroupModal: PropTypes.func.isRequired,
listGroups: PropTypes.func.isRequired,
showAddGroupModal: PropTypes.bool.isRequired,
};
CreateGroupDialog.propTypes = CreateGroupDialogPropTypes;
export default CreateGroupDialog;