mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 18:00:18 +01:00
ab4843f06b
* UX: Multichain: Implement Account Details Popover * Styling account details popover * using ButtonSecondary with variant, removing Text * adding account-details jest test * Close popover when outside area clicked * Move all export functionality into the popover * Improve jest tests * Implement new design for export key screens * Hide warning when popover is closed * Vertically align the copy button * Move AccountDetailsDisplay to its own file * Move authentication to its own file * Move private key to its own component * Fix misalignment of avatar on display screen * Move private key to its own component * Update ui/components/multichain/account-details/account-details-authenticate.js Co-authored-by: Nidhi Kumari <nidhi.kumari@consensys.net> * Update ui/components/multichain/account-details/account-details.test.js Co-authored-by: Nidhi Kumari <nidhi.kumari@consensys.net> * Prevent account name overflow, update text size * Use FormTextField * Add analytics * Move location of accountDetailsAddress * Ensure passsword input is used --------- Co-authored-by: Victor Thomas <10986371+vthomas13@users.noreply.github.com> Co-authored-by: Nidhi Kumari <nidhi.kumari@consensys.net>
104 lines
3.0 KiB
JavaScript
104 lines
3.0 KiB
JavaScript
import React, { useContext } from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import { useDispatch, useSelector } from 'react-redux';
|
|
|
|
import QrView from '../../ui/qr-code';
|
|
import EditableLabel from '../../ui/editable-label/editable-label';
|
|
|
|
import { setAccountLabel } from '../../../store/actions';
|
|
import {
|
|
getCurrentChainId,
|
|
getHardwareWalletType,
|
|
getMetaMaskKeyrings,
|
|
} from '../../../selectors';
|
|
import { isHardwareKeyring } from '../../../helpers/utils/hardware';
|
|
import {
|
|
BUTTON_SECONDARY_SIZES,
|
|
ButtonSecondary,
|
|
} from '../../component-library';
|
|
import {
|
|
AlignItems,
|
|
DISPLAY,
|
|
FLEX_DIRECTION,
|
|
TextVariant,
|
|
} from '../../../helpers/constants/design-system';
|
|
import { MetaMetricsContext } from '../../../contexts/metametrics';
|
|
import {
|
|
MetaMetricsEventCategory,
|
|
MetaMetricsEventKeyType,
|
|
MetaMetricsEventName,
|
|
} from '../../../../shared/constants/metametrics';
|
|
import { useI18nContext } from '../../../hooks/useI18nContext';
|
|
import Box from '../../ui/box/box';
|
|
|
|
export const AccountDetailsDisplay = ({
|
|
accounts,
|
|
accountName,
|
|
address,
|
|
onExportClick,
|
|
}) => {
|
|
const dispatch = useDispatch();
|
|
const trackEvent = useContext(MetaMetricsContext);
|
|
const t = useI18nContext();
|
|
|
|
const keyrings = useSelector(getMetaMaskKeyrings);
|
|
const keyring = keyrings.find((kr) => kr.accounts.includes(address));
|
|
const exportPrivateKeyFeatureEnabled = !isHardwareKeyring(keyring?.type);
|
|
|
|
const chainId = useSelector(getCurrentChainId);
|
|
const deviceName = useSelector(getHardwareWalletType);
|
|
|
|
return (
|
|
<Box
|
|
display={DISPLAY.FLEX}
|
|
alignItems={AlignItems.center}
|
|
flexDirection={FLEX_DIRECTION.COLUMN}
|
|
>
|
|
<EditableLabel
|
|
defaultValue={accountName}
|
|
onSubmit={(label) => {
|
|
dispatch(setAccountLabel(address, label));
|
|
trackEvent({
|
|
category: MetaMetricsEventCategory.Accounts,
|
|
event: MetaMetricsEventName.AccountRenamed,
|
|
properties: {
|
|
location: 'Account Details Modal',
|
|
chain_id: chainId,
|
|
account_hardware_type: deviceName,
|
|
},
|
|
});
|
|
}}
|
|
accounts={accounts}
|
|
/>
|
|
<QrView Qr={{ data: address }} />
|
|
{exportPrivateKeyFeatureEnabled ? (
|
|
<ButtonSecondary
|
|
block
|
|
size={BUTTON_SECONDARY_SIZES.LG}
|
|
variant={TextVariant.bodyMd}
|
|
onClick={() => {
|
|
trackEvent({
|
|
category: MetaMetricsEventCategory.Accounts,
|
|
event: MetaMetricsEventName.KeyExportSelected,
|
|
properties: {
|
|
key_type: MetaMetricsEventKeyType.Pkey,
|
|
location: 'Account Details Modal',
|
|
},
|
|
});
|
|
onExportClick();
|
|
}}
|
|
>
|
|
{t('showPrivateKey')}
|
|
</ButtonSecondary>
|
|
) : null}
|
|
</Box>
|
|
);
|
|
};
|
|
|
|
AccountDetailsDisplay.propTypes = {
|
|
accounts: PropTypes.array.isRequired,
|
|
accountName: PropTypes.string.isRequired,
|
|
address: PropTypes.string.isRequired,
|
|
onExportClick: PropTypes.func.isRequired,
|
|
};
|