Expander on treasury rows (#8704)

This commit is contained in:
Jaco 2023-01-06 10:00:19 +02:00 committed by GitHub
parent 874b838d43
commit 9e00a7de11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,8 +5,8 @@ import type { DeriveTreasuryProposal } from '@polkadot/api-derive/types';
import React, { useMemo } from 'react'; import React, { useMemo } from 'react';
import { AddressMini, AddressSmall, LinkExternal, Table } from '@polkadot/react-components'; import { AddressSmall, Columar, LinkExternal, Table } from '@polkadot/react-components';
import { useApi } from '@polkadot/react-hooks'; import { useApi, useToggle } from '@polkadot/react-hooks';
import { FormatBalance } from '@polkadot/react-query'; import { FormatBalance } from '@polkadot/react-query';
import { isFunction } from '@polkadot/util'; import { isFunction } from '@polkadot/util';
@ -24,6 +24,7 @@ interface Props {
function ProposalDisplay ({ className = '', isMember, members, proposal: { council, id, proposal }, withSend }: Props): React.ReactElement<Props> { function ProposalDisplay ({ className = '', isMember, members, proposal: { council, id, proposal }, withSend }: Props): React.ReactElement<Props> {
const { t } = useTranslation(); const { t } = useTranslation();
const { api } = useApi(); const { api } = useApi();
const [isExpanded, toggleIsExpanded] = useToggle(false);
const hasCouncil = isFunction(api.tx.council?.propose); const hasCouncil = isFunction(api.tx.council?.propose);
const hasProposals = useMemo( const hasProposals = useMemo(
@ -35,41 +36,59 @@ function ProposalDisplay ({ className = '', isMember, members, proposal: { counc
); );
return ( return (
<tr className={className}> <>
<Table.Column.Id value={id} /> <tr className={className}>
<td className='address all'> <Table.Column.Id value={id} />
<AddressSmall value={proposal.proposer} /> <td className='address all'>
</td> <AddressSmall value={proposal.proposer} />
<td className='address'> </td>
<AddressMini value={proposal.beneficiary} /> <td className='address'>
</td> <AddressSmall value={proposal.beneficiary} />
<td className='number'> </td>
<FormatBalance value={proposal.value} /> <td className='number'>
</td> <FormatBalance value={proposal.value} />
<td className='number'> </td>
<FormatBalance value={proposal.bond} /> <td className='number'>
</td> <FormatBalance value={proposal.bond} />
<td className={hasProposals ? 'middle' : 'button'}> </td>
{hasCouncil <td className={hasProposals ? 'middle' : 'button'}>
? hasProposals {hasCouncil
? <a href='#/council/motions'>{t('Voting')}</a> ? hasProposals
: withSend && ( ? <a href='#/council/motions'>{t('Voting')}</a>
<Council : withSend && (
id={id} <Council
isDisabled={!isMember} id={id}
members={members} isDisabled={!isMember}
/> members={members}
) />
: null )
} : null
</td> }
<td className='links'> </td>
<LinkExternal <Table.Column.Expand
data={id} isExpanded={isExpanded}
type='treasury' toggle={toggleIsExpanded}
/> />
</td> </tr>
</tr> <tr className={`${className} ${isExpanded ? 'isExpanded' : 'isCollapsed'} packedTop`}>
<td />
<td
className='columar'
colSpan={5}
>
<Columar is100>
<Columar.Column>
<LinkExternal
data={id}
type='treasury'
withTitle
/>
</Columar.Column>
</Columar>
</td>
<td />
</tr>
</>
); );
} }