Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

show snackbar on password change #3661

Merged
merged 2 commits into from
Nov 28, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions js/src/modals/PasswordManager/passwordManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ import SendIcon from 'material-ui/svg-icons/content/send';
import { Tabs, Tab } from 'material-ui/Tabs';
import Paper from 'material-ui/Paper';

import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { showSnackbar } from '../../redux/providers/snackbarActions';

import Form, { Input } from '../../ui/Form';
import { Button, Modal, IdentityName, IdentityIcon } from '../../ui';

Expand All @@ -30,13 +34,14 @@ import styles from './passwordManager.css';
const TEST_ACTION = 'TEST_ACTION';
const CHANGE_ACTION = 'CHANGE_ACTION';

export default class PasswordManager extends Component {
class PasswordManager extends Component {
static contextTypes = {
api: PropTypes.object.isRequired
}

static propTypes = {
account: PropTypes.object.isRequired,
showSnackbar: PropTypes.func.isRequired,
onClose: PropTypes.func
}

Expand Down Expand Up @@ -333,7 +338,7 @@ export default class PasswordManager extends Component {
}

handleChangePassword = () => {
const { account } = this.props;
const { account, showSnackbar, onClose } = this.props;
const { currentPass, newPass, repeatNewPass, passwordHint } = this.state;

if (repeatNewPass !== newPass) {
Expand Down Expand Up @@ -371,12 +376,9 @@ export default class PasswordManager extends Component {
.changePassword(account.address, currentPass, newPass)
])
.then(() => {
const message = {
value: 'Your password has been successfully changed',
success: true
};

this.setState({ waiting: false, message, showMessage: true });
showSnackbar(<div>Your password has been successfully changed.</div>);
this.setState({ waiting: false, showMessage: false });
onClose();
});
})
.catch(e => {
Expand All @@ -385,3 +387,14 @@ export default class PasswordManager extends Component {
});
}
}

function mapDispatchToProps (dispatch) {
return bindActionCreators({
showSnackbar
}, dispatch);
}

export default connect(
null,
mapDispatchToProps
)(PasswordManager);