1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-08-04 16:49:40 +00:00
seahub/frontend/src/components/dialog/reset-encrypted-repo-password-dialog.js
lian 82bae67d93 user reset repo password (#2913)
* user reset encrypted repo's password

* update

* send email when user reset encrypted repo's password

* resetEncryptedRepoPassword -> resetAndSendEncryptedRepoPassword

* update message

* update message

* bold email when show success msg
2019-02-13 12:02:55 +08:00

70 lines
2.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import React from 'react';
import PropTypes from 'prop-types';
import toaster from '../../components/toast';
import { Button, Form, FormGroup, Label, Input, Modal, ModalHeader, ModalBody, ModalFooter, Alert } from 'reactstrap';
import { gettext, contactEmail } from '../../utils/constants';
import { Utils } from '../../utils/utils';
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) => {
this.setState({showLoading: false});
this.setState({showSuccess: true});
}).catch((error) => {
if (error.response) {
this.setState({
errMessage: error.response.data.error_msg
});
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} centered={true}>
<ModalHeader toggle={this.props.toggleDialog}>
{gettext('Reset library password')}
</ModalHeader>
<ModalBody>
{this.state.showLoading && (
<span>{gettext('Sending new password...')}</span>
)}
{this.state.showSuccess && (
<div dangerouslySetInnerHTML={{__html:message}} />
)}
{this.state.showError && (
<span className="err-message">{this.state.errMessage}</span>
)}
</ModalBody>
</Modal>
);
}
}
ResetEncryptedRepoPasswordDialog.propTypes = propTypes;
export default ResetEncryptedRepoPasswordDialog;