show snackbar on password change (#3661)

* show snackbar on password change

* Swap last two words
This commit is contained in:
Jannis Redmann 2016-11-29 00:21:54 +01:00 committed by Jaco Greeff
parent 54b656ba05
commit 65f4ba8372

View File

@ -22,6 +22,10 @@ import SendIcon from 'material-ui/svg-icons/content/send';
import { Tabs, Tab } from 'material-ui/Tabs'; import { Tabs, Tab } from 'material-ui/Tabs';
import Paper from 'material-ui/Paper'; 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 Form, { Input } from '../../ui/Form';
import { Button, Modal, IdentityName, IdentityIcon } from '../../ui'; import { Button, Modal, IdentityName, IdentityIcon } from '../../ui';
@ -30,13 +34,14 @@ import styles from './passwordManager.css';
const TEST_ACTION = 'TEST_ACTION'; const TEST_ACTION = 'TEST_ACTION';
const CHANGE_ACTION = 'CHANGE_ACTION'; const CHANGE_ACTION = 'CHANGE_ACTION';
export default class PasswordManager extends Component { class PasswordManager extends Component {
static contextTypes = { static contextTypes = {
api: PropTypes.object.isRequired api: PropTypes.object.isRequired
} }
static propTypes = { static propTypes = {
account: PropTypes.object.isRequired, account: PropTypes.object.isRequired,
showSnackbar: PropTypes.func.isRequired,
onClose: PropTypes.func onClose: PropTypes.func
} }
@ -333,7 +338,7 @@ export default class PasswordManager extends Component {
} }
handleChangePassword = () => { handleChangePassword = () => {
const { account } = this.props; const { account, showSnackbar, onClose } = this.props;
const { currentPass, newPass, repeatNewPass, passwordHint } = this.state; const { currentPass, newPass, repeatNewPass, passwordHint } = this.state;
if (repeatNewPass !== newPass) { if (repeatNewPass !== newPass) {
@ -371,12 +376,9 @@ export default class PasswordManager extends Component {
.changePassword(account.address, currentPass, newPass) .changePassword(account.address, currentPass, newPass)
]) ])
.then(() => { .then(() => {
const message = { showSnackbar(<div>Your password has been successfully changed.</div>);
value: 'Your password has been successfully changed', this.setState({ waiting: false, showMessage: false });
success: true onClose();
};
this.setState({ waiting: false, message, showMessage: true });
}); });
}) })
.catch(e => { .catch(e => {
@ -385,3 +387,14 @@ export default class PasswordManager extends Component {
}); });
} }
} }
function mapDispatchToProps (dispatch) {
return bindActionCreators({
showSnackbar
}, dispatch);
}
export default connect(
null,
mapDispatchToProps
)(PasswordManager);