lbry-desktop/src/renderer/modal/modalWalletUnlock/view.jsx

79 lines
2 KiB
React
Raw Normal View History

2018-07-18 21:48:30 +02:00
// @flow
import React from 'react';
2018-07-25 19:45:28 +02:00
import { Form, FormRow, FormField } from 'component/common/form';
2018-07-18 21:48:30 +02:00
import { Modal } from 'modal/modal';
import Button from 'component/button';
type Props = {
quit: () => void,
2019-01-19 19:54:06 +01:00
closeModal: () => void,
unlockWallet: (?string) => void,
2018-07-18 21:48:30 +02:00
walletUnlockSucceded: boolean,
};
class ModalWalletUnlock extends React.PureComponent<Props> {
state = {
password: null,
};
componentDidUpdate() {
const { props } = this;
if (props.walletUnlockSucceded === true) {
props.closeModal();
}
}
onChangePassword(event) {
this.setState({ password: event.target.value });
}
render() {
const { quit, unlockWallet, walletUnlockSucceded } = this.props;
2018-07-18 21:48:30 +02:00
const { password } = this.state;
return (
<Modal
isOpen
2018-09-26 19:48:07 +02:00
title={__('Unlock Wallet')}
2018-07-18 21:48:30 +02:00
contentLabel={__('Unlock Wallet')}
type="confirm"
shouldCloseOnOverlayClick={false}
2018-07-18 21:48:30 +02:00
confirmButtonLabel={__('Unlock')}
abortButtonLabel={__('Exit')}
onConfirmed={() => unlockWallet(password)}
onAborted={quit}
>
2018-09-26 19:48:07 +02:00
<section className="card__content">
<Form onSubmit={() => unlockWallet(password)}>
<p>
{__(
'Your wallet has been encrypted with a local password. Please enter your wallet password to proceed.'
)}{' '}
<Button
button="link"
label={__('Learn more')}
href="https://lbry.io/faq/wallet-encryption"
/>.
2018-09-26 19:48:07 +02:00
</p>
<FormRow padded>
<FormField
stretch
autoFocus
error={walletUnlockSucceded === false ? 'Incorrect Password' : false}
label={__('Wallet Password')}
type="password"
name="wallet-password"
onChange={event => this.onChangePassword(event)}
/>
</FormRow>
</Form>
</section>
2018-07-18 21:48:30 +02:00
</Modal>
);
}
}
export default ModalWalletUnlock;