-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Part of #17670: Replace Typography with Text component in CancelSpeedupPopover #18638
Changes from 16 commits
1b41e2c
fd959f5
a4b1d55
568a932
e0c6db3
62cc742
2008ada
23b9e6a
23626ad
31992b8
cfc1b49
ac5922e
bc03fb3
e8074f0
73307fd
a6fb0dd
a0f3ea7
bdd3844
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
import { useSelector } from 'react-redux'; | ||
import React, { useEffect } from 'react'; | ||
import { Text } from '../../component-library'; | ||
import { EditGasModes, PriorityLevels } from '../../../../shared/constants/gas'; | ||
import { | ||
AlignItems, | ||
DISPLAY, | ||
FLEX_DIRECTION, | ||
Display, | ||
FlexDirection, | ||
TextVariant, | ||
} from '../../../helpers/constants/design-system'; | ||
import { getAppIsLoading } from '../../../selectors'; | ||
|
@@ -16,10 +15,10 @@ import { useTransactionModalContext } from '../../../contexts/transaction-modal' | |
import EditGasFeeButton from '../edit-gas-fee-button'; | ||
import GasDetailsItem from '../gas-details-item'; | ||
import Box from '../../ui/box'; | ||
import Button from '../../ui/button'; | ||
import InfoTooltip from '../../ui/info-tooltip'; | ||
import Popover from '../../ui/popover'; | ||
import AppLoadingSpinner from '../app-loading-spinner'; | ||
import { Text, Button, ButtonLink } from '../../component-library'; | ||
|
||
const CancelSpeedupPopover = () => { | ||
const { | ||
|
@@ -98,54 +97,51 @@ const CancelSpeedupPopover = () => { | |
<div className="cancel-speedup-popover__wrapper"> | ||
<Text | ||
alignItems={AlignItems.center} | ||
display={DISPLAY.FLEX} | ||
display={Display.Flex} | ||
variant={TextVariant.bodySm} | ||
as="h6" | ||
marginTop={0} | ||
marginBottom={2} | ||
paddingBottom={2} | ||
className="cancel-speedup-popover__description" | ||
> | ||
{t('cancelSpeedUpLabel', [ | ||
<strong key="cancelSpeedupReplace">{t('replace')}</strong>, | ||
<strong key="cancelSpeedupCancel">{t('replace')}</strong>, | ||
])} | ||
<InfoTooltip | ||
position="top" | ||
contentText={ | ||
<Box> | ||
{t('cancelSpeedUpTransactionTooltip', [ | ||
editGasMode === EditGasModes.cancel | ||
? t('cancel') | ||
: t('speedUp'), | ||
])} | ||
<div> | ||
<a | ||
href="https://community.metamask.io/t/how-to-speed-up-or-cancel-transactions-on-metamask/3296" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
{t('learnMoreUpperCase')} | ||
</a> | ||
</div> | ||
</Box> | ||
<> | ||
<Text variant={TextVariant.bodySm}> | ||
{t('cancelSpeedUpTransactionTooltip', [ | ||
editGasMode === EditGasModes.cancel | ||
? t('cancel') | ||
: t('speedUp'), | ||
])} | ||
</Text> | ||
<ButtonLink | ||
variant={TextVariant.bodySm} | ||
href="https://community.metamask.io/t/how-to-speed-up-or-cancel-transactions-on-metamask/3296" | ||
target="_blank" | ||
> | ||
{t('learnMoreUpperCase')} | ||
</ButtonLink> | ||
</> | ||
Comment on lines
+112
to
+127
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the choice to remove the in favor of a fragment related to the issue? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably not particularly related to the issue but could have some minor performance benefits as there are no utility props being used on the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool |
||
} | ||
/> | ||
</Text> | ||
<div className="cancel-speedup-popover__separator" /> | ||
<Box | ||
display={DISPLAY.FLEX} | ||
display={Display.Flex} | ||
alignItems={AlignItems.center} | ||
flexDirection={FLEX_DIRECTION.COLUMN} | ||
marginTop={4} | ||
flexDirection={FlexDirection.Column} | ||
marginTop={2} | ||
> | ||
<Box className="cancel-speedup-popover__edit-gas-button"> | ||
<div className="cancel-speedup-popover__edit-gas-button"> | ||
{!appIsLoading && <EditGasFeeButton />} | ||
</Box> | ||
<Box className="cancel-speedup-popover__gas-details"> | ||
</div> | ||
<div className="cancel-speedup-popover__gas-details"> | ||
<GasDetailsItem /> | ||
</Box> | ||
</div> | ||
</Box> | ||
<Button type="primary" onClick={submitTransactionChange}> | ||
{t('submit')} | ||
</Button> | ||
<Button onClick={submitTransactionChange}>{t('submit')}</Button> | ||
</div> | ||
</Popover> | ||
); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import React from 'react'; | ||
import { Provider } from 'react-redux'; | ||
import BigNumber from 'bignumber.js'; | ||
import configureStore from '../../../store/store'; | ||
import { TransactionModalContext } from '../../../contexts/transaction-modal'; | ||
import mockEstimates from '../../../../test/data/mock-estimates.json'; | ||
import mockState from '../../../../test/data/mock-state.json'; | ||
import { | ||
EditGasModes, | ||
GasEstimateTypes, | ||
} from '../../../../shared/constants/gas'; | ||
import { decGWEIToHexWEI } from '../../../../shared/modules/conversion.utils'; | ||
import { GasFeeContextProvider } from '../../../contexts/gasFee'; | ||
import CancelSpeedupPopover from './cancel-speedup-popover'; | ||
|
||
const store = configureStore({ | ||
metamask: { | ||
...mockState.metamask, | ||
accounts: { | ||
[mockState.metamask.selectedAddress]: { | ||
address: mockState.metamask.selectedAddress, | ||
balance: '0x1F4', | ||
}, | ||
}, | ||
gasFeeEstimates: mockEstimates[GasEstimateTypes.feeMarket].gasFeeEstimates, | ||
}, | ||
}); | ||
|
||
const MOCK_SUGGESTED_MEDIUM_MAXFEEPERGAS_DEC_GWEI = | ||
mockEstimates[GasEstimateTypes.feeMarket].gasFeeEstimates.medium | ||
.suggestedMaxFeePerGas; | ||
|
||
const MOCK_SUGGESTED_MEDIUM_MAXFEEPERGAS_BN_WEI = new BigNumber( | ||
decGWEIToHexWEI(MOCK_SUGGESTED_MEDIUM_MAXFEEPERGAS_DEC_GWEI), | ||
16, | ||
); | ||
|
||
const MOCK_SUGGESTED_MEDIUM_MAXFEEPERGAS_HEX_WEI = | ||
MOCK_SUGGESTED_MEDIUM_MAXFEEPERGAS_BN_WEI.toString(16); | ||
|
||
export default { | ||
title: 'Components/App/CancelSpeedupPopover', | ||
component: CancelSpeedupPopover, | ||
decorators: [ | ||
(story) => ( | ||
<Provider store={store}> | ||
<GasFeeContextProvider | ||
transaction={{ | ||
userFeeLevel: 'tenPercentIncreased', | ||
txParams: { | ||
gas: '0x5208', | ||
maxFeePerGas: MOCK_SUGGESTED_MEDIUM_MAXFEEPERGAS_HEX_WEI, | ||
maxPriorityFeePerGas: '0x59682f00', | ||
}, | ||
}} | ||
editGasMode={EditGasModes.cancel} | ||
> | ||
<TransactionModalContext.Provider | ||
value={{ | ||
closeModal: () => undefined, | ||
currentModal: 'cancelSpeedUpTransaction', | ||
}} | ||
> | ||
{story()} | ||
</TransactionModalContext.Provider> | ||
</GasFeeContextProvider> | ||
</Provider> | ||
), | ||
], | ||
}; | ||
|
||
export const DefaultStory = (args) => { | ||
return ( | ||
<div style={{ width: '600px' }}> | ||
<CancelSpeedupPopover {...args} /> | ||
</div> | ||
); | ||
}; | ||
|
||
DefaultStory.storyName = 'Default'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -125,7 +125,7 @@ describe('CancelSpeedupPopover', () => { | |
it('information tooltip should contain the correct text if editGasMode is cancel', async () => { | ||
await act(async () => render()); | ||
expect( | ||
InfoTooltip.mock.calls[0][0].contentText.props.children[0], | ||
InfoTooltip.mock.calls[0][0].contentText.props.children[0].props.children, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I hate this but don't have time right now to improve the tests for this |
||
).toStrictEqual( | ||
'To Cancel a transaction the gas fee must be increased by at least 10% for it to be recognized by the network.', | ||
); | ||
|
@@ -134,7 +134,7 @@ describe('CancelSpeedupPopover', () => { | |
it('information tooltip should contain the correct text if editGasMode is speedup', async () => { | ||
await act(async () => render({ editGasMode: EditGasModes.speedUp })); | ||
expect( | ||
InfoTooltip.mock.calls[0][0].contentText.props.children[0], | ||
InfoTooltip.mock.calls[0][0].contentText.props.children[0].props.children, | ||
).toStrictEqual( | ||
'To Speed up a transaction the gas fee must be increased by at least 10% for it to be recognized by the network.', | ||
); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question, why was the key changed on this? Also...why is the key needed? This might be a question for @georgewrmarshall
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question! This may have been a mistake. I'll remove it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah right I'm not super familiar with locales but because it's in an array it needs a
key