From f55b0ddc0575483b093ea4bc50d95960311a1e65 Mon Sep 17 00:00:00 2001 From: Jaco Date: Wed, 28 Dec 2022 12:47:12 +0200 Subject: [PATCH] Adjust list + badges with overlay (#8643) * Adjust list + badges with overlay * Adjust --- .../page-accounts/src/Accounts/Account.tsx | 2 +- .../page-accounts/src/Accounts/useProxies.ts | 16 ++-- .../page-accounts/src/modals/ProxiedAdd.tsx | 8 +- .../page-council/src/Overview/Candidate.tsx | 5 +- .../page-council/src/Overview/Candidates.tsx | 4 +- .../page-council/src/Overview/Members.tsx | 2 +- packages/page-society/src/Overview/Member.tsx | 90 +++++++++---------- .../page-society/src/Overview/Members.tsx | 2 +- packages/react-components/src/Table/index.tsx | 4 +- 9 files changed, 63 insertions(+), 70 deletions(-) diff --git a/packages/page-accounts/src/Accounts/Account.tsx b/packages/page-accounts/src/Accounts/Account.tsx index 6bea6bdedc..b41c59c8e2 100644 --- a/packages/page-accounts/src/Accounts/Account.tsx +++ b/packages/page-accounts/src/Accounts/Account.tsx @@ -644,7 +644,7 @@ function Account ({ account: { address, meta }, className = '', delegation, filt icon='redo' /> )} - {isProxied && !proxyInfo.hasOwned && ( + {isProxied && proxyInfo?.isEmpty && ( ('Proxied account has no owned proxies')} diff --git a/packages/page-accounts/src/Accounts/useProxies.ts b/packages/page-accounts/src/Accounts/useProxies.ts index d5cc3e7b5f..abf75a6038 100644 --- a/packages/page-accounts/src/Accounts/useProxies.ts +++ b/packages/page-accounts/src/Accounts/useProxies.ts @@ -20,17 +20,11 @@ interface Proxy { } interface State { - hasOwned: boolean; + isEmpty: boolean; owned: Proxy[]; proxies: Proxy[]; } -const EMPTY_STATE: State = { - hasOwned: false, - owned: [], - proxies: [] -}; - function createProxy (allAccounts: string[], delegate: AccountId, type: KitchensinkRuntimeProxyType, delay = BN_ZERO): Proxy { const address = delegate.toString(); @@ -42,14 +36,14 @@ function createProxy (allAccounts: string[], delegate: AccountId, type: Kitchens }; } -function useProxiesImpl (address?: string | null): State { +function useProxiesImpl (address?: string | null): State | null { const { api } = useApi(); const { allAccounts } = useAccounts(); const mountedRef = useIsMountedRef(); - const [known, setState] = useState(EMPTY_STATE); + const [known, setState] = useState(null); useEffect((): void => { - setState(EMPTY_STATE); + setState(null); address && api.query.proxy && api.query.proxy @@ -65,7 +59,7 @@ function useProxiesImpl (address?: string | null): State { const owned = proxies.filter(({ isOwned }) => isOwned); mountedRef.current && setState({ - hasOwned: owned.length !== 0, + isEmpty: owned.length === 0, owned, proxies }); diff --git a/packages/page-accounts/src/modals/ProxiedAdd.tsx b/packages/page-accounts/src/modals/ProxiedAdd.tsx index 547bec34ef..80022df5d3 100644 --- a/packages/page-accounts/src/modals/ProxiedAdd.tsx +++ b/packages/page-accounts/src/modals/ProxiedAdd.tsx @@ -48,7 +48,7 @@ function ProxyAdd ({ className = '', onClose, onStatusChange }: Props): React.Re const { t } = useTranslation(); const [{ isNameValid, name }, setName] = useState({ isNameValid: false, name: '' }); const [stashAddress, setStashAddress] = useState(null); - const { hasOwned } = useProxies(stashAddress); + const proxyInfo = useProxies(stashAddress); const _createProxied = useCallback( (): void => { @@ -68,7 +68,7 @@ function ProxyAdd ({ className = '', onClose, onStatusChange }: Props): React.Re [] ); - const isValid = isNameValid && !!stashAddress && hasOwned; + const isValid = isNameValid && !!stashAddress && proxyInfo && !proxyInfo.isEmpty; return ( ('The address that you have a valid proxy setup for.')} - isError={!hasOwned} + isError={!proxyInfo || proxyInfo.isEmpty} label={t('proxied account')} onChange={setStashAddress} - placeholder={t('stash address')} + placeholder={t('address being proxied')} /> ('The name is for unique identification of the account in your owner lists.')}> diff --git a/packages/page-council/src/Overview/Candidate.tsx b/packages/page-council/src/Overview/Candidate.tsx index d156a42e63..0288a8f51c 100644 --- a/packages/page-council/src/Overview/Candidate.tsx +++ b/packages/page-council/src/Overview/Candidate.tsx @@ -23,12 +23,11 @@ function Candidate ({ address, balance, className = '', isPrime, voters }: Props return ( - + - - {isPrime && ( ('Current prime member, default voting')} label={t('prime voter')} diff --git a/packages/page-council/src/Overview/Candidates.tsx b/packages/page-council/src/Overview/Candidates.tsx index ca5b9978f7..3a8676a05d 100644 --- a/packages/page-council/src/Overview/Candidates.tsx +++ b/packages/page-council/src/Overview/Candidates.tsx @@ -21,13 +21,13 @@ function Candidates ({ allVotes = {}, electionsInfo }: Props): React.ReactElemen const { t } = useTranslation(); const headerCandidatesRef = useRef([ - [t('candidates'), 'start', 2], + [t('candidates'), 'start'], [], [] ]); const headerRunnersRef = useRef([ - [t('runners up'), 'start', 2], + [t('runners up'), 'start'], [t('backing'), 'expand'], [t('votes')] ]); diff --git a/packages/page-council/src/Overview/Members.tsx b/packages/page-council/src/Overview/Members.tsx index 1e9ca7400d..5c2d0f4e90 100644 --- a/packages/page-council/src/Overview/Members.tsx +++ b/packages/page-council/src/Overview/Members.tsx @@ -23,7 +23,7 @@ function Members ({ allVotes = {}, className = '', electionsInfo, hasElections, const { t } = useTranslation(); const headerRef = useRef([ - [t('members'), 'start', 2], + [t('members'), 'start'], [hasElections ? t('backing') : undefined, 'expand'], [hasElections ? t('votes') : undefined] ]); diff --git a/packages/page-society/src/Overview/Member.tsx b/packages/page-society/src/Overview/Member.tsx index 45c3691883..4bff8a8139 100644 --- a/packages/page-society/src/Overview/Member.tsx +++ b/packages/page-society/src/Overview/Member.tsx @@ -75,52 +75,52 @@ function Member ({ bestNumber, className = '', value: { accountId, isCandidateVo return ( - + - - - {isHead && ( - ('society head')} - /> - )} - {isFounder && ( - ('founder')} - /> - )} - {isSkeptic && ( - ('skeptic')} - /> - )} - {(isCandidateVoter || isDefenderVoter) && ( - ('voted')} - /> - )} - {isWarned && ( - ('strikes')} - /> - )} - {isSuspended && ( - ('suspended')} - /> - )} - {availablePayout && ( - ('payout')} - /> - )} +
+ {(isCandidateVoter || isDefenderVoter) && ( + ('voted')} + /> + )} + {isWarned && ( + ('strikes')} + /> + )} + {isHead && ( + ('society head')} + /> + )} + {isFounder && ( + ('founder')} + /> + )} + {isSkeptic && ( + ('skeptic')} + /> + )} + {isSuspended && ( + ('suspended')} + /> + )} + {availablePayout && ( + ('payout')} + /> + )} +
{!!payouts?.length && ( diff --git a/packages/page-society/src/Overview/Members.tsx b/packages/page-society/src/Overview/Members.tsx index 9b54651f7a..6eb59860d8 100644 --- a/packages/page-society/src/Overview/Members.tsx +++ b/packages/page-society/src/Overview/Members.tsx @@ -21,7 +21,7 @@ function Members ({ className = '', mapMembers }: Props): React.ReactElement