From c004f07c53bb485d6925c15a12939b6a496a1b65 Mon Sep 17 00:00:00 2001 From: Antoine Estienne Date: Mon, 16 Nov 2020 15:19:08 +0100 Subject: [PATCH] Feature/better eth address addition (#4032) * update labels for eth private key * updated copy button * lint * Apply suggestions from code review Co-authored-by: Jaco Greeff * typo Co-authored-by: Jaco Greeff --- packages/page-accounts/src/modals/Create.tsx | 16 ++++++++++------ packages/react-components/src/CopyButton.tsx | 12 ++++++------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/packages/page-accounts/src/modals/Create.tsx b/packages/page-accounts/src/modals/Create.tsx index dad227b03f..6eeba77904 100644 --- a/packages/page-accounts/src/modals/Create.tsx +++ b/packages/page-accounts/src/modals/Create.tsx @@ -204,8 +204,8 @@ function Create ({ className = '', onClose, onStatusChange, seed: propsSeed, typ : [] ).concat( { text: t('Mnemonic'), value: 'bip' }, - { text: t('Raw seed'), value: 'raw' } - ), [isDevelopment, t]); + isEthereum ? { text: t('Private Key'), value: 'raw' } : { text: t('Raw seed'), value: 'raw' } + ), [isEthereum, isDevelopment, t]); const _onChangeDerive = useCallback( (newDerivePath: string) => setAddress(updateAddress(seed, newDerivePath, seedType, pairType)), @@ -295,7 +295,9 @@ function Create ({ className = '', onClose, onStatusChange, seed: propsSeed, typ diff --git a/packages/react-components/src/CopyButton.tsx b/packages/react-components/src/CopyButton.tsx index dc475d4534..d05adff022 100644 --- a/packages/react-components/src/CopyButton.tsx +++ b/packages/react-components/src/CopyButton.tsx @@ -15,27 +15,27 @@ interface Props { children?: React.ReactNode; className?: string; icon?: IconName; - isAddress?: boolean; + type?: string; isMnemonic?: boolean; value: string; } const NOOP = () => undefined; -function CopyButton ({ children, className, icon = 'copy', isAddress = false, isMnemonic = false, value }: Props): React.ReactElement { +function CopyButton ({ children, className, icon = 'copy', type, value }: Props): React.ReactElement { const { t } = useTranslation(); const { queueAction } = useContext(StatusContext); const _onCopy = useCallback( (): void => { - (isAddress || isMnemonic) && queueAction && queueAction({ - account: isAddress ? value : undefined, + (type !== 'other') && queueAction && queueAction({ + account: type !== 'mnemonic' ? value : undefined, action: t('clipboard'), - message: t(`${isAddress ? 'address' : 'mnemonic'} copied`), + message: t('{{type}} copied', { replace: { type: type || t('other') } }), status: 'queued' }); }, - [isAddress, isMnemonic, queueAction, t, value] + [type, queueAction, t, value] ); return (