2019-07-04 05:49:16 +00:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2019-07-16 02:01:09 +00:00
|
|
|
import { Modal, ModalHeader, ModalBody, ModalFooter, Button } from 'reactstrap';
|
2019-07-04 05:49:16 +00:00
|
|
|
import { gettext, username } from '../../utils/constants';
|
|
|
|
import { seafileAPI } from '../../utils/seafile-api';
|
2019-07-16 02:01:09 +00:00
|
|
|
import { Utils } from '../../utils/utils';
|
|
|
|
import toaster from '../toast';
|
2019-07-04 05:49:16 +00:00
|
|
|
|
|
|
|
class LeaveGroupDialog extends React.Component {
|
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
}
|
|
|
|
|
2019-07-05 03:05:26 +00:00
|
|
|
leaveGroup = () => {
|
2019-07-04 05:49:16 +00:00
|
|
|
seafileAPI.quitGroup(this.props.groupID, username).then((res)=> {
|
2019-07-05 03:05:26 +00:00
|
|
|
this.props.onGroupChanged();
|
2019-07-16 02:01:09 +00:00
|
|
|
}).catch(error => {
|
|
|
|
let errMessage = Utils.getErrorMsg(error);
|
|
|
|
toaster.danger(errMessage);
|
2019-07-04 05:49:16 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return(
|
|
|
|
<Modal isOpen={true} toggle={this.props.toggleLeaveGroupDialog}>
|
|
|
|
<ModalHeader toggle={this.props.toggleLeaveGroupDialog}>{gettext('Leave Group')}</ModalHeader>
|
|
|
|
<ModalBody>
|
2019-07-05 03:05:26 +00:00
|
|
|
<p>{gettext('Really want to leave this group?')}</p>
|
2019-07-04 05:49:16 +00:00
|
|
|
</ModalBody>
|
|
|
|
<ModalFooter>
|
|
|
|
<Button color="secondary" onClick={this.props.toggleLeaveGroupDialog}>{gettext('Cancel')}</Button>
|
2019-07-05 03:05:26 +00:00
|
|
|
<Button color="primary" onClick={this.leaveGroup}>{gettext('Leave')}</Button>
|
2019-07-04 05:49:16 +00:00
|
|
|
</ModalFooter>
|
|
|
|
</Modal>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const LeaveGroupDialogPropTypes = {
|
|
|
|
toggleLeaveGroupDialog: PropTypes.func.isRequired,
|
|
|
|
groupID: PropTypes.string.isRequired,
|
|
|
|
onGroupChanged: PropTypes.func.isRequired,
|
|
|
|
};
|
|
|
|
|
|
|
|
LeaveGroupDialog.propTypes = LeaveGroupDialogPropTypes;
|
|
|
|
|
|
|
|
export default LeaveGroupDialog;
|