Skip to content

Commit

Permalink
Address PR review
Browse files Browse the repository at this point in the history
  • Loading branch information
pedronfigueiredo committed Dec 11, 2024
1 parent 08ab36e commit 1b1bf84
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 13 deletions.
5 changes: 2 additions & 3 deletions ui/components/app/alert-system/alert-modal/alert-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,14 @@ function AlertDetails({
>
{customDetails ?? (
<Box>
{typeof selectedAlert.message === 'string' ? (
{Boolean(selectedAlert.content) && selectedAlert.content}
{Boolean(selectedAlert.message) && (
<Text
variant={TextVariant.bodyMd}
data-testid="alert-modal__selected-alert"
>
{selectedAlert.message}
</Text>
) : (
selectedAlert.message
)}
{selectedAlert.alertDetails?.length ? (
<Text variant={TextVariant.bodyMdBold} marginTop={1}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { ReactNode } from 'react';
import React from 'react';
import {
BannerAlert,
Box,
Expand All @@ -21,13 +21,14 @@ import { AlertProvider } from '../alert-provider';
import { AlertSeverity } from '../../../../ducks/confirm-alerts/confirm-alerts';

export type GeneralAlertProps = {
description: string | ReactNode;
description?: string;
details?: React.ReactNode | string[];
onClickSupportLink?: () => void;
provider?: SecurityProvider;
reportUrl?: string;
severity: AlertSeverity;
title?: string;
children?: React.ReactNode;
};

function ReportLink({
Expand Down Expand Up @@ -119,6 +120,7 @@ function GeneralAlert({
description={description}
{...props}
>
{props.children}
<AlertDetails
details={details}
reportUrl={reportUrl}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export interface BannerBaseStyleUtilityProps extends StyleUtilityProps {
/**
* The description is the content area below BannerBase title
*/
description?: string | React.ReactNode;
description?: string;
/**
* Additional props to pass to the `Text` component used for the `description` text
*/
Expand Down
31 changes: 25 additions & 6 deletions ui/ducks/confirm-alerts/confirm-alerts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ export type Alert = {
*/
isBlocking?: boolean;

/**
* The message is a summary of the alert details.
*/
message: string | ReactNode;

/**
* The security provider associated with the alert.
*/
Expand All @@ -58,7 +53,31 @@ export type Alert = {
* URL to report issue.
*/
reportUrl?: string;
};
} & MessageOrContent;

type MessageOrContent =
| {
/**
* The message is a summary of the alert details.
*/
message: string;

/**
* Alert summary components can be used as an alternative to a message.
*/
content?: ReactNode;
}
| {
/**
* The message is a summary of the alert details.
*/
message?: string;

/**
* Alert summary components can be used as an alternative to a message.
*/
content: ReactNode;
};

/**
* Represents the state of confirm alerts in the application.
Expand Down
1 change: 1 addition & 0 deletions ui/pages/confirmations/components/confirm/title/title.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ function ConfirmBannerAlert({ ownerId }: { ownerId: string }) {
provider={alert.provider}
details={alert.alertDetails}
reportUrl={alert.reportUrl}
children={alert.content}
/>
</Box>
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function usePendingTransactionAlerts(): Alert[] {
{
field: RowAlertKey.Speed,
key: 'pendingTransactions',
message: PendingTransactionAlertMessage(),
content: PendingTransactionAlertMessage(),
reason: t('alertReasonPendingTransactions'),
severity: Severity.Warning,
},
Expand Down

0 comments on commit 1b1bf84

Please sign in to comment.