diff --git a/packages/page-accounts/src/Accounts/Account.tsx b/packages/page-accounts/src/Accounts/Account.tsx index 510cbcb4bc..a0520fe9af 100644 --- a/packages/page-accounts/src/Accounts/Account.tsx +++ b/packages/page-accounts/src/Accounts/Account.tsx @@ -234,7 +234,7 @@ function Account ({ account: { address, meta }, className = '', filter, isFavori } - info={} + icon='shield' isInline isTooltip /> diff --git a/packages/page-democracy/src/Overview/Referendum.tsx b/packages/page-democracy/src/Overview/Referendum.tsx index e0c8248b2b..b4d0f5399d 100644 --- a/packages/page-democracy/src/Overview/Referendum.tsx +++ b/packages/page-democracy/src/Overview/Referendum.tsx @@ -128,7 +128,7 @@ function Referendum ({ className = '', value: { allAye, allNay, image, imageHash ? t('{{threshold}}, passing', { replace: { threshold } }) : t('{{threshold}}, not passing', { replace: { threshold } }) } - info={} + icon={isPassing ? 'check' : 'times'} isInline isTooltip /> diff --git a/packages/page-staking/src/Overview/Address/Status.tsx b/packages/page-staking/src/Overview/Address/Status.tsx index 41bafad4f2..277f8759b9 100644 --- a/packages/page-staking/src/Overview/Address/Status.tsx +++ b/packages/page-staking/src/Overview/Address/Status.tsx @@ -21,7 +21,7 @@ function Status ({ isElected, numNominators, onlineCount, onlineMessage }: Props ? ( } + icon='chevron-right' isInline /> ) diff --git a/packages/page-staking/src/Targets/Validator.tsx b/packages/page-staking/src/Targets/Validator.tsx index 7d79738cb2..75c859765e 100644 --- a/packages/page-staking/src/Targets/Validator.tsx +++ b/packages/page-staking/src/Targets/Validator.tsx @@ -21,6 +21,7 @@ interface Props { canSelect: boolean; filterName: string; info: ValidatorInfo; + isNominated: boolean; isSelected: boolean; toggleFavorite: (accountId: string) => void; toggleSelected: (accountId: string) => void; @@ -48,7 +49,7 @@ function checkIdentity (api: ApiPromise, accountInfo: DeriveAccountInfo): boolea return hasIdentity; } -function Validator ({ canSelect, filterName, info, isSelected, toggleFavorite, toggleSelected, withElected, withIdentity }: Props): React.ReactElement | null { +function Validator ({ canSelect, filterName, info, isNominated, isSelected, toggleFavorite, toggleSelected, withElected, withIdentity }: Props): React.ReactElement | null { const { api } = useApi(); const accountInfo = useCall(api.derive.accounts.info, [info.accountId]); const [isVisible, setVisibility] = useState(true); @@ -86,13 +87,36 @@ function Validator ({ canSelect, filterName, info, isSelected, toggleFavorite, t toggleFavorite={toggleFavorite} /> - {isElected && ( - } - isInline - /> - )} + {isNominated + ? ( + + ) + : ( + + ) + } + {isElected + ? ( + + ) + : ( + + ) + } {formatNumber(rankOverall)} diff --git a/packages/page-staking/src/Targets/index.tsx b/packages/page-staking/src/Targets/index.tsx index 8b817bfe8b..dd1f355179 100644 --- a/packages/page-staking/src/Targets/index.tsx +++ b/packages/page-staking/src/Targets/index.tsx @@ -53,6 +53,7 @@ function Targets ({ className = '', isInElection, ownStashes, targets: { calcWit const ownNominators = useOwnNominators(ownStashes); const [selected, setSelected] = useState([]); const [sorted, setSorted] = useState(); + const [myNominees, setMyNominees] = useState([]); const [nameFilter, setNameFilter] = useState(''); const [withElected, setWithElected] = useState(false); const [withIdentity, setWithIdentity] = useState(false); @@ -64,6 +65,17 @@ function Targets ({ className = '', isInElection, ownStashes, targets: { calcWit ); }, [sortBy, sortFromMax, validators]); + useEffect((): void => { + ownNominators && setMyNominees( + ownNominators.reduce((myNominees: string[], nominator): string[] => + (nominator.nominating || []).reduce((myNominees: string[], nominee): string[] => { + !myNominees.includes(nominee) && myNominees.push(nominee); + + return myNominees; + }, myNominees), []) + ); + }, [ownNominators]); + const _sort = useCallback( (newSortBy: TargetSortBy) => setSortBy(({ sortBy, sortFromMax }) => ({ sortBy: newSortBy, @@ -188,6 +200,7 @@ function Targets ({ className = '', isInElection, ownStashes, targets: { calcWit canSelect={selected.length < MAX_NOMINATIONS} filterName={nameFilter} info={validators[index]} + isNominated={myNominees.includes(validators[index].key)} isSelected={selected.includes(validators[index].key)} key={validators[index].key} toggleFavorite={toggleFavorite} diff --git a/packages/react-components/src/AccountName.tsx b/packages/react-components/src/AccountName.tsx index c26cc6e22c..e89ebb23c3 100644 --- a/packages/react-components/src/AccountName.tsx +++ b/packages/react-components/src/AccountName.tsx @@ -2,6 +2,7 @@ // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. +import { IconName } from '@fortawesome/fontawesome-svg-core'; import { DeriveAccountInfo, DeriveAccountRegistration } from '@polkadot/api-derive/types'; import { AccountId, AccountIndex, Address } from '@polkadot/types/interfaces'; @@ -14,7 +15,6 @@ import { isFunction, stringToU8a } from '@polkadot/util'; import { getAddressName } from './util'; import Badge from './Badge'; -import Icon from './Icon'; interface Props { children?: React.ReactNode; @@ -77,7 +77,7 @@ function extractName (address: string, accountIndex?: AccountIndex, defaultName? {isSpecial && ( } + icon='archway' isInline isSmall /> @@ -91,12 +91,12 @@ function extractName (address: string, accountIndex?: AccountIndex, defaultName? ); } -function createIdElem (color: 'green' | 'red' | 'gray', nameElem: React.ReactNode, infoElem: React.ReactNode): React.ReactNode { +function createIdElem (nameElem: React.ReactNode, color: 'green' | 'red' | 'gray', icon: IconName): React.ReactNode { return (
- {displayParent - ? <>{displayParent}/{displayName} - : displayName - } - + const displayParent = identity.displayParent && ( + isGood + ? identity.displayParent + : identity.displayParent.replace(/[^\x20-\x7E]/g, '') + ); + const elem = createIdElem( + ( + + {displayParent + ? <>{displayParent}/{displayName} + : displayName + } + + ), + isGood ? 'green' : (isBad ? 'red' : 'gray'), + identity.parent ? 'link' : (isGood ? 'check' : 'minus') ); - const infoElem = ; - const color = isGood ? 'green' : (isBad ? 'red' : 'gray'); - displayCache.set(address, createIdElem(color, nameElem, infoElem)); + displayCache.set(address, elem); - return createIdElem(color, nameElem, infoElem); + return elem; } function AccountName ({ children, className = '', defaultName, label, noLookup, onClick, override, toggle, value, withSidebar }: Props): React.ReactElement { diff --git a/packages/react-components/src/Badge.tsx b/packages/react-components/src/Badge.tsx index c48602819b..fb0ce45adb 100644 --- a/packages/react-components/src/Badge.tsx +++ b/packages/react-components/src/Badge.tsx @@ -2,15 +2,19 @@ // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. +import { IconName } from '@fortawesome/fontawesome-svg-core'; + import React, { useState } from 'react'; import styled from 'styled-components'; +import Icon from './Icon'; import Tooltip from './Tooltip'; interface Props { className?: string; color: 'counter' | 'green' | 'blue' | 'gray' | 'normal' | 'purple' | 'red' | 'transparent'; hover?: React.ReactNode; + icon?: IconName; info?: React.ReactNode; isInline?: boolean; isSmall?: boolean; @@ -20,7 +24,7 @@ interface Props { let badgeId = 0; -function Badge ({ className = '', color = 'normal', hover, info, isInline, isSmall, isTooltip, onClick }: Props): React.ReactElement | null { +function Badge ({ className = '', color = 'normal', hover, icon, info, isInline, isSmall, isTooltip, onClick }: Props): React.ReactElement | null { const [trigger] = useState(`badge-hover-${Date.now()}-${badgeId++}`); const extraProps = isTooltip && hover ? { 'data-for': trigger, 'data-tip': true } @@ -33,7 +37,7 @@ function Badge ({ className = '', color = 'normal', hover, info, isInline, isSma onClick={onClick} >
- {info} + {info || (icon && )}
{hover}