1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-08-05 17:14:28 +00:00
seahub/frontend/src/components/dialog/reset-encrypted-repo-password-dialog.js

68 lines
2.0 KiB
JavaScript
Raw Normal View History

import React from 'react';
import PropTypes from 'prop-types';
import { Modal, ModalHeader, ModalBody } from 'reactstrap';
import { gettext, contactEmail } from '../../utils/constants';
import { seafileAPI } from '../../utils/seafile-api';
const propTypes = {
repoID: PropTypes.string.isRequired,
toggleDialog: PropTypes.func.isRequired,
};
class ResetEncryptedRepoPasswordDialog extends React.Component {
constructor(props) {
super(props);
this.state = {
errMessage: '',
showLoading: true,
showSuccess: false,
showError: false,
};
}
componentDidMount() {
seafileAPI.resetAndSendEncryptedRepoPassword(this.props.repoID).then((res) => {
2024-07-18 03:58:42 +00:00
this.setState({ showLoading: false });
this.setState({ showSuccess: true });
}).catch((error) => {
if (error.response) {
this.setState({
errMessage: error.response.data.error_msg
});
2024-07-18 03:58:42 +00:00
this.setState({ showLoading: false });
this.setState({ showError: true });
}
});
}
render() {
let user_email = '<strong>' + contactEmail + '</strong>';
let message = gettext('New password has been sent to your email {mail}. Please check your mailbox. If you dont receive the password, please check if your email address is properly configured.').replace('{mail}', user_email);
return (
<Modal isOpen={true} toggle={this.props.toggleDialog}>
<ModalHeader toggle={this.props.toggleDialog}>
{gettext('Reset library password')}
</ModalHeader>
<ModalBody>
{this.state.showLoading && (
<span>{gettext('Sending new password...')}</span>
)}
{this.state.showSuccess && (
2024-07-18 03:58:42 +00:00
<div dangerouslySetInnerHTML={{ __html: message }} />
)}
{this.state.showError && (
<span className="err-message">{this.state.errMessage}</span>
)}
</ModalBody>
</Modal>
);
}
}
ResetEncryptedRepoPasswordDialog.propTypes = propTypes;
export default ResetEncryptedRepoPasswordDialog;