(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}