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;
|
2021-09-03 17:56:43 +02:00
|
|
|
const { t } = this.context;
|
2016-11-04 22:39:53 +01:00
|
|
|
|
2020-01-13 16:12:53 +01:00
|
|
|
return (
|
2021-09-03 17:56:43 +02:00
|
|
|
<>
|
|
|
|
<div className="page-container__header">
|
2021-11-10 18:29:22 +01:00
|
|
|
<div className="page-container__title">{t('importAccount')}</div>
|
2021-09-03 17:56:43 +02:00
|
|
|
<div className="page-container__subtitle">
|
|
|
|
{t('importAccountMsg')}
|
|
|
|
<span
|
|
|
|
className="new-account-info-link"
|
|
|
|
onClick={() => {
|
|
|
|
global.platform.openTab({
|
2022-07-31 20:26:40 +02:00
|
|
|
url: 'https://metamask.zendesk.com/hc/en-us/articles/360015289932',
|
2021-09-03 17:56:43 +02:00
|
|
|
});
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{t('here')}
|
|
|
|
</span>
|
|
|
|
</div>
|
2020-01-13 16:12:53 +01:00
|
|
|
</div>
|
2021-09-03 17:56:43 +02:00
|
|
|
<div className="new-account-import-form">
|
|
|
|
<div className="new-account-import-form__select-section">
|
|
|
|
<div className="new-account-import-form__select-label">
|
|
|
|
{t('selectType')}
|
|
|
|
</div>
|
|
|
|
<Dropdown
|
|
|
|
className="new-account-import-form__select"
|
|
|
|
options={menuItems.map((text) => ({ value: text }))}
|
|
|
|
selectedOption={type || menuItems[0]}
|
|
|
|
onChange={(value) => {
|
|
|
|
this.setState({ type: value });
|
|
|
|
}}
|
|
|
|
/>
|
2020-01-13 16:12:53 +01:00
|
|
|
</div>
|
2021-09-03 17:56:43 +02:00
|
|
|
{this.renderImportView()}
|
2019-11-23 05:14:12 +01:00
|
|
|
</div>
|
2021-09-03 17:56:43 +02:00
|
|
|
</>
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2016-11-04 23:08:50 +01:00
|
|
|
}
|
|
|
|
}
|