diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d667b951..4dfac2731 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,9 +11,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Update `InputFileAvatar` core component to remove `onFileSelect` and `onFileError` properties and use `value` and `onChange` properties instead -- Update `IProposalActionUpdateMetadataDaoMetadata` interface `logo` property to `avatar` to better align with actions. +- Update `IProposalActionUpdateMetadataDaoMetadata` interface `logo` property to `avatar` to better align with actions - Bump `softprops/action-gh-release` from 2.2.0 to 2.2.1 - Update minor and patch NPM dependencies +- Update `` module component to include `statusContext` property and support `ADVANCEABLE` + status +- Remove `` and `` sub-components for `` ## [1.0.62] - 2025-01-08 diff --git a/src/modules/assets/copy/modulesCopy.ts b/src/modules/assets/copy/modulesCopy.ts index 947fcb9b1..77d20575b 100644 --- a/src/modules/assets/copy/modulesCopy.ts +++ b/src/modules/assets/copy/modulesCopy.ts @@ -17,14 +17,6 @@ export const modulesCopy = { delegations: 'Delegations', votingPower: 'Voting Power', }, - approvalThresholdResult: { - stage: 'Stage', - outOf: (threshold: string) => `of ${threshold} members`, - }, - majorityVotingResult: { - winningOption: 'Winning Option', - stage: 'Stage', - }, proposalActionsContainer: { emptyHeader: 'No actions added', }, @@ -93,18 +85,18 @@ export const modulesCopy = { totalHoldersTerm: 'Total token holders', }, proposalDataListItemStatus: { - voted: "You've voted", + voted: 'Voted', ago: 'ago', left: 'left', + in: 'in', statusLabel: { ACCEPTED: 'Accepted', + ADVANCEABLE: 'Advanceable', ACTIVE: 'Active', - CHALLENGED: 'Challenged', DRAFT: 'Draft', EXECUTED: 'Executed', EXPIRED: 'Expired', FAILED: 'Failed', - PARTIALLY_EXECUTED: 'Partially executed', PENDING: 'Pending', EXECUTABLE: 'Executable', REJECTED: 'Rejected', diff --git a/src/modules/components/proposal/proposalDataListItem/approvalThresholdResult/approvalThresholdResult.test.tsx b/src/modules/components/proposal/proposalDataListItem/approvalThresholdResult/approvalThresholdResult.test.tsx deleted file mode 100644 index fe51698a6..000000000 --- a/src/modules/components/proposal/proposalDataListItem/approvalThresholdResult/approvalThresholdResult.test.tsx +++ /dev/null @@ -1,60 +0,0 @@ -import { render, screen } from '@testing-library/react'; -import { NumberFormat, formatterUtils } from '../../../../../core'; -import { modulesCopy } from '../../../../assets'; -import { ApprovalThresholdResult, type IApprovalThresholdResultProps } from './approvalThresholdResult'; - -describe(' component', () => { - const createTestComponent = (props?: Partial) => { - const completeProps: IApprovalThresholdResultProps = { - approvalAmount: 1, - approvalThreshold: 2, - ...props, - }; - - return ; - }; - - it('renders the formatted approval threshold and approval amount and the corresponding progressbar', () => { - const mockProps: IApprovalThresholdResultProps = { - approvalAmount: 15000000, - approvalThreshold: 20000000, - }; - - render(createTestComponent(mockProps)); - - const expectedApproval = formatterUtils.formatNumber(mockProps.approvalAmount, { - format: NumberFormat.GENERIC_SHORT, - })!; - - const expectedThreshold = formatterUtils.formatNumber(mockProps.approvalThreshold, { - format: NumberFormat.GENERIC_SHORT, - })!; - - const progressbar = screen.getByRole('progressbar'); - expect(progressbar).toBeInTheDocument(); - - const expectedPercentage = (mockProps.approvalAmount / mockProps.approvalThreshold) * 100; - expect(progressbar.getAttribute('data-value')).toEqual(expectedPercentage.toString()); - - expect(screen.getByText(expectedApproval)).toBeInTheDocument(); - expect(screen.getByText(modulesCopy.approvalThresholdResult.outOf(expectedThreshold))).toBeInTheDocument(); - }); - - it('renders the stage title and stage id when provided', () => { - const stage = { - title: 'Test Stage', - id: '3', - }; - - render(createTestComponent({ stage })); - - expect(screen.getByText(stage.title)).toBeInTheDocument(); - expect(screen.getByText(stage.id)).toBeInTheDocument(); - }); - - it('renders the default stage title when not provided', () => { - render(createTestComponent()); - - expect(screen.getByText(/approved by/i)).toBeInTheDocument(); - }); -}); diff --git a/src/modules/components/proposal/proposalDataListItem/approvalThresholdResult/approvalThresholdResult.tsx b/src/modules/components/proposal/proposalDataListItem/approvalThresholdResult/approvalThresholdResult.tsx deleted file mode 100644 index 3ed1a724b..000000000 --- a/src/modules/components/proposal/proposalDataListItem/approvalThresholdResult/approvalThresholdResult.tsx +++ /dev/null @@ -1,40 +0,0 @@ -import { NumberFormat, Progress, formatterUtils } from '../../../../../core'; -import { useGukModulesContext } from '../../../gukModulesProvider'; -import { type IApprovalThresholdResult } from '../proposalDataListItemStructure'; - -export interface IApprovalThresholdResultProps extends IApprovalThresholdResult {} - -/** - * `ApprovalThresholdResult` component - */ -export const ApprovalThresholdResult: React.FC = (props) => { - const { approvalAmount, approvalThreshold, stage } = props; - const percentage = approvalThreshold !== 0 ? (approvalAmount / approvalThreshold) * 100 : 100; - - const { copy } = useGukModulesContext(); - - const formattedApprovalThreshold = formatterUtils.formatNumber(approvalThreshold, { - format: NumberFormat.GENERIC_SHORT, - })!; - - return ( -
-
- {stage?.title ?? 'Approved By'} - {stage?.id != null && ( - - {copy.approvalThresholdResult.stage} - {stage.id} - - )} -
- -
- - {formatterUtils.formatNumber(approvalAmount, { format: NumberFormat.GENERIC_SHORT })} - - {copy.approvalThresholdResult.outOf(formattedApprovalThreshold)} -
-
- ); -}; diff --git a/src/modules/components/proposal/proposalDataListItem/approvalThresholdResult/index.ts b/src/modules/components/proposal/proposalDataListItem/approvalThresholdResult/index.ts deleted file mode 100644 index 8f6eb5c24..000000000 --- a/src/modules/components/proposal/proposalDataListItem/approvalThresholdResult/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { ApprovalThresholdResult, type IApprovalThresholdResultProps } from './approvalThresholdResult'; diff --git a/src/modules/components/proposal/proposalDataListItem/majorityVotingResult/index.ts b/src/modules/components/proposal/proposalDataListItem/majorityVotingResult/index.ts deleted file mode 100644 index 418f0bf66..000000000 --- a/src/modules/components/proposal/proposalDataListItem/majorityVotingResult/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { MajorityVotingResult, type IMajorityVotingResultProps } from './majorityVotingResult'; diff --git a/src/modules/components/proposal/proposalDataListItem/majorityVotingResult/majorityVotingResult.test.tsx b/src/modules/components/proposal/proposalDataListItem/majorityVotingResult/majorityVotingResult.test.tsx deleted file mode 100644 index 043539de4..000000000 --- a/src/modules/components/proposal/proposalDataListItem/majorityVotingResult/majorityVotingResult.test.tsx +++ /dev/null @@ -1,48 +0,0 @@ -import { render, screen } from '@testing-library/react'; -import { MajorityVotingResult, type IMajorityVotingResultProps } from './majorityVotingResult'; - -describe(' component', () => { - const createTestComponent = (props?: Partial) => { - const completeProps: IMajorityVotingResultProps = { - option: 'yes', - voteAmount: '100 wAnt', - votePercentage: 10, - ...props, - }; - - return ; - }; - - it('renders the given winning option, vote amount, vote percentage and a corresponding progressbar', () => { - const mockProps: IMajorityVotingResultProps = { - option: 'yes', - voteAmount: '100k wAnt', - votePercentage: 15, - }; - - render(createTestComponent(mockProps)); - - expect(screen.getByText(mockProps.option)).toBeInTheDocument(); - expect(screen.getByText(mockProps.voteAmount)).toBeInTheDocument(); - expect(screen.getByText(mockProps.votePercentage, { exact: false })).toBeInTheDocument(); - expect(screen.getByRole('progressbar')).toBeInTheDocument(); - }); - - it('renders the stage title and stage id when provided', () => { - const stage = { - title: 'Test Stage', - id: '3', - }; - - render(createTestComponent({ stage })); - - expect(screen.getByText(stage.title)).toBeInTheDocument(); - expect(screen.getByText(stage.id)).toBeInTheDocument(); - }); - - it('renders the default stage title when not provided', () => { - render(createTestComponent()); - - expect(screen.getByText(/winning option/i)).toBeInTheDocument(); - }); -}); diff --git a/src/modules/components/proposal/proposalDataListItem/majorityVotingResult/majorityVotingResult.tsx b/src/modules/components/proposal/proposalDataListItem/majorityVotingResult/majorityVotingResult.tsx deleted file mode 100644 index e146d17cb..000000000 --- a/src/modules/components/proposal/proposalDataListItem/majorityVotingResult/majorityVotingResult.tsx +++ /dev/null @@ -1,34 +0,0 @@ -import { Progress } from '../../../../../core'; -import { useGukModulesContext } from '../../../gukModulesProvider'; -import { type IMajorityVotingResult } from '../proposalDataListItemStructure'; - -export interface IMajorityVotingResultProps extends IMajorityVotingResult {} - -/** - * `MajorityVotingResult` component - */ -export const MajorityVotingResult: React.FC = (props) => { - const { option, stage, voteAmount, votePercentage } = props; - - const { copy } = useGukModulesContext(); - - return ( -
-
- {stage?.title ?? copy.majorityVotingResult.winningOption} - {stage?.id == null && {`${votePercentage.toString()}%`}} - {stage?.id != null && ( - - {copy.majorityVotingResult.stage} - {stage.id} - - )} -
- -
- {option} - {voteAmount} -
-
- ); -}; diff --git a/src/modules/components/proposal/proposalDataListItem/proposalDataListItemStatus/proposalDataListItemStatus.test.tsx b/src/modules/components/proposal/proposalDataListItem/proposalDataListItemStatus/proposalDataListItemStatus.test.tsx index 35a7ef98e..4a1629be6 100644 --- a/src/modules/components/proposal/proposalDataListItem/proposalDataListItemStatus/proposalDataListItemStatus.test.tsx +++ b/src/modules/components/proposal/proposalDataListItem/proposalDataListItemStatus/proposalDataListItemStatus.test.tsx @@ -2,7 +2,6 @@ import { render, screen } from '@testing-library/react'; import { DateFormat, IconType, formatterUtils } from '../../../../../core'; import { modulesCopy } from '../../../../assets'; import { ProposalStatus } from '../../proposalUtils'; -import { proposalDataListItemUtils } from '../proposalDataListItemUtils'; import { ProposalDataListItemStatus, type IProposalDataListItemStatusProps } from './proposalDataListItemStatus'; describe(' component', () => { @@ -50,32 +49,50 @@ describe(' component', () => { expect(screen.queryByTestId(IconType.CALENDAR)).not.toBeInTheDocument(); }); - test.each(proposalDataListItemUtils.ongoingStatuses)( - 'displays the date and a pinging indicator when the status is %s and voted is false', - (status) => { - const date = 1719563030308; - render(createTestComponent({ date, status, voted: false })); - - const formattedDate = formatterUtils.formatDate(date, { format: DateFormat.RELATIVE })!; - expect(screen.getByText(formattedDate)).toBeInTheDocument(); - expect(screen.getByTestId('statePingAnimation')).toBeInTheDocument(); - }, - ); - - test.each(proposalDataListItemUtils.ongoingStatuses)( - 'displays a you-voted label with an icon checkmark when the status is %s and voted is true', - (status) => { - render(createTestComponent({ status, voted: true })); - - expect(screen.getByText(/You've voted/i)).toBeInTheDocument(); - expect(screen.getByTestId(IconType.CHECKMARK)).toBeInTheDocument(); - }, - ); - - it('does not display a you-voted label when the status is not an ongoing one and the voted is true', () => { + it('displays the date and a pinging indicator when the status is active and voted is false', () => { + const status = ProposalStatus.ACTIVE; + const date = 1719563030308; + render(createTestComponent({ date, status, voted: false })); + + const formattedDate = formatterUtils.formatDate(date, { format: DateFormat.RELATIVE })!; + expect(screen.getByText(formattedDate)).toBeInTheDocument(); + expect(screen.getByTestId('statePingAnimation')).toBeInTheDocument(); + }); + + it('displays a voted label when the status is active and voted is true', () => { + const status = ProposalStatus.ACTIVE; + render(createTestComponent({ status, voted: true })); + + expect(screen.getByText(/Voted/i)).toBeInTheDocument(); + expect(screen.getByTestId(IconType.CHECKMARK)).toBeInTheDocument(); + }); + + it('does not display a voted label when the status is not active and voted is true', () => { render(createTestComponent({ status: ProposalStatus.EXECUTED, voted: true })); - expect(screen.queryByText(/You've voted/i)).not.toBeInTheDocument(); + expect(screen.queryByText(/Voted/i)).not.toBeInTheDocument(); expect(screen.queryByTestId(IconType.CHECKMARK)).not.toBeInTheDocument(); }); + + it('displays the status context when statusContext is provided and status is active', () => { + const statusContext = 'Stage 1'; + const status = ProposalStatus.ACTIVE; + render(createTestComponent({ statusContext, status })); + expect(screen.getByText(statusContext)).toBeInTheDocument(); + }); + + it('displays the status context when statusContext is provided and status is advanceable', () => { + const statusContext = 'Stage 1'; + const status = ProposalStatus.ADVANCEABLE; + render(createTestComponent({ status, statusContext })); + expect(screen.getByText(modulesCopy.proposalDataListItemStatus.statusLabel[status])).toBeInTheDocument(); + expect(screen.getByText(statusContext)).toBeInTheDocument(); + }); + + it('does not display the status context when statusContext is provided and status is final', () => { + const statusContext = 'Stage 1'; + const status = ProposalStatus.EXECUTED; + render(createTestComponent({ statusContext, status })); + expect(screen.queryByText(statusContext)).not.toBeInTheDocument(); + }); }); diff --git a/src/modules/components/proposal/proposalDataListItem/proposalDataListItemStatus/proposalDataListItemStatus.tsx b/src/modules/components/proposal/proposalDataListItem/proposalDataListItemStatus/proposalDataListItemStatus.tsx index f8f734ec0..3b15fdeb0 100644 --- a/src/modules/components/proposal/proposalDataListItem/proposalDataListItemStatus/proposalDataListItemStatus.tsx +++ b/src/modules/components/proposal/proposalDataListItem/proposalDataListItemStatus/proposalDataListItemStatus.tsx @@ -2,27 +2,19 @@ import classNames from 'classnames'; import { AvatarIcon, DateFormat, + formatterUtils, IconType, Rerender, StatePingAnimation, Tag, - formatterUtils, - type StatePingAnimationVariant, } from '../../../../../core'; import type { ModulesCopy } from '../../../../assets'; import { useGukModulesContext } from '../../../gukModulesProvider'; import { ProposalStatus, proposalStatusToTagVariant } from '../../proposalUtils'; import { type IProposalDataListItemStructureProps } from '../proposalDataListItemStructure'; -import { proposalDataListItemUtils } from '../proposalDataListItemUtils'; export interface IProposalDataListItemStatusProps - extends Pick {} - -const proposalStatusToPingVariant = new Map([ - [ProposalStatus.ACTIVE, 'info'], - [ProposalStatus.CHALLENGED, 'warning'], - [ProposalStatus.VETOED, 'warning'], -]); + extends Pick {} const getFormattedProposalDate = (date: string | number, now: number, copy: ModulesCopy) => { const formattedDuration = formatterUtils.formatDate(date, { format: DateFormat.DURATION })!; @@ -34,41 +26,46 @@ const getFormattedProposalDate = (date: string | number, now: number, copy: Modu }; export const ProposalDataListItemStatus: React.FC = (props) => { - const { date, status, voted } = props; + const { date, status, statusContext, voted } = props; + + const isActive = status === ProposalStatus.ACTIVE; - const isOngoing = proposalDataListItemUtils.isOngoingStatus(status); - const isOngoingAndVoted = isOngoing && voted; + const showStatusContext = statusContext != null && (isActive || status === ProposalStatus.ADVANCEABLE); const showStatusMetadata = status !== ProposalStatus.DRAFT; const { copy } = useGukModulesContext(); return ( -
- +
+
+ + {showStatusContext && ( +
+ {copy.proposalDataListItemStatus.in} + {statusContext} +
+ )} +
{showStatusMetadata && (
- {isOngoingAndVoted && copy.proposalDataListItemStatus.voted} - {!isOngoingAndVoted && date != null && ( + {isActive && voted && copy.proposalDataListItemStatus.voted} + {(!isActive || !voted) && date != null && ( {(now) => getFormattedProposalDate(date, now, copy)} )} - {isOngoingAndVoted && } - {isOngoing && !voted && } - {!isOngoing && !voted && date && ( - - )} + {isActive && voted && } + {isActive && !voted && } + {!isActive && date && }
)}
diff --git a/src/modules/components/proposal/proposalDataListItem/proposalDataListItemStructure/proposalDataListItemStructure.api.ts b/src/modules/components/proposal/proposalDataListItem/proposalDataListItemStructure/proposalDataListItemStructure.api.ts index de0603b3e..df0dd2804 100644 --- a/src/modules/components/proposal/proposalDataListItem/proposalDataListItemStructure/proposalDataListItemStructure.api.ts +++ b/src/modules/components/proposal/proposalDataListItem/proposalDataListItemStructure/proposalDataListItemStructure.api.ts @@ -2,15 +2,7 @@ import type { IDataListItemProps } from '../../../../../core'; import { type ICompositeAddress, type IWeb3ComponentProps } from '../../../../types'; import { type ProposalStatus } from '../../proposalUtils'; -export type ProposalType = 'majorityVoting' | 'approvalThreshold' | undefined; - -export type ProposalResult = TType extends 'majorityVoting' - ? IMajorityVotingResult - : TType extends 'approvalThreshold' - ? IApprovalThresholdResult - : undefined; - -export type IProposalDataListItemStructureBaseProps = IDataListItemProps & +export type IProposalDataListItemStructureProps = IDataListItemProps & IWeb3ComponentProps & { /** * Proposal id @@ -28,14 +20,15 @@ export type IProposalDataListItemStructureBaseProps; /** * Proposal status */ status: ProposalStatus; + /** + * Provides additional context about the current status of a proposal within a multistage voting process. + * Only displayed when proposal status is `ACTIVE` or `ADVANCEABLE`. + */ + statusContext?: string; /** * Proposal description */ @@ -44,10 +37,6 @@ export type IProposalDataListItemStructureBaseProps - | IProposalDataListItemStructureBaseProps<'majorityVoting'> - | IProposalDataListItemStructureBaseProps<'approvalThreshold'>; diff --git a/src/modules/components/proposal/proposalDataListItem/proposalDataListItemStructure/proposalDataListItemStructure.stories.tsx b/src/modules/components/proposal/proposalDataListItem/proposalDataListItemStructure/proposalDataListItemStructure.stories.tsx index 52daffbe4..e2144d1e5 100644 --- a/src/modules/components/proposal/proposalDataListItem/proposalDataListItemStructure/proposalDataListItemStructure.stories.tsx +++ b/src/modules/components/proposal/proposalDataListItem/proposalDataListItemStructure/proposalDataListItemStructure.stories.tsx @@ -28,45 +28,14 @@ export const Default: Story = { }, }; -/** - * Example of the `ProposalDataListItem.Structure` module component for a MajorityVoting type proposal. - */ -export const MajorityVoting: Story = { - args: { - date: 1691664284000, - status: ProposalStatus.ACTIVE, - title: 'Update DAO metadata', - summary: 'Update the name, logo and description of the DAO.', - voted: true, - publisher: { address: '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045', name: 'vitalik.eth' }, - type: 'majorityVoting', - result: { option: 'yes', voteAmount: '100k wAnt', votePercentage: 15 }, - }, -}; - -/** - * Example of the `ProposalDataListItem.Structure` module component for an ApprovalThreshold type proposal. - */ -export const ApprovalThreshold: Story = { - args: { - date: 1638723612000, - status: ProposalStatus.ACTIVE, - title: 'Add new DAO member', - summary: `Adding a new member to the DAO. This is a long description to test if the component correctly truncated - the proposal description. This is a long description to test if the component correctly truncated the proposal description.`, - publisher: { address: '0xd5fb864ACfD6BB2f72939f122e89fF7F475924f5', name: 'sio.eth' }, - type: 'approvalThreshold', - result: { approvalAmount: 4, approvalThreshold: 6 }, - }, -}; - /** * Example of the `ProposalDataListItem.Structure` module component for a multi-body proposal. */ export const MultiBody: Story = { args: { - date: 1580338809000, + date: Date.now() + 1000000, status: ProposalStatus.ACTIVE, + statusContext: 'Stage 1', title: 'Partnering with WalletConnect on Social Media', summary: 'This is round 1 of our community engagement and building gamfi strategy with our marketing team partnership.', @@ -77,8 +46,6 @@ export const MultiBody: Story = { { address: '0xd5fb864ACfD6BB2f72939f122e89fF7F475924f5', name: 'sio.eth' }, { address: '0xbC7f20ebB9AeDe6DF4965eCAAcfBb24927Ae16E7' }, ], - type: 'approvalThreshold', - result: { stage: { title: 'Founders Approval Council', id: '1' }, approvalAmount: 4, approvalThreshold: 6 }, }, }; diff --git a/src/modules/components/proposal/proposalDataListItem/proposalDataListItemStructure/proposalDataListItemStructure.test.tsx b/src/modules/components/proposal/proposalDataListItem/proposalDataListItemStructure/proposalDataListItemStructure.test.tsx index d50e55cb4..690e8d966 100644 --- a/src/modules/components/proposal/proposalDataListItem/proposalDataListItemStructure/proposalDataListItemStructure.test.tsx +++ b/src/modules/components/proposal/proposalDataListItem/proposalDataListItemStructure/proposalDataListItemStructure.test.tsx @@ -119,56 +119,4 @@ describe(' component', () => { expect(screen.getByText(formattedDate)).toBeInTheDocument(); }); }); - - describe("'approvalThreshold' type", () => { - it(`renders the results when status is ongoing`, () => { - const testProps = { approvalAmount: 10, approvalThreshold: 11 }; - - render( - createTestComponent({ result: testProps, type: 'approvalThreshold', status: ProposalStatus.ACTIVE }), - ); - - expect(screen.getByText(testProps.approvalAmount)).toBeInTheDocument(); - expect( - screen.getByText(modulesCopy.approvalThresholdResult.outOf(testProps.approvalThreshold.toString())), - ).toBeInTheDocument(); - }); - - it('does not render the results when status is not of an ongoing type', () => { - const testProps = { approvalAmount: 10, approvalThreshold: 11 }; - - render( - createTestComponent({ result: testProps, type: 'approvalThreshold', status: ProposalStatus.EXPIRED }), - ); - - expect(screen.queryByText(testProps.approvalAmount)).not.toBeInTheDocument(); - expect( - screen.queryByText(modulesCopy.approvalThresholdResult.outOf(testProps.approvalThreshold.toString())), - ).not.toBeInTheDocument(); - }); - }); - - describe("'majorityVoting' type", () => { - it(`renders the results when status is ongoing`, () => { - const testProps = { option: 'Yes', voteAmount: '100 wAnt', votePercentage: 10 }; - - render( - createTestComponent({ result: testProps, type: 'majorityVoting', status: ProposalStatus.CHALLENGED }), - ); - - expect(screen.getByText(testProps.option)).toBeInTheDocument(); - expect(screen.getByText(testProps.voteAmount)).toBeInTheDocument(); - expect(screen.getByText(`${testProps.votePercentage.toString()}%`)).toBeInTheDocument(); - }); - - it('does not render the results when status is not of an ongoing type', () => { - const testProps = { option: 'Yes', voteAmount: '100 wAnt', votePercentage: 10 }; - - render(createTestComponent({ result: testProps, type: 'majorityVoting', status: ProposalStatus.PENDING })); - - expect(screen.queryByText(testProps.option)).not.toBeInTheDocument(); - expect(screen.queryByText(testProps.voteAmount)).not.toBeInTheDocument(); - expect(screen.queryByText(`${testProps.votePercentage.toString()}%`)).not.toBeInTheDocument(); - }); - }); }); diff --git a/src/modules/components/proposal/proposalDataListItem/proposalDataListItemStructure/proposalDataListItemStructure.tsx b/src/modules/components/proposal/proposalDataListItem/proposalDataListItemStructure/proposalDataListItemStructure.tsx index 7f2872bb6..ec659c8af 100644 --- a/src/modules/components/proposal/proposalDataListItem/proposalDataListItemStructure/proposalDataListItemStructure.tsx +++ b/src/modules/components/proposal/proposalDataListItem/proposalDataListItemStructure/proposalDataListItemStructure.tsx @@ -3,10 +3,7 @@ import { useAccount } from 'wagmi'; import { DataList, Heading, Link, Tag } from '../../../../../core'; import { addressUtils } from '../../../../utils/addressUtils'; import { useGukModulesContext } from '../../../gukModulesProvider'; -import { ApprovalThresholdResult } from '../approvalThresholdResult'; -import { MajorityVotingResult } from '../majorityVotingResult'; import { ProposalDataListItemStatus } from '../proposalDataListItemStatus'; -import { proposalDataListItemUtils } from '../proposalDataListItemUtils'; import { type IProposalDataListItemStructureProps, type IPublisher } from './proposalDataListItemStructure.api'; export const maxPublishersDisplayed = 3; @@ -27,11 +24,11 @@ export const ProposalDataListItemStructure: React.FC parsePublisher(p, isConnected, connectedAddress)) : [parsePublisher(publisher, isConnected, connectedAddress)]; @@ -55,7 +50,7 @@ export const ProposalDataListItemStructure: React.FC - +
{id && {id}} @@ -63,13 +58,7 @@ export const ProposalDataListItemStructure: React.FC

