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

Feat: Add Do not copy option to address copy modal #3949

Merged
merged 4 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
19 changes: 14 additions & 5 deletions src/components/common/CopyTooltip/ConfirmCopyModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import { type ReactElement, useEffect, type SyntheticEvent } from 'react'
import { trackEvent, TX_LIST_EVENTS } from '@/services/analytics'
import Track from '../Track'

import css from './styles.module.css'

export type ConfirmCopyModalProps = {
open: boolean
onClose: () => void
Expand Down Expand Up @@ -47,11 +49,18 @@ const ConfirmCopyModal = ({ open, onClose, onCopy, children }: ConfirmCopyModalP
<DialogContent>{children}</DialogContent>
<Divider />
<DialogActions sx={{ padding: 3 }}>
<Track {...TX_LIST_EVENTS.COPY_WARNING_PROCEED}>
<Button size="small" variant="outlined" color="primary" onClick={onCopy}>
Proceed and copy
</Button>
</Track>
<Box className={css.dialogActions} gap={1}>
<Track {...TX_LIST_EVENTS.COPY_WARNING_PROCEED}>
<Button size="small" variant="text" color="primary" onClick={onCopy} fullWidth>
Proceed and copy
</Button>
</Track>
<Track {...TX_LIST_EVENTS.COPY_WARNING_CLOSE}>
<Button size="small" variant="contained" color="primary" onClick={onClose} fullWidth>
Do not copy
</Button>
</Track>
</Box>
</DialogActions>
</Dialog>
)
Expand Down
15 changes: 15 additions & 0 deletions src/components/common/CopyTooltip/styles.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.dialogActions {
display: flex;
flex-direction: row;
align-items: center;
}

@media (max-width: 599.95px) {
.dialogActions {
flex-direction: column;
width: 100%;
}
.dialogActions > span {
width: 100%;
}
}
5 changes: 5 additions & 0 deletions src/services/analytics/events/txList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ export const TX_LIST_EVENTS = {
category: TX_LIST_CATEGORY,
event: EventType.CLICK,
},
COPY_WARNING_CLOSE: {
action: 'Do not copy address',
category: TX_LIST_CATEGORY,
event: EventType.CLICK,
},
TOGGLE_UNTRUSTED: {
action: 'Toggle untrusted transactions',
category: TX_LIST_CATEGORY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,6 @@ describe('useSafeWalletProvider', () => {
push: mockPush,
} as unknown as router.NextRouter)

// @ts-expect-error - auto accept prompt
jest.spyOn(window, 'confirm').mockReturnValue(true)

const { result } = renderHook(() => _useTxFlowApi('1', '0x1234567890000000000000000000000000000000'), {
Expand Down
Loading