1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-17 15:53:28 +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;

View File

@@ -0,0 +1,43 @@
import React from 'react';
import PropTypes from 'prop-types';
import CommonToolbar from './common-toolbar';
import { Button } from 'reactstrap';
import { gettext } from '../../utils/constants';
const propTypes = {
searchPlaceholder: PropTypes.string,
onShowSidePanel: PropTypes.func.isRequired,
onSearchedClick: PropTypes.func.isRequired,
toggleAddGroupModal: PropTypes.func.isRequired,
};
class GroupsToolbar extends React.Component {
constructor(props) {
super(props);
}
render() {
let { onShowSidePanel, onSearchedClick } = this.props;
let placeHolder = this.props.searchPlaceholder || 'Search files in this library';
return (
<div className="main-panel-north">
<div className="cur-view-toolbar">
<div className="operation">
<Button color="btn btn-secondary operation-item" onClick={this.props.toggleAddGroupModal}>
<i className="fas fa-plus-square op-icon"></i>{gettext("New Group")}
</Button>
</div>
<span title="Side Nav Menu" onClick={onShowSidePanel}
className="sf2-icon-menu side-nav-toggle hidden-md-up d-md-none">
</span>
</div>
<CommonToolbar searchPlaceholder={placeHolder} onSearchedClick={onSearchedClick}/>
</div>
);
}
}
GroupsToolbar.propTypes = propTypes;
export default GroupsToolbar;