Don't display on-network divider (development) (#1943)
This commit is contained in:
parent
bea8ae7346
commit
9c56dc7148
@ -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<Props> {
|
||||
const api = useApi();
|
||||
const [genesisHash, setGenesisHash] = useState<string | null>(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<Props> {
|
||||
>
|
||||
{t('Forget this account')}
|
||||
</Menu.Item>
|
||||
<Menu.Divider />
|
||||
<ChainLock
|
||||
className='accounts--network-toggle'
|
||||
genesisHash={genesisHash}
|
||||
isDisabled={!isEditable || isExternal}
|
||||
onChange={_onGenesisChange}
|
||||
preventDefault
|
||||
/>
|
||||
{!api.isDevelopment && (
|
||||
<>
|
||||
<Menu.Divider />
|
||||
<ChainLock
|
||||
className='accounts--network-toggle'
|
||||
genesisHash={genesisHash}
|
||||
isDisabled={!isEditable || isExternal}
|
||||
onChange={_onGenesisChange}
|
||||
preventDefault
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</Menu>
|
||||
</Popup>
|
||||
</div>
|
||||
|
||||
@ -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<Props> {
|
||||
const { t } = useTranslation();
|
||||
const [password, setPassword] = useState('');
|
||||
@ -25,16 +40,15 @@ export default function ({ address, onClose }: Props): React.ReactElement<Props>
|
||||
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<Props>
|
||||
}
|
||||
|
||||
onClose();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Modal
|
||||
@ -59,14 +73,14 @@ export default function ({ address, onClose }: Props): React.ReactElement<Props>
|
||||
<Modal.Header>{t('Backup account')}</Modal.Header>
|
||||
<Content
|
||||
address={address}
|
||||
doBackup={doBackup}
|
||||
doBackup={_doBackup}
|
||||
isPassTouched={isPassTouched}
|
||||
isPassValid={isPassValid}
|
||||
password={password}
|
||||
onChangePass={onChangePass}
|
||||
onChangePass={_onChangePass}
|
||||
/>
|
||||
<Buttons
|
||||
doBackup={doBackup}
|
||||
doBackup={_doBackup}
|
||||
isPassValid={isPassValid}
|
||||
onClose={onClose}
|
||||
/>
|
||||
@ -74,23 +88,7 @@ export default function ({ address, onClose }: Props): React.ReactElement<Props>
|
||||
);
|
||||
}
|
||||
|
||||
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<ContentProps> {
|
||||
function Content ({ address, doBackup, isPassTouched, isPassValid, onChangePass, password }: ContentProps): React.ReactElement<ContentProps> {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
@ -103,6 +101,7 @@ function Content ({
|
||||
<p>{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.')}</p>
|
||||
<div>
|
||||
<Password
|
||||
autoFocus
|
||||
help={t('The account password as specified when creating the account. This is used to encrypt the backup file and subsequently decrypt it when restoring the account.')}
|
||||
isError={isPassTouched && !isPassValid}
|
||||
label={t('password')}
|
||||
@ -117,17 +116,7 @@ function Content ({
|
||||
);
|
||||
}
|
||||
|
||||
interface ButtonsProps {
|
||||
doBackup: () => void;
|
||||
isPassValid: boolean;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
function Buttons ({
|
||||
doBackup,
|
||||
isPassValid,
|
||||
onClose
|
||||
}: ButtonsProps): React.ReactElement<ButtonsProps> {
|
||||
function Buttons ({ doBackup, isPassValid, onClose }: ButtonsProps): React.ReactElement<ButtonsProps> {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
|
||||
@ -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<Props> {
|
||||
const api = useApi();
|
||||
const [current, setCurrent] = useState<KeyringAddress | null>(null);
|
||||
const [genesisHash, setGenesisHash] = useState<string | null>(null);
|
||||
const [isForgetOpen, setIsForgetOpen] = useState(false);
|
||||
@ -107,14 +109,18 @@ function Address ({ address, className, t }: Props): React.ReactElement<Props> {
|
||||
>
|
||||
{t('Forget this address')}
|
||||
</Menu.Item>
|
||||
<Menu.Divider />
|
||||
<ChainLock
|
||||
className='addresses--network-toggle'
|
||||
genesisHash={genesisHash}
|
||||
isDisabled={!isEditable}
|
||||
onChange={_onGenesisChange}
|
||||
preventDefault
|
||||
/>
|
||||
{!api.isDevelopment && (
|
||||
<>
|
||||
<Menu.Divider />
|
||||
<ChainLock
|
||||
className='addresses--network-toggle'
|
||||
genesisHash={genesisHash}
|
||||
isDisabled={!isEditable}
|
||||
onChange={_onGenesisChange}
|
||||
preventDefault
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</Menu>
|
||||
</Popup>
|
||||
</div>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user