{summary}

- - {isOngoing && type === 'approvalThreshold' && result && } - - {isOngoing && type === 'majorityVoting' && result && } - {children} -
{ - describe('isOngoingStatus', () => { - it('returns true for ongoing proposal statuses', () => { - expect(proposalDataListItemUtils.isOngoingStatus(ProposalStatus.ACTIVE)).toBeTruthy(); - expect(proposalDataListItemUtils.isOngoingStatus(ProposalStatus.CHALLENGED)).toBeTruthy(); - expect(proposalDataListItemUtils.isOngoingStatus(ProposalStatus.VETOED)).toBeTruthy(); - }); - - it('returns false for non-ongoing proposal statuses', () => { - expect(proposalDataListItemUtils.isOngoingStatus(ProposalStatus.DRAFT)).toBeFalsy(); - expect(proposalDataListItemUtils.isOngoingStatus(ProposalStatus.EXECUTABLE)).toBeFalsy(); - expect(proposalDataListItemUtils.isOngoingStatus(ProposalStatus.ACCEPTED)).toBeFalsy(); - }); - }); -}); diff --git a/src/modules/components/proposal/proposalDataListItem/proposalDataListItemUtils.ts b/src/modules/components/proposal/proposalDataListItem/proposalDataListItemUtils.ts deleted file mode 100644 index 0d9d27ae6..000000000 --- a/src/modules/components/proposal/proposalDataListItem/proposalDataListItemUtils.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { ProposalStatus } from '../proposalUtils'; - -class ProposalDataListItemUtils { - ongoingStatuses: ProposalStatus[] = [ProposalStatus.ACTIVE, ProposalStatus.CHALLENGED, ProposalStatus.VETOED]; - - isOngoingStatus = (status: ProposalStatus) => this.ongoingStatuses.includes(status); -} - -export const proposalDataListItemUtils = new ProposalDataListItemUtils(); diff --git a/src/modules/components/proposal/proposalUtils.ts b/src/modules/components/proposal/proposalUtils.ts index 31e831ca6..f08e2a141 100644 --- a/src/modules/components/proposal/proposalUtils.ts +++ b/src/modules/components/proposal/proposalUtils.ts @@ -3,12 +3,11 @@ import type { TagVariant } from '../../../core'; export enum ProposalStatus { ACCEPTED = 'ACCEPTED', ACTIVE = 'ACTIVE', - CHALLENGED = 'CHALLENGED', + ADVANCEABLE = 'ADVANCEABLE', DRAFT = 'DRAFT', EXECUTED = 'EXECUTED', EXPIRED = 'EXPIRED', FAILED = 'FAILED', - PARTIALLY_EXECUTED = 'PARTIALLY_EXECUTED', PENDING = 'PENDING', EXECUTABLE = 'EXECUTABLE', REJECTED = 'REJECTED', @@ -17,8 +16,8 @@ export enum ProposalStatus { export enum ProposalVotingStatus { ACTIVE = 'ACTIVE', - PENDING = 'PENDING', ACCEPTED = 'ACCEPTED', + PENDING = 'PENDING', EXPIRED = 'EXPIRED', REJECTED = 'REJECTED', UNREACHED = 'UNREACHED', @@ -28,12 +27,11 @@ export enum ProposalVotingStatus { export const proposalStatusToVotingStatus: Record = { [ProposalStatus.ACCEPTED]: ProposalVotingStatus.ACCEPTED, [ProposalStatus.ACTIVE]: ProposalVotingStatus.ACTIVE, - [ProposalStatus.CHALLENGED]: ProposalVotingStatus.ACTIVE, + [ProposalStatus.ADVANCEABLE]: ProposalVotingStatus.ACCEPTED, [ProposalStatus.DRAFT]: ProposalVotingStatus.PENDING, [ProposalStatus.EXECUTED]: ProposalVotingStatus.ACCEPTED, [ProposalStatus.EXPIRED]: ProposalVotingStatus.EXPIRED, [ProposalStatus.FAILED]: ProposalVotingStatus.ACCEPTED, - [ProposalStatus.PARTIALLY_EXECUTED]: ProposalVotingStatus.ACCEPTED, [ProposalStatus.PENDING]: ProposalVotingStatus.PENDING, [ProposalStatus.EXECUTABLE]: ProposalVotingStatus.ACTIVE, [ProposalStatus.REJECTED]: ProposalVotingStatus.REJECTED, @@ -43,14 +41,13 @@ export const proposalStatusToVotingStatus: Record = { [ProposalStatus.ACCEPTED]: 'success', [ProposalStatus.ACTIVE]: 'info', - [ProposalStatus.CHALLENGED]: 'warning', + [ProposalStatus.ADVANCEABLE]: 'info', [ProposalStatus.DRAFT]: 'neutral', [ProposalStatus.EXECUTED]: 'success', [ProposalStatus.EXPIRED]: 'critical', [ProposalStatus.FAILED]: 'critical', - [ProposalStatus.PARTIALLY_EXECUTED]: 'warning', [ProposalStatus.PENDING]: 'neutral', [ProposalStatus.EXECUTABLE]: 'info', [ProposalStatus.REJECTED]: 'critical', - [ProposalStatus.VETOED]: 'warning', + [ProposalStatus.VETOED]: 'critical', };