Show a specific icon on external account (#484)
* icon to show external account * revert renaming * lint * use find instead of some * before the name * Update packages/extension-ui/src/Popup/Forget.tsx * Update packages/extension-ui/src/components/Address.tsx
This commit is contained in:
parent
8fa54c9a3a
commit
a11244adf4
@ -123,6 +123,7 @@ function Account ({ address, className, genesisHash, isExternal, isHidden, paren
|
|||||||
address={address}
|
address={address}
|
||||||
className='address'
|
className='address'
|
||||||
genesisHash={genesisHash}
|
genesisHash={genesisHash}
|
||||||
|
isExternal={isExternal}
|
||||||
isHidden={isHidden}
|
isHidden={isHidden}
|
||||||
name={editedName}
|
name={editedName}
|
||||||
parentName={parentName}
|
parentName={parentName}
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import React, { useCallback, useContext } from 'react';
|
|||||||
import { RouteComponentProps, withRouter } from 'react-router';
|
import { RouteComponentProps, withRouter } from 'react-router';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
|
||||||
import { ActionContext, Address, Button, Warning, ActionBar, ActionText } from '../components';
|
import { ActionContext, Address, ActionBar, ActionText, Button, Warning } from '../components';
|
||||||
import useTranslation from '../hooks/useTranslation';
|
import useTranslation from '../hooks/useTranslation';
|
||||||
import { forgetAccount } from '../messaging';
|
import { forgetAccount } from '../messaging';
|
||||||
import { Header } from '../partials';
|
import { Header } from '../partials';
|
||||||
|
|||||||
@ -40,6 +40,7 @@ export default function ImportQr (): React.ReactElement {
|
|||||||
<div>
|
<div>
|
||||||
<Address
|
<Address
|
||||||
{...account}
|
{...account}
|
||||||
|
isExternal={true}
|
||||||
name={name}
|
name={name}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -152,6 +152,7 @@ export default function Request ({ account: { isExternal }, buttonText, isFirst,
|
|||||||
<Address
|
<Address
|
||||||
address={json.address}
|
address={json.address}
|
||||||
genesisHash={json.genesisHash}
|
genesisHash={json.genesisHash}
|
||||||
|
isExternal={isExternal}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{isExternal
|
{isExternal
|
||||||
@ -189,7 +190,10 @@ export default function Request ({ account: { isExternal }, buttonText, isFirst,
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div>
|
<div>
|
||||||
<Address address={raw.address} />
|
<Address
|
||||||
|
address={raw.address}
|
||||||
|
isExternal={isExternal}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<Bytes
|
<Bytes
|
||||||
bytes={raw.data}
|
bytes={raw.data}
|
||||||
|
|||||||
62
packages/extension-ui/src/assets/arrowTopRight.svg
Normal file
62
packages/extension-ui/src/assets/arrowTopRight.svg
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
width="14"
|
||||||
|
height="14"
|
||||||
|
viewBox="0 0 14 14"
|
||||||
|
fill="none"
|
||||||
|
version="1.1"
|
||||||
|
id="svg6"
|
||||||
|
sodipodi:docname="arrowTopRight.svg"
|
||||||
|
inkscape:version="0.92.3 (2405546, 2018-03-11)">
|
||||||
|
<metadata
|
||||||
|
id="metadata12">
|
||||||
|
<rdf:RDF>
|
||||||
|
<cc:Work
|
||||||
|
rdf:about="">
|
||||||
|
<dc:format>image/svg+xml</dc:format>
|
||||||
|
<dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
|
<dc:title></dc:title>
|
||||||
|
</cc:Work>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
<defs
|
||||||
|
id="defs10" />
|
||||||
|
<sodipodi:namedview
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="1"
|
||||||
|
objecttolerance="10"
|
||||||
|
gridtolerance="10"
|
||||||
|
guidetolerance="10"
|
||||||
|
inkscape:pageopacity="0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:window-width="1137"
|
||||||
|
inkscape:window-height="772"
|
||||||
|
id="namedview8"
|
||||||
|
showgrid="false"
|
||||||
|
inkscape:zoom="22.627417"
|
||||||
|
inkscape:cx="12.76945"
|
||||||
|
inkscape:cy="8.9508825"
|
||||||
|
inkscape:window-x="393"
|
||||||
|
inkscape:window-y="259"
|
||||||
|
inkscape:window-maximized="0"
|
||||||
|
inkscape:current-layer="svg6" />
|
||||||
|
<path
|
||||||
|
d="M 12.654628,1.3598586 1.3442182,12.66615"
|
||||||
|
id="path2"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="stroke:#6c6c6c;stroke-width:2.67733049;stroke-linecap:round;stroke-linejoin:round" />
|
||||||
|
<path
|
||||||
|
d="M 1.2846487,1.363854 12.651896,1.3419767 12.673836,12.673441"
|
||||||
|
id="path4"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="stroke:#6c6c6c;stroke-width:2.67507029;stroke-linecap:round;stroke-linejoin:round" />
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 1.9 KiB |
@ -12,6 +12,7 @@ import styled from 'styled-components';
|
|||||||
import { decodeAddress, encodeAddress } from '@polkadot/util-crypto';
|
import { decodeAddress, encodeAddress } from '@polkadot/util-crypto';
|
||||||
|
|
||||||
import copyIcon from '../assets/copy.svg';
|
import copyIcon from '../assets/copy.svg';
|
||||||
|
import externalIcon from '../assets/arrowTopRight.svg';
|
||||||
import hiddenIcon from '../assets/hidden.svg';
|
import hiddenIcon from '../assets/hidden.svg';
|
||||||
import details from '../assets/details.svg';
|
import details from '../assets/details.svg';
|
||||||
import parentArrow from '../assets/arrowParentLabel.svg';
|
import parentArrow from '../assets/arrowParentLabel.svg';
|
||||||
@ -30,6 +31,7 @@ interface Props {
|
|||||||
children?: React.ReactNode;
|
children?: React.ReactNode;
|
||||||
className?: string;
|
className?: string;
|
||||||
genesisHash?: string | null;
|
genesisHash?: string | null;
|
||||||
|
isExternal?: boolean | null;
|
||||||
isHidden?: boolean;
|
isHidden?: boolean;
|
||||||
name?: React.ReactNode | null;
|
name?: React.ReactNode | null;
|
||||||
parentName?: string | null;
|
parentName?: string | null;
|
||||||
@ -71,7 +73,7 @@ function recodeAddress (address: string, accounts: AccountWithChildren[], chain:
|
|||||||
|
|
||||||
const ACCOUNTS_SCREEN_HEIGHT = 550;
|
const ACCOUNTS_SCREEN_HEIGHT = 550;
|
||||||
|
|
||||||
function Address ({ actions, address, children, className, genesisHash, isHidden, name, parentName, suri, toggleActions }: Props): React.ReactElement<Props> {
|
function Address ({ actions, address, children, className, genesisHash, isExternal, isHidden, name, parentName, suri, toggleActions }: Props): React.ReactElement<Props> {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { accounts } = useContext(AccountContext);
|
const { accounts } = useContext(AccountContext);
|
||||||
const settings = useContext(SettingsContext);
|
const settings = useContext(SettingsContext);
|
||||||
@ -110,7 +112,18 @@ function Address ({ actions, address, children, className, genesisHash, isHidden
|
|||||||
const _onClick = useCallback((): void => setShowActionsMenu(!showActionsMenu), [showActionsMenu]);
|
const _onClick = useCallback((): void => setShowActionsMenu(!showActionsMenu), [showActionsMenu]);
|
||||||
const _onCopy = useCallback((): void => show(t('Copied')), [show, t]);
|
const _onCopy = useCallback((): void => show(t('Copied')), [show, t]);
|
||||||
|
|
||||||
const displayedName = name || (account && account.name) || t('<unknown>');
|
const displayedName = (
|
||||||
|
<>
|
||||||
|
{(account?.isExternal || isExternal) && (
|
||||||
|
<Svg
|
||||||
|
className='externalIcon'
|
||||||
|
src={externalIcon}
|
||||||
|
title={t('external account')}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{name || account?.name || t('<unknown>')}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={className}>
|
<div className={className}>
|
||||||
@ -118,6 +131,7 @@ function Address ({ actions, address, children, className, genesisHash, isHidden
|
|||||||
<Identicon
|
<Identicon
|
||||||
className='identityIcon'
|
className='identityIcon'
|
||||||
iconTheme={theme}
|
iconTheme={theme}
|
||||||
|
isExternal={isExternal}
|
||||||
onCopy={_onCopy}
|
onCopy={_onCopy}
|
||||||
prefix={prefix}
|
prefix={prefix}
|
||||||
value={formatted || address}
|
value={formatted || address}
|
||||||
@ -310,6 +324,13 @@ export default styled(Address)(({ theme }: ThemeProps) => `
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.externalIcon {
|
||||||
|
height: 10px;
|
||||||
|
width: 10px;
|
||||||
|
margin-right: 0.5rem;
|
||||||
|
background: ${theme.labelColor}
|
||||||
|
}
|
||||||
|
|
||||||
.identityIcon {
|
.identityIcon {
|
||||||
margin-left: 15px;
|
margin-left: 15px;
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
|
|||||||
@ -8,11 +8,12 @@ import styled from 'styled-components';
|
|||||||
import Icon from '@polkadot/react-identicon';
|
import Icon from '@polkadot/react-identicon';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
iconTheme?: 'beachball' | 'empty' | 'jdenticon' | 'polkadot' | 'substrate';
|
|
||||||
className?: string;
|
className?: string;
|
||||||
|
iconTheme?: 'beachball' | 'empty' | 'jdenticon' | 'polkadot' | 'substrate';
|
||||||
|
isExternal?: boolean | null;
|
||||||
|
onCopy?: () => void;
|
||||||
prefix?: number;
|
prefix?: number;
|
||||||
value?: string | null;
|
value?: string | null;
|
||||||
onCopy?: () => void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function Identicon ({ className, iconTheme, onCopy, prefix, value }: Props): React.ReactElement<Props> {
|
function Identicon ({ className, iconTheme, onCopy, prefix, value }: Props): React.ReactElement<Props> {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user