diff --git a/packages/app-accounts/src/Account.tsx b/packages/app-accounts/src/Account.tsx index 22fb9953cde3..ddf304208c46 100644 --- a/packages/app-accounts/src/Account.tsx +++ b/packages/app-accounts/src/Account.tsx @@ -8,6 +8,7 @@ import { I18nProps } from '@polkadot/react-components/types'; import React, { useState, useEffect } from 'react'; import styled from 'styled-components'; import { AddressCard, AddressInfo, Button, ChainLock, Forget, Menu, Popup } from '@polkadot/react-components'; +import { useApi } from '@polkadot/react-hooks'; import keyring from '@polkadot/ui-keyring'; import Backup from './modals/Backup'; @@ -22,6 +23,7 @@ interface Props extends I18nProps { } function Account ({ address, className, t }: Props): React.ReactElement { + const api = useApi(); const [genesisHash, setGenesisHash] = useState(null); const [isBackupOpen, setIsBackupOpen] = useState(false); const [{ isDevelopment, isEditable, isExternal }, setFlags] = useState({ isDevelopment: false, isEditable: false, isExternal: false }); @@ -135,14 +137,18 @@ function Account ({ address, className, t }: Props): React.ReactElement { > {t('Forget this account')} - - + {!api.isDevelopment && ( + <> + + + + )} diff --git a/packages/app-accounts/src/modals/Backup.tsx b/packages/app-accounts/src/modals/Backup.tsx index daecfa763293..4d424d83175a 100644 --- a/packages/app-accounts/src/modals/Backup.tsx +++ b/packages/app-accounts/src/modals/Backup.tsx @@ -16,6 +16,21 @@ interface Props extends BareProps { address: string; } +interface ButtonsProps { + doBackup: () => void; + isPassValid: boolean; + onClose: () => void; +} + +interface ContentProps { + address: string; + doBackup: () => void; + isPassTouched: boolean; + isPassValid: boolean; + onChangePass: (password: string) => void; + password: string; +} + export default function ({ address, onClose }: Props): React.ReactElement { const { t } = useTranslation(); const [password, setPassword] = useState(''); @@ -25,16 +40,15 @@ export default function ({ address, onClose }: Props): React.ReactElement keyring.isPassValid(password) && !backupFailed, [password, backupFailed]); - function onChangePass (value: string): void { + const _onChangePass = (value: string): void => { if (!isPassTouched) { setIsPassTouched(true); } - setBackupFailed(false); + setBackupFailed(false); setPassword(value); - } - - function doBackup (): void { + }; + const _doBackup = (): void => { try { const addressKeyring = address && keyring.getPair(address); const json = addressKeyring && keyring.backupAccount(addressKeyring, password); @@ -48,7 +62,7 @@ export default function ({ address, onClose }: Props): React.ReactElement } onClose(); - } + }; return ( {t('Backup account')} @@ -74,23 +88,7 @@ export default function ({ address, onClose }: Props): React.ReactElement ); } -interface ContentProps { - address: string; - doBackup: () => void; - isPassTouched: boolean; - isPassValid: boolean; - password: string; - onChangePass: (password: string) => void; -} - -function Content ({ - address, - doBackup, - isPassTouched, - isPassValid, - password, - onChangePass -}: ContentProps): React.ReactElement { +function Content ({ address, doBackup, isPassTouched, isPassValid, onChangePass, password }: ContentProps): React.ReactElement { const { t } = useTranslation(); return ( @@ -103,6 +101,7 @@ function Content ({

{t('Save this backup file in a secure location. Additionally, the password associated with this account is needed together with this backup file in order to restore your account.')}

void; - isPassValid: boolean; - onClose: () => void; -} - -function Buttons ({ - doBackup, - isPassValid, - onClose -}: ButtonsProps): React.ReactElement { +function Buttons ({ doBackup, isPassValid, onClose }: ButtonsProps): React.ReactElement { const { t } = useTranslation(); return ( diff --git a/packages/app-address-book/src/Address.tsx b/packages/app-address-book/src/Address.tsx index 0cc9bb973da6..9b8305d66a67 100644 --- a/packages/app-address-book/src/Address.tsx +++ b/packages/app-address-book/src/Address.tsx @@ -9,6 +9,7 @@ import { I18nProps } from '@polkadot/react-components/types'; import React, { useEffect, useState } from 'react'; import styled from 'styled-components'; import { AddressCard, AddressInfo, Button, ChainLock, Forget, Menu, Popup } from '@polkadot/react-components'; +import { useApi } from '@polkadot/react-hooks'; import keyring from '@polkadot/ui-keyring'; import Transfer from '@polkadot/app-accounts/modals/Transfer'; @@ -26,6 +27,7 @@ const WITH_EXTENDED = { nonce: true }; const isEditable = true; function Address ({ address, className, t }: Props): React.ReactElement { + const api = useApi(); const [current, setCurrent] = useState(null); const [genesisHash, setGenesisHash] = useState(null); const [isForgetOpen, setIsForgetOpen] = useState(false); @@ -107,14 +109,18 @@ function Address ({ address, className, t }: Props): React.ReactElement { > {t('Forget this address')} - - + {!api.isDevelopment && ( + <> + + + + )}