Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Commit

Permalink
Bounties - Distinguish slash and unassign curator in extended status (p…
Browse files Browse the repository at this point in the history
  • Loading branch information
ekowalsk authored Feb 3, 2021
1 parent be9e4f2 commit 937754b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
8 changes: 4 additions & 4 deletions packages/page-bounties/src/Bounties.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand All @@ -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 () => {
Expand All @@ -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 () => {
Expand All @@ -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 () => {
Expand Down
9 changes: 5 additions & 4 deletions packages/page-bounties/src/Voting/ExtendedStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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')
});

Expand Down
10 changes: 9 additions & 1 deletion packages/page-bounties/src/helpers/extendedStatuses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 937754b

Please sign in to comment.