mirror of
https://github.com/status-im/MyCrypto.git
synced 2025-02-09 09:43:34 +00:00
Added logic for changing of decryption selections.
This commit is contained in:
parent
6ac6237f72
commit
87121c8a6d
@ -1,54 +1,65 @@
|
|||||||
import React, {Component} from 'react';
|
import React, {Component} from 'react';
|
||||||
import translate from 'translations';
|
import translate from 'translations';
|
||||||
/*import KeystoreDecrypt from './KeystoreDecrypt';
|
import KeystoreDecrypt from './KeystoreDecrypt';
|
||||||
import PrivateKeyDecrypt from './PrivateKeyDecrypt';
|
import PrivateKeyDecrypt from './PrivateKeyDecrypt';
|
||||||
import MnemonicDecrypt from './MnemonicDecrypt';
|
import MnemonicDecrypt from './MnemonicDecrypt';
|
||||||
import LedgerNanoSDecrypt from './LedgerNanoSDecrypt';
|
import LedgerNanoSDecrypt from './LedgerNanoSDecrypt';
|
||||||
import TrezorDecrypt from './TrezorDecrypt';
|
import TrezorDecrypt from './TrezorDecrypt';
|
||||||
import ViewOnlyDecrypt from './ViewOnlyDecrypt';*/
|
import ViewOnlyDecrypt from './ViewOnlyDecrypt';
|
||||||
|
|
||||||
|
const decryptionChoices = [
|
||||||
|
{
|
||||||
|
name: 'keystore-file',
|
||||||
|
lid: 'x_Keystore2',
|
||||||
|
component: KeystoreDecrypt
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'private-key',
|
||||||
|
lid: 'x_PrivKey2',
|
||||||
|
component: PrivateKeyDecrypt
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'mnemonic-phrase',
|
||||||
|
lid: 'x_Mnemonic',
|
||||||
|
component: MnemonicDecrypt
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'ledger-nano-s',
|
||||||
|
lid: 'x_Ledger',
|
||||||
|
component: LedgerNanoSDecrypt
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'trezor',
|
||||||
|
lid: 'x_Trezor',
|
||||||
|
component: TrezorDecrypt
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'view-only',
|
||||||
|
lid: 'View with Address Only',
|
||||||
|
component: ViewOnlyDecrypt
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
export default class WalletDecrypt extends Component {
|
export default class WalletDecrypt extends Component {
|
||||||
buildDecryptionChoices() {
|
constructor(props) {
|
||||||
const decryptionChoices = [
|
super(props);
|
||||||
{
|
|
||||||
name: 'keystore-file',
|
|
||||||
lid: 'x_Keystore2',
|
|
||||||
// component: KeystoreDecrypt
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'private-key',
|
|
||||||
lid: 'x_PrivKey2',
|
|
||||||
// component: PrivateKeyDecrypt
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'mnemonic-phrase',
|
|
||||||
lid: 'x_Mnemonic',
|
|
||||||
// component: MnemonicDecrypt
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'ledger-nano-s',
|
|
||||||
lid: 'x_Ledger',
|
|
||||||
// component: LedgerNanoSDecrypt
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'trezor',
|
|
||||||
lid: 'x_Trezor',
|
|
||||||
// component: TrezorDecrypt
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'view-only',
|
|
||||||
lid: 'View with Address Only',
|
|
||||||
// component: ViewOnlyDecrypt
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
|
this.state = {
|
||||||
|
decryptionComponent: null
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
buildDecryptionChoices() {
|
||||||
return decryptionChoices.map((decryptionChoice, idx) => {
|
return decryptionChoices.map((decryptionChoice, idx) => {
|
||||||
return (
|
return (
|
||||||
<label className="radio">
|
<label className="radio" key={decryptionChoice.name}>
|
||||||
<input
|
<input
|
||||||
aria-flowto={`aria${idx}`}
|
aria-flowto={`aria${idx}`}
|
||||||
aria-labelledby={`${decryptionChoice.name}-label`}
|
aria-labelledby={`${decryptionChoice.name}-label`}
|
||||||
type="radio"
|
type="radio"
|
||||||
|
name="decryption-choice-radio-group"
|
||||||
|
value={decryptionChoice.name}
|
||||||
|
onChange={this.handleDecryptionChoiceChange.bind(this)}
|
||||||
/>
|
/>
|
||||||
<span id={`${decryptionChoice.name}-label`}>
|
<span id={`${decryptionChoice.name}-label`}>
|
||||||
{translate(decryptionChoice.lid)}
|
{translate(decryptionChoice.lid)}
|
||||||
@ -58,7 +69,23 @@ export default class WalletDecrypt extends Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleDecryptionChoiceChange(event)
|
||||||
|
{
|
||||||
|
const choiceObject = decryptionChoices.find(decryptionChoice => {
|
||||||
|
return (decryptionChoice.name === event.target.value) ? decryptionChoice.component : false;
|
||||||
|
});
|
||||||
|
const decryptionComponent = choiceObject.component;
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
decryptionComponent
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
const decryptionComponent = this.state.decryptionComponent ?
|
||||||
|
<this.state.decryptionComponent /> :
|
||||||
|
<div />;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className="container">
|
<section className="container">
|
||||||
<div className="tab-content">
|
<div className="tab-content">
|
||||||
@ -74,7 +101,10 @@ export default class WalletDecrypt extends Component {
|
|||||||
<h4>{translate('decrypt_Access')}</h4>
|
<h4>{translate('decrypt_Access')}</h4>
|
||||||
|
|
||||||
{this.buildDecryptionChoices()}
|
{this.buildDecryptionChoices()}
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
{decryptionComponent}
|
||||||
</article>
|
</article>
|
||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user