Skip to content

Commit 09b4c80

Browse files
feat: Add link to pending transaction alert (#28721)
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** This PR substitutes a purely text based alert for pending transactions with one that includes a hyperlink to the docs. <!-- Write a short description of the changes included in this pull request, also include relevant motivation and context. Have in mind the following questions: 1. What is the reason for the change? 2. What is the improvement/solution? --> [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28721?quickstart=1) ## **Related issues** Fixes: #28308 ## **Manual testing steps** 1. Go to this page... 2. 3. ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ![Screenshot 2024-12-02 at 11 13 58](https://github.com/user-attachments/assets/146b353d-a515-40db-95cd-5e091700cf18) ## **Pre-merge author checklist** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.
1 parent b8f6ba7 commit 09b4c80

File tree

25 files changed

+141
-77
lines changed

25 files changed

+141
-77
lines changed

app/_locales/de/messages.json

-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/_locales/el/messages.json

-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/_locales/en/messages.json

+9-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/_locales/en_GB/messages.json

-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/_locales/es/messages.json

-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/_locales/fr/messages.json

-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/_locales/hi/messages.json

-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/_locales/id/messages.json

-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/_locales/ja/messages.json

-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/_locales/ko/messages.json

-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/_locales/pt/messages.json

-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/_locales/ru/messages.json

-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/_locales/tl/messages.json

-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/_locales/tr/messages.json

-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/_locales/vi/messages.json

-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/_locales/zh_CN/messages.json

-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jest.integration.config.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ module.exports = {
2525
setupFilesAfterEnv: ['<rootDir>/test/integration/config/setupAfter.js'],
2626
testMatch: ['<rootDir>/test/integration/**/*.test.(js|ts|tsx)'],
2727
testPathIgnorePatterns: ['<rootDir>/test/integration/config/*'],
28-
// This was increased from 5500 to 10000 to when lazy loading was introduced
29-
testTimeout: 10000,
28+
testTimeout: 15000,
3029
// We have to specify the environment we are running in, which is jsdom. The
3130
// default is 'node'. This can be modified *per file* using a comment at the
3231
// head of the file. So it may be worthwhile to switch to 'node' in any

test/integration/confirmations/transactions/alerts.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ describe('Contract Interaction Confirmation Alerts', () => {
362362
expect(
363363
await screen.findByTestId('alert-modal__selected-alert'),
364364
).toHaveTextContent(
365-
'This transaction wont go through until a previous transaction is complete. Learn how to cancel or speed up a transaction.',
365+
"This transaction won't go through until a previous transaction is complete. Learn how to cancel or speed up a transaction.",
366366
);
367367
});
368368

ui/components/app/alert-system/alert-modal/alert-modal.tsx

+9-6
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,15 @@ function AlertDetails({
164164
>
165165
{customDetails ?? (
166166
<Box>
167-
<Text
168-
variant={TextVariant.bodyMd}
169-
data-testid="alert-modal__selected-alert"
170-
>
171-
{selectedAlert.message}
172-
</Text>
167+
{Boolean(selectedAlert.content) && selectedAlert.content}
168+
{Boolean(selectedAlert.message) && (
169+
<Text
170+
variant={TextVariant.bodyMd}
171+
data-testid="alert-modal__selected-alert"
172+
>
173+
{selectedAlert.message}
174+
</Text>
175+
)}
173176
{selectedAlert.alertDetails?.length ? (
174177
<Text variant={TextVariant.bodyMdBold} marginTop={1}>
175178
{t('alertModalDetails')}

ui/components/app/alert-system/general-alert/general-alert.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@ import { AlertProvider } from '../alert-provider';
2121
import { AlertSeverity } from '../../../../ducks/confirm-alerts/confirm-alerts';
2222

2323
export type GeneralAlertProps = {
24-
description: string;
24+
description?: string;
2525
details?: React.ReactNode | string[];
2626
onClickSupportLink?: () => void;
2727
provider?: SecurityProvider;
2828
reportUrl?: string;
2929
severity: AlertSeverity;
3030
title?: string;
31+
children?: React.ReactNode;
3132
};
3233

3334
function ReportLink({
@@ -119,6 +120,7 @@ function GeneralAlert({
119120
description={description}
120121
{...props}
121122
>
123+
{props.children}
122124
<AlertDetails
123125
details={details}
124126
reportUrl={reportUrl}

ui/ducks/confirm-alerts/confirm-alerts.ts

+26-6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { ReactNode } from 'react';
12
import { SecurityProvider } from '../../../shared/constants/security-provider';
23
import { Severity } from '../../helpers/constants/design-system';
34

@@ -33,11 +34,6 @@ export type Alert = {
3334
*/
3435
isBlocking?: boolean;
3536

36-
/**
37-
* The message is a summary of the alert details.
38-
*/
39-
message: string;
40-
4137
/**
4238
* The security provider associated with the alert.
4339
*/
@@ -57,7 +53,31 @@ export type Alert = {
5753
* URL to report issue.
5854
*/
5955
reportUrl?: string;
60-
};
56+
} & MessageOrContent;
57+
58+
type MessageOrContent =
59+
| {
60+
/**
61+
* The message is a summary of the alert details.
62+
*/
63+
message: string;
64+
65+
/**
66+
* Alert summary components can be used as an alternative to a message.
67+
*/
68+
content?: ReactNode;
69+
}
70+
| {
71+
/**
72+
* The message is a summary of the alert details.
73+
*/
74+
message?: string;
75+
76+
/**
77+
* Alert summary components can be used as an alternative to a message.
78+
*/
79+
content: ReactNode;
80+
};
6181

6282
/**
6383
* Represents the state of confirm alerts in the application.

ui/pages/confirmations/components/confirm/title/title.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ function ConfirmBannerAlert({ ownerId }: { ownerId: string }) {
4343
provider={alert.provider}
4444
details={alert.alertDetails}
4545
reportUrl={alert.reportUrl}
46+
children={alert.content}
4647
/>
4748
</Box>
4849
))}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import React from 'react';
2+
import { ButtonLink, Text } from '../../../../../components/component-library';
3+
import {
4+
TextColor,
5+
TextVariant,
6+
} from '../../../../../helpers/constants/design-system';
7+
import ZENDESK_URLS from '../../../../../helpers/constants/zendesk-url';
8+
import { useI18nContext } from '../../../../../hooks/useI18nContext';
9+
10+
export const PendingTransactionAlertMessage = () => {
11+
const t = useI18nContext();
12+
13+
return (
14+
<Text
15+
variant={TextVariant.bodyMd}
16+
color={TextColor.textDefault}
17+
data-testid="alert-modal__selected-alert"
18+
>
19+
{t('pendingTransactionAlertMessage', [
20+
<ButtonLink
21+
href={ZENDESK_URLS.SPEEDUP_CANCEL}
22+
key="link"
23+
target="_blank"
24+
rel="noreferrer noopener"
25+
color={TextColor.primaryDefault}
26+
>
27+
{t('pendingTransactionAlertMessageHyperlink')}
28+
</ButtonLink>,
29+
])}
30+
</Text>
31+
);
32+
};

0 commit comments

Comments
 (0)