Skip to content

Commit

Permalink
fix: show unavailable networks when replaying Safes (#4197)
Browse files Browse the repository at this point in the history
  • Loading branch information
schmanu authored Sep 18, 2024
1 parent 1db148e commit 938d524
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
17 changes: 11 additions & 6 deletions src/components/common/NetworkInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,24 @@ const NetworkInput = ({
}: {
name: string
required?: boolean
chainConfigs: ChainInfo[]
chainConfigs: (ChainInfo & { available: boolean })[]
}): ReactElement => {
const isDarkMode = useDarkMode()
const theme = useTheme()
const [testNets, prodNets] = useMemo(() => partition(chainConfigs, (config) => config.isTestnet), [chainConfigs])
const { control } = useFormContext() || {}

const renderMenuItem = useCallback(
(chainId: string, isSelected: boolean) => {
(chainId: string, isDisabled: boolean) => {
const chain = chainConfigs.find((chain) => chain.chainId === chainId)
if (!chain) return null
return (
<MenuItem key={chainId} value={chainId} sx={{ '&:hover': { backgroundColor: 'inherit' } }}>
<MenuItem
disabled={isDisabled}
key={chainId}
value={chainId}
sx={{ '&:hover': { backgroundColor: 'inherit' } }}
>
<ChainIndicator chainId={chain.chainId} />
</MenuItem>
)
Expand All @@ -51,7 +56,7 @@ const NetworkInput = ({
fullWidth
label="Network"
IconComponent={ExpandMoreIcon}
renderValue={(value) => renderMenuItem(value, true)}
renderValue={(value) => renderMenuItem(value, false)}
MenuProps={{
sx: {
'& .MuiPaper-root': {
Expand All @@ -67,11 +72,11 @@ const NetworkInput = ({
},
}}
>
{prodNets.map((chain) => renderMenuItem(chain.chainId, false))}
{prodNets.map((chain) => renderMenuItem(chain.chainId, !chain.available))}

{testNets.length > 0 && <ListSubheader className={css.listSubHeader}>Testnets</ListSubheader>}

{testNets.map((chain) => renderMenuItem(chain.chainId, false))}
{testNets.map((chain) => renderMenuItem(chain.chainId, !chain.available))}
</Select>
</FormControl>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ const ReplaySafeDialog = ({
const submitDisabled =
isUnsupportedSafeCreationVersion || !!safeCreationDataError || safeCreationDataLoading || !formState.isValid

const noChainsAvailable = !chain && safeCreationData && replayableChains && replayableChains.length === 0
const noChainsAvailable =
!chain && safeCreationData && replayableChains && replayableChains.filter((chain) => chain.available).length === 0

return (
<Dialog open={open} onClose={onClose} onClick={(e) => e.stopPropagation()}>
Expand Down

0 comments on commit 938d524

Please sign in to comment.