Bounties - Distinguish slash and unassign curator in extended status (#4578)
This commit is contained in:
parent
be9e4f2cc0
commit
937754b644
@ -507,7 +507,7 @@ describe('Bounties', () => {
|
||||
|
||||
const { findByText } = renderOneBounty(bounty, proposals);
|
||||
|
||||
expect(await findByText('Approval under voting')).toBeTruthy();
|
||||
expect(await findByText('Bounty approval under voting')).toBeTruthy();
|
||||
});
|
||||
|
||||
it('on parallel bounty approval and bounty close in proposed status', async () => {
|
||||
@ -519,7 +519,7 @@ describe('Bounties', () => {
|
||||
|
||||
const { findByText } = renderOneBounty(bounty, proposals);
|
||||
|
||||
expect(await findByText('Approval under voting')).toBeTruthy();
|
||||
expect(await findByText('Bounty approval under voting')).toBeTruthy();
|
||||
});
|
||||
|
||||
it('on close bounty in active status', async () => {
|
||||
@ -528,7 +528,7 @@ describe('Bounties', () => {
|
||||
|
||||
const { findByText } = renderOneBounty(bounty, proposals);
|
||||
|
||||
expect(await findByText('Rejection under voting')).toBeTruthy();
|
||||
expect(await findByText('Bounty rejection under voting')).toBeTruthy();
|
||||
});
|
||||
|
||||
it('on unassign curator in active state', async () => {
|
||||
@ -537,7 +537,7 @@ describe('Bounties', () => {
|
||||
|
||||
const { findByText } = renderOneBounty(bounty, proposals);
|
||||
|
||||
expect(await findByText('Unassign curator under voting')).toBeTruthy();
|
||||
expect(await findByText('Curator slash under voting')).toBeTruthy();
|
||||
});
|
||||
|
||||
it('on bounty approval in active state', async () => {
|
||||
|
||||
@ -10,7 +10,7 @@ import React, { useRef } from 'react';
|
||||
import { BN_ZERO } from '@polkadot/util';
|
||||
|
||||
import Description from '../Description';
|
||||
import { bestValidProposalName } from '../helpers/extendedStatuses';
|
||||
import { proposalNameToDisplay } from '../helpers/extendedStatuses';
|
||||
import { useTranslation } from '../translate';
|
||||
|
||||
interface Props {
|
||||
@ -21,12 +21,13 @@ interface Props {
|
||||
}
|
||||
|
||||
function ExtendedStatus ({ blocksUntilPayout, className = '', proposals, status }: Props): React.ReactElement<Props> {
|
||||
const bestProposalName = proposals ? bestValidProposalName(proposals, status) : null;
|
||||
const bestProposalName = proposals ? proposalNameToDisplay(proposals, status) : null;
|
||||
const { t } = useTranslation();
|
||||
const votingDescriptions = useRef<Record<string, string>>({
|
||||
approveBounty: t('Approval under voting'),
|
||||
closeBounty: t('Rejection under voting'),
|
||||
approveBounty: t('Bounty approval under voting'),
|
||||
closeBounty: t('Bounty rejection under voting'),
|
||||
proposeCurator: t('Curator under voting'),
|
||||
slashCurator: t('Curator slash under voting'),
|
||||
unassignCurator: t('Unassign curator under voting')
|
||||
});
|
||||
|
||||
|
||||
@ -23,12 +23,20 @@ function getProposalByMethod (bountyProposals: DeriveCollectiveProposal[], metho
|
||||
return bountyProposals.find(({ proposal }) => proposal.method === method);
|
||||
}
|
||||
|
||||
export function bestValidProposalName (bountyProposals: DeriveCollectiveProposal[], status: BountyStatus): string | undefined {
|
||||
function bestValidProposalName (bountyProposals: DeriveCollectiveProposal[], status: BountyStatus): string | undefined {
|
||||
const methods = bountyProposals.map(({ proposal }) => proposal.method);
|
||||
|
||||
return validMethods(status).find((method) => methods.includes(method));
|
||||
}
|
||||
|
||||
export function proposalNameToDisplay (bountyProposals: DeriveCollectiveProposal[], status: BountyStatus): string | undefined {
|
||||
const bestProposalName = bestValidProposalName(bountyProposals, status);
|
||||
|
||||
if (bestProposalName !== 'unassignCurator') { return bestProposalName; }
|
||||
|
||||
return status.isCuratorProposed ? 'unassignCurator' : 'slashCurator';
|
||||
}
|
||||
|
||||
export function getProposalToDisplay (bountyProposals: DeriveCollectiveProposal[], status: BountyStatus): DeriveCollectiveProposal | null {
|
||||
const method = bestValidProposalName(bountyProposals, status);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user