Adjust list + badges with overlay (#8643)

* Adjust list + badges with overlay

* Adjust
This commit is contained in:
Jaco 2022-12-28 12:47:12 +02:00 committed by GitHub
parent 88db504e83
commit f55b0ddc05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 63 additions and 70 deletions

View File

@ -644,7 +644,7 @@ function Account ({ account: { address, meta }, className = '', delegation, filt
icon='redo'
/>
)}
{isProxied && !proxyInfo.hasOwned && (
{isProxied && proxyInfo?.isEmpty && (
<Badge
className='important'
hover={t<string>('Proxied account has no owned proxies')}

View File

@ -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<State>(EMPTY_STATE);
const [known, setState] = useState<State | null>(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
});

View File

@ -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<string | null>(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 (
<Modal
@ -82,10 +82,10 @@ function ProxyAdd ({ className = '', onClose, onStatusChange }: Props): React.Re
<InputAddressSimple
autoFocus
help={t<string>('The address that you have a valid proxy setup for.')}
isError={!hasOwned}
isError={!proxyInfo || proxyInfo.isEmpty}
label={t<string>('proxied account')}
onChange={setStashAddress}
placeholder={t<string>('stash address')}
placeholder={t<string>('address being proxied')}
/>
</Modal.Columns>
<Modal.Columns hint={t<string>('The name is for unique identification of the account in your owner lists.')}>

View File

@ -23,12 +23,11 @@ function Candidate ({ address, balance, className = '', isPrime, voters }: Props
return (
<tr className={className}>
<td className='address all'>
<td className='address all relative'>
<AddressSmall value={address} />
</td>
<td>
{isPrime && (
<Tag
className='absolute'
color='green'
hover={t<string>('Current prime member, default voting')}
label={t<string>('prime voter')}

View File

@ -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')]
]);

View File

@ -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]
]);

View File

@ -75,52 +75,52 @@ function Member ({ bestNumber, className = '', value: { accountId, isCandidateVo
return (
<tr className={className}>
<td className='address'>
<td className='address relative all'>
<AddressSmall value={accountId} />
</td>
<td className='all'>
{isHead && (
<Tag
color='green'
label={t<string>('society head')}
/>
)}
{isFounder && (
<Tag
color='green'
label={t<string>('founder')}
/>
)}
{isSkeptic && (
<Tag
color='yellow'
label={t<string>('skeptic')}
/>
)}
{(isCandidateVoter || isDefenderVoter) && (
<Tag
color='blue'
label={t<string>('voted')}
/>
)}
{isWarned && (
<Tag
color='orange'
label={t<string>('strikes')}
/>
)}
{isSuspended && (
<Tag
color='red'
label={t<string>('suspended')}
/>
)}
{availablePayout && (
<Tag
color='grey'
label={t<string>('payout')}
/>
)}
<div className='absolute'>
{(isCandidateVoter || isDefenderVoter) && (
<Tag
color='blue'
label={t<string>('voted')}
/>
)}
{isWarned && (
<Tag
color='orange'
label={t<string>('strikes')}
/>
)}
{isHead && (
<Tag
color='green'
label={t<string>('society head')}
/>
)}
{isFounder && (
<Tag
color='green'
label={t<string>('founder')}
/>
)}
{isSkeptic && (
<Tag
color='yellow'
label={t<string>('skeptic')}
/>
)}
{isSuspended && (
<Tag
color='red'
label={t<string>('suspended')}
/>
)}
{availablePayout && (
<Tag
color='grey'
label={t<string>('payout')}
/>
)}
</div>
</td>
<td className='number together'>
{!!payouts?.length && (

View File

@ -21,7 +21,7 @@ function Members ({ className = '', mapMembers }: Props): React.ReactElement<Pro
const bestNumber = useBestNumber();
const headerRef = useRef([
[t('members'), 'start', 3],
[t('members'), 'start', 2],
[t('voted on'), 'start'],
[t('strikes')],
[]

View File

@ -271,8 +271,8 @@ export default React.memo(styled(Table)`
.absolute {
position: absolute;
right: 0.125rem;
top: 0.375rem;
right: 0;
top: 0.75rem;
white-space: nowrap;
}
}