-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: display executed payloads counts on proposal list
- Loading branch information
1 parent
34ed5f6
commit e126d10
Showing
28 changed files
with
317 additions
and
227 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@venusprotocol/evm": minor | ||
--- | ||
|
||
display executed payloads counts on proposal list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { cn } from 'utilities'; | ||
import { ProgressCircle } from '../ProgressCircle'; | ||
|
||
export interface LabeledProgressCircleProps extends React.HTMLAttributes<HTMLDivElement> { | ||
value: number; | ||
total: number; | ||
} | ||
|
||
export const LabeledProgressCircle: React.FC<LabeledProgressCircleProps> = ({ | ||
className, | ||
value, | ||
total, | ||
...otherProps | ||
}) => ( | ||
<div | ||
className={cn('relative ml-3 w-11 h-11 flex items-center justify-center', className)} | ||
{...otherProps} | ||
> | ||
<ProgressCircle className="absolute inset" value={(value * 100) / total} /> | ||
|
||
<p className="text-sm text-center"> | ||
{value}/{total} | ||
</p> | ||
</div> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
apps/evm/src/pages/Governance/ProposalList/GovernanceProposal/Status/Indicator/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { Icon, type IconName } from 'components'; | ||
import { useMemo } from 'react'; | ||
import { type Proposal, ProposalState } from 'types'; | ||
import { cn } from 'utilities'; | ||
|
||
export type IndicatorProps = React.HTMLAttributes<HTMLDivElement> & Pick<Proposal, 'state'>; | ||
|
||
export const Indicator: React.FC<IndicatorProps> = ({ state, className, ...otherProps }) => { | ||
const [colorClass, iconName] = useMemo<[string, IconName]>(() => { | ||
let tmpColorClass = 'bg-grey'; | ||
let tmpIconName: IconName = 'dots'; | ||
|
||
if (state === ProposalState.Executed) { | ||
tmpColorClass = 'bg-green'; | ||
tmpIconName = 'mark'; | ||
} else if (state === ProposalState.Succeeded) { | ||
tmpColorClass = 'bg-orange'; | ||
tmpIconName = 'exclamation'; | ||
} else if ( | ||
state === ProposalState.Defeated || | ||
state === ProposalState.Expired || | ||
state === ProposalState.Canceled | ||
) { | ||
tmpColorClass = 'bg-red'; | ||
tmpIconName = 'close'; | ||
} | ||
|
||
return [tmpColorClass, tmpIconName]; | ||
}, [state]); | ||
|
||
return ( | ||
<div | ||
className={cn( | ||
'w-10 h-10 rounded-full mx-auto flex items-center justify-center', | ||
colorClass, | ||
className, | ||
)} | ||
{...otherProps} | ||
> | ||
<Icon name={iconName} className="w-6 h-6 text-offWhite" /> | ||
</div> | ||
); | ||
}; |
68 changes: 68 additions & 0 deletions
68
apps/evm/src/pages/Governance/ProposalList/GovernanceProposal/Status/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { LabeledProgressCircle } from 'components'; | ||
import { useIsFeatureEnabled } from 'hooks/useIsFeatureEnabled'; | ||
import { useTranslation } from 'libs/translations'; | ||
import { useMemo } from 'react'; | ||
import { ProposalState } from 'types'; | ||
import { cn, getProposalStateLabel } from 'utilities'; | ||
import { Indicator } from './Indicator'; | ||
|
||
export interface StatusProps extends React.HTMLAttributes<HTMLDivElement> { | ||
state: ProposalState; | ||
totalPayloadsCount: number; | ||
executedPayloadsCount: number; | ||
} | ||
|
||
export const Status: React.FC<StatusProps> = ({ | ||
state, | ||
totalPayloadsCount, | ||
executedPayloadsCount, | ||
className, | ||
...otherProps | ||
}) => { | ||
const { t } = useTranslation(); | ||
const isMultichainGovernanceFeatureEnabled = useIsFeatureEnabled({ | ||
name: 'multichainGovernance', | ||
}); | ||
|
||
const isFullyExecuted = executedPayloadsCount === totalPayloadsCount; | ||
const shouldShowExecutedPayloadsStatus = | ||
isMultichainGovernanceFeatureEnabled && state === ProposalState.Executed && !isFullyExecuted; | ||
|
||
const label = useMemo(() => { | ||
if (shouldShowExecutedPayloadsStatus) { | ||
return t('voteProposalUi.status.executedPayloads'); | ||
} | ||
|
||
if (state === ProposalState.Succeeded) { | ||
return t('voteProposalUi.status.readyForExecution'); | ||
} | ||
|
||
return getProposalStateLabel({ state }); | ||
}, [t, state, shouldShowExecutedPayloadsStatus]); | ||
|
||
return ( | ||
<div | ||
className={cn( | ||
'flex items-center gap-3 overflow-hidden text-offWhite sm:flex-col sm:text-center', | ||
className, | ||
)} | ||
{...otherProps} | ||
> | ||
<div className="shrink-0"> | ||
{shouldShowExecutedPayloadsStatus ? ( | ||
<LabeledProgressCircle | ||
total={totalPayloadsCount} | ||
value={executedPayloadsCount} | ||
className="mx-auto" | ||
/> | ||
) : ( | ||
<Indicator state={state} /> | ||
)} | ||
</div> | ||
|
||
<p className="text-md font-semibold whitespace-nowrap overflow-hidden text-ellipsis flex-grow"> | ||
{label} | ||
</p> | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.