Skip to content

Commit

Permalink
feat: Add link to pending transaction alert
Browse files Browse the repository at this point in the history
  • Loading branch information
pedronfigueiredo committed Nov 29, 2024
1 parent 7d252e9 commit 0120ce4
Show file tree
Hide file tree
Showing 20 changed files with 57 additions and 64 deletions.
3 changes: 0 additions & 3 deletions app/_locales/de/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions app/_locales/el/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions app/_locales/en/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions app/_locales/en_GB/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions app/_locales/es/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions app/_locales/fr/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions app/_locales/hi/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions app/_locales/id/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions app/_locales/ja/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions app/_locales/ko/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions app/_locales/pt/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions app/_locales/ru/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions app/_locales/tl/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions app/_locales/tr/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions app/_locales/vi/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions app/_locales/zh_CN/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 10 additions & 6 deletions ui/components/app/alert-system/alert-modal/alert-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,16 @@ function AlertDetails({
>
{customDetails ?? (
<Box>
<Text
variant={TextVariant.bodyMd}
data-testid="alert-modal__selected-alert"
>
{selectedAlert.message}
</Text>
{typeof selectedAlert.message === 'string' ? (
<Text
variant={TextVariant.bodyMd}
data-testid="alert-modal__selected-alert"
>
{selectedAlert.message}
</Text>
) : (
selectedAlert.message
)}
{selectedAlert.alertDetails?.length ? (
<Text variant={TextVariant.bodyMdBold} marginTop={1}>
{t('alertModalDetails')}
Expand Down
3 changes: 2 additions & 1 deletion ui/ducks/confirm-alerts/confirm-alerts.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ReactNode } from 'react';
import { SecurityProvider } from '../../../shared/constants/security-provider';
import { Severity } from '../../helpers/constants/design-system';

Expand Down Expand Up @@ -36,7 +37,7 @@ export type Alert = {
/**
* The message is a summary of the alert details.
*/
message: string;
message: string | ReactNode;

/**
* The security provider associated with the alert.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from 'react';
import { Text } from '../../../../../components/component-library';
import { TextVariant } from '../../../../../helpers/constants/design-system';
import { useI18nContext } from '../../../../../hooks/useI18nContext';
import ZENDESK_URLS from '../../../../../helpers/constants/zendesk-url';

export const PendingTransactionAlertMessage = () => {
const t = useI18nContext();

return (
<Text
variant={TextVariant.bodyMd}
data-testid="alert-modal__selected-alert"
>
{t('pendingTransactionAlertMessage', [
<a
href={ZENDESK_URLS.SPEEDUP_CANCEL}
key="link"
target="_blank"
rel="noreferrer noopener"
>
{t('pendingTransactionAlertMessageHyperlink')}
</a>,
])}
</Text>
);
};
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { TransactionMeta } from '@metamask/transaction-controller';
import { useMemo } from 'react';
import { useSelector } from 'react-redux';

import { submittedPendingTransactionsSelector } from '../../../../../selectors';
import { useI18nContext } from '../../../../../hooks/useI18nContext';
import { isCorrectDeveloperTransactionType } from '../../../../../../shared/lib/confirmation.utils';
import { RowAlertKey } from '../../../../../components/app/confirm/info/row/constants';
import { Alert } from '../../../../../ducks/confirm-alerts/confirm-alerts';
import { Severity } from '../../../../../helpers/constants/design-system';
import { RowAlertKey } from '../../../../../components/app/confirm/info/row/constants';
import { useI18nContext } from '../../../../../hooks/useI18nContext';
import { submittedPendingTransactionsSelector } from '../../../../../selectors';
import { useConfirmContext } from '../../../context/confirm';
import { isCorrectDeveloperTransactionType } from '../../../../../../shared/lib/confirmation.utils';
import { PendingTransactionAlertMessage } from './PendingTransactionAlertMessage';

export function usePendingTransactionAlerts(): Alert[] {
const t = useI18nContext();
Expand All @@ -18,8 +18,10 @@ export function usePendingTransactionAlerts(): Alert[] {

const isValidType = isCorrectDeveloperTransactionType(type);

const hasPendingTransactions =
isValidType && Boolean(pendingTransactions.length);
// const hasPendingTransactions =
// isValidType && Boolean(pendingTransactions.length);

const hasPendingTransactions = true;

return useMemo(() => {
if (!hasPendingTransactions) {
Expand All @@ -30,7 +32,7 @@ export function usePendingTransactionAlerts(): Alert[] {
{
field: RowAlertKey.Speed,
key: 'pendingTransactions',
message: t('alertMessagePendingTransactions'),
message: PendingTransactionAlertMessage(),
reason: t('alertReasonPendingTransactions'),
severity: Severity.Warning,
},
Expand Down

0 comments on commit 0120ce4

Please sign in to comment.