warning for deprecated Rinkeby, Ropsten and Kovan test networks (#15725)
* warning for deprecated Rinkeby, Ropsten and Kovan test networks * modified DeprecatedTestNetworks function * added getCompletedOnboarding * removed warning message from MetaMask Notification page * updated deprecatedTestNetworksMsgfeature/default_network_editable
parent
bc0d32de56
commit
64391d346e
@ -0,0 +1,82 @@ |
||||
import React, { useEffect, useState } from 'react'; |
||||
import { useSelector } from 'react-redux'; |
||||
import Button from '../button'; |
||||
import { useI18nContext } from '../../../hooks/useI18nContext'; |
||||
import { |
||||
DISPLAY, |
||||
JUSTIFY_CONTENT, |
||||
TYPOGRAPHY, |
||||
COLORS, |
||||
} from '../../../helpers/constants/design-system'; |
||||
import Box from '../box/box'; |
||||
import Typography from '../typography/typography'; |
||||
import ActionableMessage from '../actionable-message/actionable-message'; |
||||
import { getCurrentChainId } from '../../../selectors'; |
||||
import { getCompletedOnboarding } from '../../../ducks/metamask/metamask'; |
||||
|
||||
export default function DeprecatedTestNetworks() { |
||||
const currentChainID = useSelector(getCurrentChainId); |
||||
const [isShowingWarning, setIsShowingWarning] = useState(false); |
||||
const completedOnboarding = useSelector(getCompletedOnboarding); |
||||
const t = useI18nContext(); |
||||
|
||||
useEffect(() => { |
||||
if ( |
||||
completedOnboarding && |
||||
(currentChainID === '0x3' || |
||||
currentChainID === '0x2a' || |
||||
currentChainID === '0x4') |
||||
) { |
||||
setIsShowingWarning(true); |
||||
} else { |
||||
setIsShowingWarning(false); |
||||
} |
||||
}, [currentChainID, completedOnboarding]); |
||||
|
||||
return ( |
||||
isShowingWarning && ( |
||||
<ActionableMessage |
||||
type="warning" |
||||
className="deprecated-test-networks" |
||||
withRightButton |
||||
message={ |
||||
<Box |
||||
display={DISPLAY.FLEX} |
||||
className="deprecated-test-networks__content" |
||||
> |
||||
<Box marginRight={2} color={COLORS.WARNING_DEFAULT}> |
||||
<i className="fa fa-info-circle deprecated-test-networks__content__icon" /> |
||||
</Box> |
||||
<Box justifyContent={JUSTIFY_CONTENT.SPACE_BETWEEN}> |
||||
<Typography |
||||
variant={TYPOGRAPHY.H7} |
||||
marginTop={0} |
||||
marginBottom={0} |
||||
> |
||||
{t('deprecatedTestNetworksMsg')} |
||||
|
||||
<Button |
||||
className="deprecated-test-networks__content__inline-link" |
||||
type="link" |
||||
target="_blank" |
||||
href="https://blog.ethereum.org/2022/06/21/testnet-deprecation/" |
||||
> |
||||
{' '} |
||||
{t('deprecatedTestNetworksLink')} |
||||
</Button> |
||||
</Typography> |
||||
|
||||
<Box |
||||
className="deprecated-test-networks__content__close" |
||||
marginLeft={2} |
||||
marginTop={0} |
||||
color={COLORS.ICON_ALTERNATIVE} |
||||
onClick={() => setIsShowingWarning(false)} |
||||
/> |
||||
</Box> |
||||
</Box> |
||||
} |
||||
/> |
||||
) |
||||
); |
||||
} |
@ -0,0 +1,11 @@ |
||||
import React from 'react'; |
||||
import DeprecatedTestNetworks from './deprecated-test-networks'; |
||||
|
||||
export default { |
||||
title: 'Components/UI/DeprecatedTestNetworks', |
||||
id: __filename, |
||||
}; |
||||
|
||||
export const DefaultStory = () => <DeprecatedTestNetworks />; |
||||
|
||||
DefaultStory.storyName = 'Default'; |
@ -0,0 +1 @@ |
||||
export { default } from './deprecated-test-networks'; |
@ -0,0 +1,25 @@ |
||||
.deprecated-test-networks { |
||||
position: fixed; |
||||
bottom: 0; |
||||
margin: 8px; |
||||
z-index: 1050; |
||||
|
||||
&__content { |
||||
&__icon { |
||||
font-size: 16px; |
||||
} |
||||
|
||||
&__inline-link { |
||||
@include H7; |
||||
|
||||
display: initial; |
||||
padding: 0; |
||||
} |
||||
|
||||
&__close::after { |
||||
content: '\00D7'; |
||||
font-size: 24px; |
||||
cursor: pointer; |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue