2018-07-18 21:48:30 +02:00
|
|
|
// @flow
|
|
|
|
import React from 'react';
|
2019-02-13 17:27:20 +01:00
|
|
|
import { Form, 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,
|
|
|
|
};
|
|
|
|
|
2019-03-18 06:09:50 +01:00
|
|
|
type State = {
|
|
|
|
password: string,
|
|
|
|
};
|
|
|
|
|
|
|
|
class ModalWalletUnlock extends React.PureComponent<Props, State> {
|
2018-07-18 21:48:30 +02:00
|
|
|
state = {
|
2019-03-18 06:09:50 +01:00
|
|
|
password: '',
|
2018-07-18 21:48:30 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
componentDidUpdate() {
|
|
|
|
const { props } = this;
|
|
|
|
|
|
|
|
if (props.walletUnlockSucceded === true) {
|
|
|
|
props.closeModal();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-18 06:09:50 +01:00
|
|
|
onChangePassword(event: SyntheticInputEvent<*>) {
|
2018-07-18 21:48:30 +02:00
|
|
|
this.setState({ password: event.target.value });
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2019-01-14 19:40:06 +01:00
|
|
|
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')}
|
2019-03-18 06:09:50 +01:00
|
|
|
type='confirm'
|
2018-08-15 21:56:42 +02:00
|
|
|
shouldCloseOnOverlayClick={false}
|
2018-07-18 21:48:30 +02:00
|
|
|
confirmButtonLabel={__('Unlock')}
|
|
|
|
abortButtonLabel={__('Exit')}
|
|
|
|
onConfirmed={() => unlockWallet(password)}
|
|
|
|
onAborted={quit}
|
|
|
|
>
|
2019-03-18 06:09:50 +01:00
|
|
|
<section className='card__content'>
|
2018-09-26 19:48:07 +02:00
|
|
|
<Form onSubmit={() => unlockWallet(password)}>
|
|
|
|
<p>
|
|
|
|
{__(
|
|
|
|
'Your wallet has been encrypted with a local password. Please enter your wallet password to proceed.'
|
2019-01-14 19:40:06 +01:00
|
|
|
)}{' '}
|
|
|
|
<Button
|
2019-03-18 06:09:50 +01:00
|
|
|
button='link'
|
2019-01-14 19:40:06 +01:00
|
|
|
label={__('Learn more')}
|
2019-03-18 06:09:50 +01:00
|
|
|
href='https://lbry.io/faq/wallet-encryption'
|
2019-03-05 05:46:57 +01:00
|
|
|
/>
|
|
|
|
.
|
2018-09-26 19:48:07 +02:00
|
|
|
</p>
|
2019-02-13 17:27:20 +01:00
|
|
|
<FormField
|
|
|
|
autoFocus
|
|
|
|
error={walletUnlockSucceded === false ? 'Incorrect Password' : false}
|
|
|
|
label={__('Wallet Password')}
|
2019-03-18 06:09:50 +01:00
|
|
|
type='password'
|
|
|
|
name='wallet-password'
|
2019-02-13 17:27:20 +01:00
|
|
|
onChange={event => this.onChangePassword(event)}
|
|
|
|
/>
|
2018-09-26 19:48:07 +02:00
|
|
|
</Form>
|
|
|
|
</section>
|
2018-07-18 21:48:30 +02:00
|
|
|
</Modal>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default ModalWalletUnlock;
|