fix: add back cancel button in token safety for swap (#4527)

* add back cancel button in token safety for swap

* also add to swap flow
This commit is contained in:
lynn 2022-08-29 13:08:30 -04:00 committed by GitHub
parent a177829976
commit 4b82838f80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 3 deletions

@ -126,6 +126,7 @@ export default memo(function CurrencySearchModal({
tokenAddress={warningToken.address} tokenAddress={warningToken.address}
onContinue={() => handleCurrencySelect(warningToken)} onContinue={() => handleCurrencySelect(warningToken)}
onCancel={() => setModalView(CurrencyModalView.search)} onCancel={() => setModalView(CurrencyModalView.search)}
showCancel={true}
/> />
) )
} }

@ -7,6 +7,7 @@ interface TokenSafetyModalProps {
secondTokenAddress?: string secondTokenAddress?: string
onContinue: () => void onContinue: () => void
onCancel: () => void onCancel: () => void
showCancel?: boolean
} }
export default function TokenSafetyModal({ export default function TokenSafetyModal({
@ -15,6 +16,7 @@ export default function TokenSafetyModal({
secondTokenAddress, secondTokenAddress,
onContinue, onContinue,
onCancel, onCancel,
showCancel,
}: TokenSafetyModalProps) { }: TokenSafetyModalProps) {
return ( return (
<Modal isOpen={isOpen} onDismiss={onCancel}> <Modal isOpen={isOpen} onDismiss={onCancel}>
@ -23,6 +25,7 @@ export default function TokenSafetyModal({
secondTokenAddress={secondTokenAddress} secondTokenAddress={secondTokenAddress}
onCancel={onCancel} onCancel={onCancel}
onContinue={onContinue} onContinue={onContinue}
showCancel={showCancel}
/> />
</Modal> </Modal>
) )

@ -10,7 +10,7 @@ import { ExternalLink as LinkIconFeather } from 'react-feather'
import { Text } from 'rebass' import { Text } from 'rebass'
import { useAddUserToken } from 'state/user/hooks' import { useAddUserToken } from 'state/user/hooks'
import styled from 'styled-components/macro' import styled from 'styled-components/macro'
import { CopyLinkIcon, ExternalLink } from 'theme' import { ButtonText, CopyLinkIcon, ExternalLink } from 'theme'
import { ExplorerDataType, getExplorerLink } from 'utils/getExplorerLink' import { ExplorerDataType, getExplorerLink } from 'utils/getExplorerLink'
const Wrapper = styled.div` const Wrapper = styled.div`
@ -51,6 +51,13 @@ const StyledButton = styled(ButtonPrimary)`
font-weight: 600; font-weight: 600;
` `
const StyledCancelButton = styled(ButtonText)`
margin-top: 16px;
color: ${({ theme }) => theme.textSecondary};
font-weight: 600;
font-size: 14px;
`
const StyledCloseButton = styled(StyledButton)` const StyledCloseButton = styled(StyledButton)`
background-color: ${({ theme }) => theme.backgroundInteractive}; background-color: ${({ theme }) => theme.backgroundInteractive};
color: ${({ theme }) => theme.textPrimary}; color: ${({ theme }) => theme.textPrimary};
@ -66,16 +73,19 @@ const Buttons = ({
warning, warning,
onContinue, onContinue,
onCancel, onCancel,
showCancel,
}: { }: {
warning: Warning warning: Warning
onContinue: () => void onContinue: () => void
onCancel: () => void onCancel: () => void
showCancel?: boolean
}) => { }) => {
return warning.canProceed ? ( return warning.canProceed ? (
<> <>
<StyledButton onClick={onContinue}> <StyledButton onClick={onContinue}>
<Trans>I understand</Trans> <Trans>I understand</Trans>
</StyledButton> </StyledButton>
{showCancel && <StyledCancelButton onClick={onCancel}>Cancel</StyledCancelButton>}
</> </>
) : ( ) : (
<StyledCloseButton onClick={onCancel}> <StyledCloseButton onClick={onCancel}>
@ -179,9 +189,16 @@ interface TokenSafetyProps {
secondTokenAddress?: string secondTokenAddress?: string
onContinue: () => void onContinue: () => void
onCancel: () => void onCancel: () => void
showCancel?: boolean
} }
export default function TokenSafety({ tokenAddress, secondTokenAddress, onContinue, onCancel }: TokenSafetyProps) { export default function TokenSafety({
tokenAddress,
secondTokenAddress,
onContinue,
onCancel,
showCancel,
}: TokenSafetyProps) {
const logos = [] const logos = []
const urls = [] const urls = []
@ -244,7 +261,7 @@ export default function TokenSafety({ tokenAddress, secondTokenAddress, onContin
</InfoText> </InfoText>
</ShortColumn> </ShortColumn>
<LinkColumn>{urls}</LinkColumn> <LinkColumn>{urls}</LinkColumn>
<Buttons warning={displayWarning} onContinue={acknowledge} onCancel={onCancel} /> <Buttons warning={displayWarning} onContinue={acknowledge} onCancel={onCancel} showCancel={showCancel} />
</Container> </Container>
</Wrapper> </Wrapper>
) )

@ -516,6 +516,7 @@ export default function Swap() {
secondTokenAddress={importTokensNotInDefault[1]?.address} secondTokenAddress={importTokensNotInDefault[1]?.address}
onContinue={handleConfirmTokenWarning} onContinue={handleConfirmTokenWarning}
onCancel={handleDismissTokenWarning} onCancel={handleDismissTokenWarning}
showCancel={true}
/> />
) : ( ) : (
<TokenWarningModal <TokenWarningModal