Skip to content

Commit

Permalink
feat: add create proposal feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
gleiser-oliveira committed Nov 7, 2023
1 parent 32b7390 commit 37bab3b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
1 change: 1 addition & 0 deletions src/hooks/useIsFeatureEnabled/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const featureFlags = {
convertVrtRoute: [ChainId.BSC_MAINNET, ChainId.BSC_TESTNET],
historyRoute: [ChainId.BSC_MAINNET, ChainId.BSC_TESTNET],
vaiRoute: [ChainId.BSC_MAINNET, ChainId.BSC_TESTNET],
createProposal: [ChainId.BSC_MAINNET, ChainId.BSC_TESTNET],
};

export type FeatureFlag = keyof typeof featureFlags;
Expand Down
34 changes: 19 additions & 15 deletions src/pages/Governance/ProposalList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
import CREATE_PROPOSAL_THRESHOLD_WEI from 'constants/createProposalThresholdWei';
import { routes } from 'constants/routing';
import { useAuth } from 'context/AuthContext';
import { useIsFeatureEnabled } from 'hooks/useIsFeatureEnabled';
import { UseUrlPaginationOutput } from 'hooks/useUrlPagination';

import CreateProposalModal from './CreateProposalModal';
Expand Down Expand Up @@ -47,6 +48,7 @@ export const ProposalListUi: React.FC<ProposalListUiProps> = ({
isCreateProposalLoading,
canCreateProposal,
}) => {
const createProposalEnabled = useIsFeatureEnabled({ name: 'createProposal' });
const navigate = useNavigate();
const { newProposalStep } = useParams<{
newProposalStep: 'create' | 'file' | 'manual' | undefined;
Expand All @@ -60,20 +62,22 @@ export const ProposalListUi: React.FC<ProposalListUiProps> = ({
<div css={[styles.header, styles.bottomSpace]}>
<Typography variant="h4">{t('vote.proposals')}</Typography>

<div css={styles.createProposal}>
<TextButton
onClick={() => {
setShowCreateProposalModal(true);
navigate(routes.governanceProposalCreate.path);
}}
css={styles.marginLess}
disabled={!canCreateProposal}
>
{t('vote.createProposalPlus')}
</TextButton>

<InfoIcon tooltip={t('vote.requiredVotingPower')} css={styles.infoIconWrapper} />
</div>
{createProposalEnabled && (
<div css={styles.createProposal}>
<TextButton
onClick={() => {
setShowCreateProposalModal(true);
navigate(routes.governanceProposalCreate.path);
}}
css={styles.marginLess}
disabled={!canCreateProposal}
>
{t('vote.createProposalPlus')}
</TextButton>

<InfoIcon tooltip={t('vote.requiredVotingPower')} css={styles.infoIconWrapper} />
</div>
)}
</div>

{isLoading && <Spinner css={styles.loader} />}
Expand Down Expand Up @@ -126,7 +130,7 @@ export const ProposalListUi: React.FC<ProposalListUiProps> = ({
/>
)}

{showCreateProposalModal && (
{createProposalEnabled && showCreateProposalModal && (
<CreateProposalModal
isOpen={showCreateProposalModal}
handleClose={() => {
Expand Down

0 comments on commit 37bab3b

Please sign in to comment.