From 9c56dc7148478a73b9531d38743684da93e55168 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Mon, 25 Nov 2019 13:53:35 +0100 Subject: [PATCH] Don't display on-network divider (development) (#1943) --- packages/app-accounts/src/Account.tsx | 22 ++++--- packages/app-accounts/src/modals/Backup.tsx | 63 +++++++++------------ packages/app-address-book/src/Address.tsx | 22 ++++--- 3 files changed, 54 insertions(+), 53 deletions(-) diff --git a/packages/app-accounts/src/Account.tsx b/packages/app-accounts/src/Account.tsx index 22fb9953cd..ddf304208c 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 daecfa7632..4d424d8317 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); - 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 0cc9bb973d..9b8305d66a 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 && ( + <> + + + + )}