From 1a77385303db3d80ac82054f9351a8002a2d1f1f Mon Sep 17 00:00:00 2001 From: Johnny D Date: Sat, 9 Sep 2023 00:31:59 +1000 Subject: [PATCH] Only show version appropriate ballots in listings (#4047) --- .../useAvailableReconfigurationStrategies.ts | 2 +- .../hooks/useLoadInitialStateFromQuery.ts | 2 +- .../DetailsSection/CycleDeadlineDropdown.tsx | 5 +- .../RulesDrawer/RulesForm/RulesForm.tsx | 12 ++- src/constants/v2v3/ballotStrategies/index.ts | 91 +++++++++++-------- 5 files changed, 67 insertions(+), 45 deletions(-) diff --git a/src/components/Create/hooks/useAvailableReconfigurationStrategies.ts b/src/components/Create/hooks/useAvailableReconfigurationStrategies.ts index 0035c53459..a40f21e04a 100644 --- a/src/components/Create/hooks/useAvailableReconfigurationStrategies.ts +++ b/src/components/Create/hooks/useAvailableReconfigurationStrategies.ts @@ -3,7 +3,7 @@ import { NetworkName } from 'models/networkName' import { ArrayElement } from 'utils/arrayElement' export const useAvailableReconfigurationStrategies = (network: NetworkName) => { - const strategies = ballotStrategiesFn(network).map(s => + const strategies = ballotStrategiesFn({ network }).map(s => s.id === 'threeDay' ? { ...s, isDefault: true } : { ...s, isDefault: false }, diff --git a/src/components/Create/hooks/useLoadInitialStateFromQuery.ts b/src/components/Create/hooks/useLoadInitialStateFromQuery.ts index 9f5e2520bf..1e6a3035ab 100644 --- a/src/components/Create/hooks/useLoadInitialStateFromQuery.ts +++ b/src/components/Create/hooks/useLoadInitialStateFromQuery.ts @@ -73,7 +73,7 @@ const parseCreateFlowStateFromInitialState = ( } const reconfigurationRuleSelection = - ballotStrategiesFn().find(s => + ballotStrategiesFn({}).find(s => isEqualAddress(s.address, initialState.fundingCycleData.ballot), )?.id ?? 'threeDay' diff --git a/src/components/v2v3/V2V3Project/V2V3ProjectSettings/pages/NewEditCyclePage/DetailsSection/CycleDeadlineDropdown.tsx b/src/components/v2v3/V2V3Project/V2V3ProjectSettings/pages/NewEditCyclePage/DetailsSection/CycleDeadlineDropdown.tsx index 3d208e5e48..ec240aae5f 100644 --- a/src/components/v2v3/V2V3Project/V2V3ProjectSettings/pages/NewEditCyclePage/DetailsSection/CycleDeadlineDropdown.tsx +++ b/src/components/v2v3/V2V3Project/V2V3ProjectSettings/pages/NewEditCyclePage/DetailsSection/CycleDeadlineDropdown.tsx @@ -1,14 +1,17 @@ import { Trans } from '@lingui/macro' import { Form, Select } from 'antd' import { ballotStrategiesFn } from 'constants/v2v3/ballotStrategies' +import { V2V3ContractsContext } from 'contexts/v2v3/Contracts/V2V3ContractsContext' import { BallotStrategy } from 'models/ballot' +import { useContext } from 'react' export default function CycleDeadlineDropdown({ className, }: { className?: string }) { - const ballotStrategies = ballotStrategiesFn() + const { cv } = useContext(V2V3ContractsContext) + const ballotStrategies = ballotStrategiesFn({ cv }) return (