Skip to content

Commit

Permalink
fix: Add proposers feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
usame-algan committed Nov 6, 2024
1 parent 92111aa commit a37cc0c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 19 deletions.
43 changes: 24 additions & 19 deletions src/components/settings/ProposersList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ import Track from '@/components/common/Track'
import UpsertProposer from '@/features/proposers/components/UpsertProposer'
import DeleteProposerDialog from '@/features/proposers/components/DeleteProposerDialog'
import EditProposerDialog from '@/features/proposers/components/EditProposerDialog'
import { useHasFeature } from '@/hooks/useChains'
import useProposers from '@/hooks/useProposers'
import AddIcon from '@/public/images/common/add.svg'
import { SETTINGS_EVENTS } from '@/services/analytics'
import { FEATURES } from '@/utils/chains'
import { Box, Button, Grid, Paper, SvgIcon, Typography } from '@mui/material'
import EthHashInfo from '@/components/common/EthHashInfo'
import ExternalLink from '@/components/common/ExternalLink'
Expand All @@ -33,6 +35,7 @@ const headCells = [
const ProposersList = () => {
const [isAddDialogOpen, setIsAddDialogOpen] = useState<boolean>()
const proposers = useProposers()
const isEnabled = useHasFeature(FEATURES.PROPOSERS)

const rows = useMemo(() => {
if (!proposers.data) return []
Expand Down Expand Up @@ -60,7 +63,7 @@ const ProposersList = () => {
actions: {
rawValue: '',
sticky: true,
content: (
content: isEnabled && (
<div className={tableCss.actions}>
<EditProposerDialog proposer={proposer} />
<DeleteProposerDialog proposer={proposer} />
Expand Down Expand Up @@ -95,24 +98,26 @@ const ProposersList = () => {
transactions first. <ExternalLink href={HelpCenterArticle.DELEGATES}>Learn more</ExternalLink>
</Typography>

<Box mb={2}>
<CheckWallet allowProposer={false}>
{(isOk) => (
<Track {...SETTINGS_EVENTS.PROPOSERS.ADD_PROPOSER}>
<Button
data-testid="add-proposer-btn"
onClick={onAdd}
variant="text"
startIcon={<SvgIcon component={AddIcon} inheritViewBox fontSize="small" />}
disabled={!isOk}
size="compact"
>
Add proposer
</Button>
</Track>
)}
</CheckWallet>
</Box>
{isEnabled && (
<Box mb={2}>
<CheckWallet allowProposer={false}>
{(isOk) => (
<Track {...SETTINGS_EVENTS.PROPOSERS.ADD_PROPOSER}>
<Button
data-testid="add-proposer-btn"
onClick={onAdd}
variant="text"
startIcon={<SvgIcon component={AddIcon} inheritViewBox fontSize="small" />}
disabled={!isOk}
size="compact"
>
Add proposer
</Button>
</Track>
)}
</CheckWallet>
</Box>
)}

{rows.length > 0 && <EnhancedTable rows={rows} headCells={headCells} />}
</Grid>
Expand Down
1 change: 1 addition & 0 deletions src/utils/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export enum FEATURES {
STAKING_BANNER = 'STAKING_BANNER',
MULTI_CHAIN_SAFE_CREATION = 'MULTI_CHAIN_SAFE_CREATION',
MULTI_CHAIN_SAFE_ADD_NETWORK = 'MULTI_CHAIN_SAFE_ADD_NETWORK',
PROPOSERS = 'PROPOSERS',
}

export const FeatureRoutes = {
Expand Down

0 comments on commit a37cc0c

Please sign in to comment.