mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-23 02:10:12 +01:00
28137798b6
* UX: Multichain: Move Add Account and Import Account into Account Menu Popover * Create a new CreateAccount component for the Account Menu * Add actions for import form * Use separate actions for cancel vs. submit * Fix jest tests * Remove commented route navigation * Accommodate for failing import * Fix tests * Remove routes for new account and import * Remove old create account page * Move import-account files to multichain directory * Fix paths on the import files * Remove deprecated component library variables * Fix error property of add form * Fix user-actions-benchmark
63 lines
1.5 KiB
JavaScript
63 lines
1.5 KiB
JavaScript
import PropTypes from 'prop-types';
|
|
import React, { useState } from 'react';
|
|
import { useSelector } from 'react-redux';
|
|
import {
|
|
FormTextField,
|
|
TEXT_FIELD_SIZES,
|
|
TEXT_FIELD_TYPES,
|
|
} from '../../component-library';
|
|
import { useI18nContext } from '../../../hooks/useI18nContext';
|
|
import BottomButtons from './bottom-buttons';
|
|
|
|
PrivateKeyImportView.propTypes = {
|
|
importAccountFunc: PropTypes.func.isRequired,
|
|
onActionComplete: PropTypes.func.isRequired,
|
|
};
|
|
|
|
export default function PrivateKeyImportView({
|
|
importAccountFunc,
|
|
onActionComplete,
|
|
}) {
|
|
const t = useI18nContext();
|
|
const [privateKey, setPrivateKey] = useState('');
|
|
|
|
const warning = useSelector((state) => state.appState.warning);
|
|
|
|
function handleKeyPress(event) {
|
|
if (privateKey !== '' && event.key === 'Enter') {
|
|
event.preventDefault();
|
|
_importAccountFunc();
|
|
}
|
|
}
|
|
|
|
function _importAccountFunc() {
|
|
importAccountFunc('Private Key', [privateKey]);
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<FormTextField
|
|
id="private-key-box"
|
|
size={TEXT_FIELD_SIZES.LARGE}
|
|
autoFocus
|
|
type={TEXT_FIELD_TYPES.PASSWORD}
|
|
helpText={warning}
|
|
error
|
|
label={t('pastePrivateKey')}
|
|
value={privateKey}
|
|
onChange={(event) => setPrivateKey(event.target.value)}
|
|
inputProps={{
|
|
onKeyPress: handleKeyPress,
|
|
}}
|
|
marginBottom={4}
|
|
/>
|
|
|
|
<BottomButtons
|
|
importAccountFunc={_importAccountFunc}
|
|
isPrimaryDisabled={privateKey === ''}
|
|
onActionComplete={onActionComplete}
|
|
/>
|
|
</>
|
|
);
|
|
}
|