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

fix: addressing feedbacks in typed sign alerts #25163

Merged
merged 6 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
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.

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
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', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't it the case to update the description to something like: renders the confirm button when there is one unconfirmed alert?

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