From 937754b64423b01f172995e23e159d8a16ebab27 Mon Sep 17 00:00:00 2001 From: Ewa Kowalska <30404388+ekowalsk@users.noreply.github.com> Date: Wed, 3 Feb 2021 11:22:58 +0100 Subject: [PATCH] Bounties - Distinguish slash and unassign curator in extended status (#4578) --- packages/page-bounties/src/Bounties.spec.tsx | 8 ++++---- packages/page-bounties/src/Voting/ExtendedStatus.tsx | 9 +++++---- packages/page-bounties/src/helpers/extendedStatuses.ts | 10 +++++++++- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/packages/page-bounties/src/Bounties.spec.tsx b/packages/page-bounties/src/Bounties.spec.tsx index 228d1838d4..01c3319c97 100644 --- a/packages/page-bounties/src/Bounties.spec.tsx +++ b/packages/page-bounties/src/Bounties.spec.tsx @@ -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 () => { diff --git a/packages/page-bounties/src/Voting/ExtendedStatus.tsx b/packages/page-bounties/src/Voting/ExtendedStatus.tsx index db048101ec..172b407af6 100644 --- a/packages/page-bounties/src/Voting/ExtendedStatus.tsx +++ b/packages/page-bounties/src/Voting/ExtendedStatus.tsx @@ -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 { - const bestProposalName = proposals ? bestValidProposalName(proposals, status) : null; + const bestProposalName = proposals ? proposalNameToDisplay(proposals, status) : null; const { t } = useTranslation(); const votingDescriptions = useRef>({ - 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') }); diff --git a/packages/page-bounties/src/helpers/extendedStatuses.ts b/packages/page-bounties/src/helpers/extendedStatuses.ts index a81374efa8..442d108353 100644 --- a/packages/page-bounties/src/helpers/extendedStatuses.ts +++ b/packages/page-bounties/src/helpers/extendedStatuses.ts @@ -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);