Skip to content
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

Fix: add chain check in Delete Tx modal #4656

Merged
merged 3 commits into from
Dec 18, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 21 additions & 11 deletions src/components/tx-flow/flows/ReplaceTx/DeleteTxModal.tsx
Original file line number Diff line number Diff line change
@@ -27,6 +27,8 @@ import { txDispatch, TxEvent } from '@/services/tx/txEvents'
import { REJECT_TX_EVENTS } from '@/services/analytics/events/reject-tx'
import { trackEvent } from '@/services/analytics'
import { isWalletRejection } from '@/utils/wallets'
import CheckWallet from '@/components/common/CheckWallet'
import ChainSwitcher from '@/components/common/ChainSwitcher'

type DeleteTxModalProps = {
safeTxHash: string
@@ -122,6 +124,10 @@ const InternalDeleteTxModal = ({
related to deleting a transaction off-chain.
</Box>

<Box mt={2}>
<ChainSwitcher />
</Box>

{error && (
<Box mt={2}>
<ErrorMessage error={error}>Error deleting transaction</ErrorMessage>
@@ -136,17 +142,21 @@ const InternalDeleteTxModal = ({
Keep it
</Button>

<Button
data-testid="delete-tx-btn"
size="small"
variant="contained"
color="primary"
onClick={onConfirm}
disabled={isLoading}
sx={{ minWidth: '122px', minHeight: '36px' }}
>
{isLoading ? <CircularProgress size={20} /> : 'Yes, delete'}
</Button>
<CheckWallet checkNetwork>
{(isOk) => (
<Button
data-testid="delete-tx-btn"
size="small"
variant="contained"
color="primary"
onClick={onConfirm}
disabled={!isOk || isLoading}
sx={{ minWidth: '122px', minHeight: '36px' }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we extend this component to avoid "inline" styles?

>
{isLoading ? <CircularProgress size={20} /> : 'Yes, delete'}
</Button>
)}
</CheckWallet>
</DialogActions>
</Dialog>
)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Avoid inline styles like sx={{ minWidth: '122px', minHeight: '36px' }}. Use styled-components or a CSS class for maintainability.
  2. Consider extracting the <CheckWallet> rendering logic from the component to adhere to the Single Responsibility Principle by separating business logic from UI presentation.

2 changes: 1 addition & 1 deletion src/components/tx-flow/flows/ReplaceTx/index.tsx
Original file line number Diff line number Diff line change
@@ -79,7 +79,7 @@ const DeleteTxButton = ({
<Tooltip
arrow
placement="top"
title={isDeletable ? '' : 'You can only delete the last transaction in the queue or duplicates'}
title={isDeletable ? '' : 'You can only delete the last transaction in the queue, or a duplicate transaction.'}
>
<span style={{ width: '100%' }}>
<Track {...REJECT_TX_EVENTS.DELETE_OFFCHAIN_BUTTON} as="div">

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider extracting the inline style for the <span> to a CSS class to enhance readability and maintainability. This aligns with best practices to avoid inline styles and keeps styles centralized.