2021-02-04 19:15:23 +01:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2021-02-19 20:03:44 +01:00
|
|
|
|
|
|
|
import Dropdown from '../../../components/ui/dropdown';
|
2016-11-04 22:39:53 +01:00
|
|
|
|
2016-11-04 23:08:50 +01:00
|
|
|
// Subviews
|
2021-02-04 19:15:23 +01:00
|
|
|
import JsonImportView from './json';
|
|
|
|
import PrivateKeyImportView from './private-key';
|
2017-01-18 01:22:22 +01:00
|
|
|
|
2020-01-13 16:12:53 +01:00
|
|
|
export default class AccountImportSubview extends Component {
|
|
|
|
static contextTypes = {
|
|
|
|
t: PropTypes.func,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2016-11-04 23:08:50 +01:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
state = {};
|
2016-11-04 22:39:53 +01:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
getMenuItemTexts() {
|
2021-02-04 19:15:23 +01:00
|
|
|
return [this.context.t('privateKey'), this.context.t('jsonFile')];
|
2020-01-13 16:12:53 +01:00
|
|
|
}
|
2018-03-29 17:00:44 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
renderImportView() {
|
2021-02-04 19:15:23 +01:00
|
|
|
const { type } = this.state;
|
|
|
|
const menuItems = this.getMenuItemTexts();
|
|
|
|
const current = type || menuItems[0];
|
2016-11-04 22:39:53 +01:00
|
|
|
|
2020-01-13 16:12:53 +01:00
|
|
|
switch (current) {
|
|
|
|
case this.context.t('privateKey'):
|
2021-02-04 19:15:23 +01:00
|
|
|
return <PrivateKeyImportView />;
|
2020-01-13 16:12:53 +01:00
|
|
|
case this.context.t('jsonFile'):
|
2021-02-04 19:15:23 +01:00
|
|
|
return <JsonImportView />;
|
2020-01-13 16:12:53 +01:00
|
|
|
default:
|
2021-02-04 19:15:23 +01:00
|
|
|
return <JsonImportView />;
|
2020-01-13 16:12:53 +01:00
|
|
|
}
|
|
|
|
}
|
2018-03-22 02:40:28 +01:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
render() {
|
2021-02-04 19:15:23 +01:00
|
|
|
const menuItems = this.getMenuItemTexts();
|
|
|
|
const { type } = this.state;
|
2016-11-04 22:39:53 +01:00
|
|
|
|
2020-01-13 16:12:53 +01:00
|
|
|
return (
|
|
|
|
<div className="new-account-import-form">
|
|
|
|
<div className="new-account-import-disclaimer">
|
|
|
|
<span>{this.context.t('importAccountMsg')}</span>
|
|
|
|
<span
|
|
|
|
style={{
|
|
|
|
cursor: 'pointer',
|
|
|
|
textDecoration: 'underline',
|
|
|
|
}}
|
|
|
|
onClick={() => {
|
2020-04-16 23:34:40 +02:00
|
|
|
global.platform.openTab({
|
2020-11-03 00:41:28 +01:00
|
|
|
url:
|
|
|
|
'https://metamask.zendesk.com/hc/en-us/articles/360015289932',
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2020-01-13 16:12:53 +01:00
|
|
|
}}
|
|
|
|
>
|
|
|
|
{this.context.t('here')}
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
<div className="new-account-import-form__select-section">
|
|
|
|
<div className="new-account-import-form__select-label">
|
|
|
|
{this.context.t('selectType')}
|
|
|
|
</div>
|
2021-02-19 20:03:44 +01:00
|
|
|
<Dropdown
|
2020-01-13 16:12:53 +01:00
|
|
|
className="new-account-import-form__select"
|
2021-02-19 20:03:44 +01:00
|
|
|
options={menuItems.map((text) => ({ value: text }))}
|
|
|
|
selectedOption={type || menuItems[0]}
|
|
|
|
onChange={(value) => {
|
|
|
|
this.setState({ type: value });
|
2020-01-13 16:12:53 +01:00
|
|
|
}}
|
|
|
|
/>
|
2019-11-23 05:14:12 +01:00
|
|
|
</div>
|
2020-01-13 16:12:53 +01:00
|
|
|
{this.renderImportView()}
|
2019-11-23 05:14:12 +01:00
|
|
|
</div>
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2016-11-04 23:08:50 +01:00
|
|
|
}
|
|
|
|
}
|