1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-05 07:24:56 +01:00
metamask-extension/ui/pages/create-account/import-account/index.js

77 lines
2.1 KiB
JavaScript
Raw Normal View History

import React, { Component } from 'react';
import PropTypes from 'prop-types';
import Dropdown from '../../../components/ui/dropdown';
2016-11-04 23:08:50 +01:00
// Subviews
import JsonImportView from './json';
import PrivateKeyImportView from './private-key';
export default class AccountImportSubview extends Component {
static contextTypes = {
t: PropTypes.func,
};
2016-11-04 23:08:50 +01:00
state = {};
2020-11-03 00:41:28 +01:00
getMenuItemTexts() {
return [this.context.t('privateKey'), this.context.t('jsonFile')];
}
2020-11-03 00:41:28 +01:00
renderImportView() {
const { type } = this.state;
const menuItems = this.getMenuItemTexts();
const current = type || menuItems[0];
switch (current) {
case this.context.t('privateKey'):
return <PrivateKeyImportView />;
case this.context.t('jsonFile'):
return <JsonImportView />;
default:
return <JsonImportView />;
}
}
2020-11-03 00:41:28 +01:00
render() {
const menuItems = this.getMenuItemTexts();
const { type } = this.state;
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={() => {
global.platform.openTab({
2020-11-03 00:41:28 +01:00
url:
'https://metamask.zendesk.com/hc/en-us/articles/360015289932',
});
}}
>
{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>
<Dropdown
className="new-account-import-form__select"
options={menuItems.map((text) => ({ value: text }))}
selectedOption={type || menuItems[0]}
onChange={(value) => {
this.setState({ type: value });
}}
/>
</div>
{this.renderImportView()}
</div>
);
2016-11-04 23:08:50 +01:00
}
}