mirror of
https://github.com/haiwen/seahub.git
synced 2025-07-15 07:52:14 +00:00
commit
f003f94e48
@ -10,6 +10,7 @@ class CreateGroupDialog extends React.Component {
|
|||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
groupName: '',
|
groupName: '',
|
||||||
|
errorMsg: '',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -18,6 +19,11 @@ class CreateGroupDialog extends React.Component {
|
|||||||
this.setState({
|
this.setState({
|
||||||
groupName: name
|
groupName: name
|
||||||
});
|
});
|
||||||
|
if (this.state.errorMsg) {
|
||||||
|
this.setState({
|
||||||
|
errorMsg: ''
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleSubmitGroup = () => {
|
handleSubmitGroup = () => {
|
||||||
@ -25,13 +31,23 @@ class CreateGroupDialog extends React.Component {
|
|||||||
if (name) {
|
if (name) {
|
||||||
let that = this;
|
let that = this;
|
||||||
seafileAPI.createGroup(name).then((res)=> {
|
seafileAPI.createGroup(name).then((res)=> {
|
||||||
that.props.listGroups();
|
that.props.onCreateGroup();
|
||||||
|
}).catch((error) => {
|
||||||
|
let errorMsg = gettext(error.response.data.error_msg);
|
||||||
|
this.setState({
|
||||||
|
errorMsg: errorMsg
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
this.setState({
|
this.setState({
|
||||||
groupName: '',
|
groupName: '',
|
||||||
});
|
});
|
||||||
this.props.toggleAddGroupModal();
|
}
|
||||||
|
|
||||||
|
handleKeyDown = (e) => {
|
||||||
|
if (e.keyCode === 13) {
|
||||||
|
this.handleSubmitGroup();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
@ -40,11 +56,13 @@ class CreateGroupDialog extends React.Component {
|
|||||||
<ModalHeader toggle={this.toggle}>{gettext('New group')}</ModalHeader>
|
<ModalHeader toggle={this.toggle}>{gettext('New group')}</ModalHeader>
|
||||||
<ModalBody>
|
<ModalBody>
|
||||||
<label htmlFor="groupName">{gettext('Name')}</label>
|
<label htmlFor="groupName">{gettext('Name')}</label>
|
||||||
<Input type="text" id="groupName" value={this.state.groupName} onChange={this.handleGroupChange}/>
|
<Input type="text" id="groupName" value={this.state.groupName}
|
||||||
|
onChange={this.handleGroupChange} onKeyDown={this.handleKeyDown}/>
|
||||||
|
<span className="error">{this.state.errorMsg}</span>
|
||||||
</ModalBody>
|
</ModalBody>
|
||||||
<ModalFooter>
|
<ModalFooter>
|
||||||
<Button color="primary" onClick={this.handleSubmitGroup}>{gettext('Submit')}</Button>
|
|
||||||
<Button color="secondary" onClick={this.props.toggleAddGroupModal}>{gettext('Cancel')}</Button>
|
<Button color="secondary" onClick={this.props.toggleAddGroupModal}>{gettext('Cancel')}</Button>
|
||||||
|
<Button color="primary" onClick={this.handleSubmitGroup}>{gettext('Submit')}</Button>
|
||||||
</ModalFooter>
|
</ModalFooter>
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
@ -53,7 +71,7 @@ class CreateGroupDialog extends React.Component {
|
|||||||
|
|
||||||
const CreateGroupDialogPropTypes = {
|
const CreateGroupDialogPropTypes = {
|
||||||
toggleAddGroupModal: PropTypes.func.isRequired,
|
toggleAddGroupModal: PropTypes.func.isRequired,
|
||||||
listGroups: PropTypes.func.isRequired,
|
onCreateGroup: PropTypes.func.isRequired,
|
||||||
showAddGroupModal: PropTypes.bool.isRequired,
|
showAddGroupModal: PropTypes.bool.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ class GroupsToolbar extends React.Component {
|
|||||||
let { onShowSidePanel, onSearchedClick } = this.props;
|
let { onShowSidePanel, onSearchedClick } = this.props;
|
||||||
return (
|
return (
|
||||||
<div className="main-panel-north">
|
<div className="main-panel-north">
|
||||||
<div className="cur-view-toolbar">
|
<div className="cur-view-toolbar border-left-show">
|
||||||
<div className="operation">
|
<div className="operation">
|
||||||
<Button color="btn btn-secondary operation-item" onClick={this.props.toggleAddGroupModal}>
|
<Button color="btn btn-secondary operation-item" onClick={this.props.toggleAddGroupModal}>
|
||||||
<i className="fas fa-plus-square op-icon"></i>{gettext("New Group")}
|
<i className="fas fa-plus-square op-icon"></i>{gettext("New Group")}
|
||||||
|
@ -122,6 +122,15 @@ class GroupsView extends React.Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onCreateGroup = () => {
|
||||||
|
this.setState({
|
||||||
|
showAddGroupModal: false,
|
||||||
|
isLoading: true,
|
||||||
|
groupList: [],
|
||||||
|
});
|
||||||
|
this.listGroups();
|
||||||
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.listGroups();
|
this.listGroups();
|
||||||
}
|
}
|
||||||
@ -154,7 +163,7 @@ class GroupsView extends React.Component {
|
|||||||
{ this.state.showAddGroupModal &&
|
{ this.state.showAddGroupModal &&
|
||||||
<CreateGroupDialog
|
<CreateGroupDialog
|
||||||
toggleAddGroupModal={this.toggleAddGroupModal}
|
toggleAddGroupModal={this.toggleAddGroupModal}
|
||||||
listGroups={this.listGroups}
|
onCreateGroup={this.onCreateGroup}
|
||||||
showAddGroupModal={this.state.showAddGroupModal}
|
showAddGroupModal={this.state.showAddGroupModal}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user