Skip to content

Commit

Permalink
fix: addressing feedbacks in typed sign alerts (#25163)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpuri authored Jun 11, 2024
1 parent c81284f commit 1be8a26
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/_locales/en/messages.json

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

6 changes: 5 additions & 1 deletion ui/components/app/alert-system/alert-modal/alert-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,11 @@ function AlertHeader({

function BlockaidAlertDetails() {
const t = useI18nContext();
return <Text textAlign={TextAlign.Center}>{t('blockaidAlertInfo')}</Text>;
return (
<Text textAlign={TextAlign.Center} variant={TextVariant.bodyMd}>
{t('blockaidAlertInfo')}
</Text>
);
}

function AlertDetails({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { DisclosureVariant } from '../../../ui/disclosure/disclosure.constants';
import { useI18nContext } from '../../../../hooks/useI18nContext';
import {
Display,
FontWeight,
TextVariant,
} from '../../../../helpers/constants/design-system';
import { SecurityProvider } from '../../../../../shared/constants/security-provider';
Expand Down Expand Up @@ -79,7 +80,12 @@ function AlertDetails({
<Box as="ul" className={'alert-modal__alert-details'} paddingLeft={6}>
{details.map((detail, index) => (
<Box as="li" key={`disclosure-detail-${index}`}>
<Text variant={TextVariant.bodySm}>{detail}</Text>
<Text
variant={TextVariant.bodyMdMedium}
fontWeight={FontWeight.Normal}
>
{detail}
</Text>
</Box>
))}
</Box>
Expand Down
5 changes: 3 additions & 2 deletions ui/hooks/useAlerts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const useAlerts = (ownerId: string) => {
!isAlertConfirmed(alert.key) && alert.severity === Severity.Danger,
);
const hasAlerts = alerts.length > 0;
const hasDangerAlerts = alerts.some(
const dangerAlerts = alerts.filter(
(alert) => alert.severity === Severity.Danger,
);
const hasUnconfirmedDangerAlerts = unconfirmedDangerAlerts.length > 0;
Expand All @@ -73,7 +73,8 @@ const useAlerts = (ownerId: string) => {
generalAlerts,
getFieldAlerts,
hasAlerts,
hasDangerAlerts,
dangerAlerts,
hasDangerAlerts: dangerAlerts?.length > 0,
hasUnconfirmedDangerAlerts,
isAlertConfirmed,
setAlertConfirmed,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ describe('ConfirmFooter', () => {
};
it('renders the review alerts button when there are unconfirmed alerts', () => {
const { getByText } = render(stateWithAlertsMock);
expect(getByText('Review alerts')).toBeInTheDocument();
expect(getByText('Confirm')).toBeInTheDocument();
});

it('renders the confirm button when there are no unconfirmed alerts', () => {
Expand Down
4 changes: 2 additions & 2 deletions ui/pages/confirmations/components/confirm/footer/footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const ConfirmButton = ({
const [confirmModalVisible, setConfirmModalVisible] =
useState<boolean>(false);

const { alerts, hasDangerAlerts, hasUnconfirmedDangerAlerts } =
const { alerts, dangerAlerts, hasDangerAlerts, hasUnconfirmedDangerAlerts } =
useAlerts(alertOwnerId);

const handleCloseConfirmModal = useCallback(() => {
Expand Down Expand Up @@ -76,7 +76,7 @@ const ConfirmButton = ({
size={ButtonSize.Lg}
disabled={hasUnconfirmedDangerAlerts ? false : disabled}
>
{hasUnconfirmedDangerAlerts ? t('reviewAlerts') : t('confirm')}
{dangerAlerts?.length > 1 ? t('reviewAlerts') : t('confirm')}
</Button>
</>
);
Expand Down

0 comments on commit 1be8a26

Please sign in to comment.