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

feat: Implement alerts for personal sign #24469

Merged
merged 204 commits into from
May 28, 2024

Conversation

vinistevam
Copy link
Contributor

@vinistevam vinistevam commented May 9, 2024

Description

This PR aims to implement alerts for personal sign.

Context
The confirmation supporting the personal sign operation was one of the first confirmations implemented using the new confirmation architecture.

In order to test and demonstrate the use of the new alert system, we can incorporate suitable alerts into the personal sign confirmation.

Changes
Implementation

  • Changed personal-sign.tsx to use the AlertRow component.
  • Created a hook to support custom actions in alerts, PersonalSignAlertActions
  • Created usePersonalSignAlerts to aggregate the alerts from the providers and add those into the new alert system.
  • Created setConfirmationAlerts hook to update and clean alerts based on the current confirmation.
  • Created useConfirmationAlerts hook to integrate the types of confirmations into the new alert system.
  • Included the new SecurityAlertBanner in the title.tsx to render the general alerts coming from the new alert system.

New Banner Alert component

  • Created SecurityAlertBanner to support general alerts coming from a provider. This component was based on the SecurityProviderBannerAlert.
    • Unit tests
    • Storybook

Folder reorganization

  • confirmations/alerts to alerts-system (ui/components/app/ should not have several subfolders)

QA Design feedback

  • Only render in AlertModal only alerts tied to a field, general alerts should be displayed in the banner on top of the confirmation.
  • Hide the acknowledge checkbox for alerts with severity info and warning.
  • Move icon in the AlertModal be in the same level of the navigation and close buttons.
  • Include provider into the AlertModal.

Clean up, team feedback, QA tests and fixes

  • Created an AlertSeverity type to use in the Alert type, also added a provider optional property.
  • Fixed handleCloseModal in the footer.tsx.
  • Extracted to a utility file getBannerAlertSeverity, getProviderAlertSeverity and providerAlertNormalizer functions and added Unit tests.
  • Fixed alert-row when variant is undefined to use primarily the severity from the alert.
  • Fixed handleAcknowledgeClick

Open in GitHub Codespaces

Related issues

Fixes: https://github.com/MetaMask/MetaMask-planning/issues/2412

Manual testing steps

  1. Test regression for signature and personal sign re-designed confirmations.

PRs Related
#23719
#23625
#23664
#24049
#24214
#24400

Screenshots/Recordings

personal-sign-alert-system.webm

Security banner alert
image

Multiple alerts
image

Before

After

Pre-merge author checklist

  • I’ve followed MetaMask Coding Standards.
  • 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 format if applicable
  • I’ve applied the right labels on the PR (see labeling guidelines). 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.

vinistevam and others added 30 commits March 18, 2024 10:35
…al.tsx

Co-authored-by: Matthew Walsh <matthew.walsh@consensys.net>
…al.tsx

Co-authored-by: Matthew Walsh <matthew.walsh@consensys.net>
…al.test.tsx

Co-authored-by: Matthew Walsh <matthew.walsh@consensys.net>
const hasUnconfirmedAlerts = alerts.some(
(alert: Alert) =>
!isAlertConfirmed(alert.key) && alert.severity === Severity.Danger,
);
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be useful to move methods like above to useAlerts so they can be re-used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

100%, I should have done that before. I didn't push it because I saw this improvement in your PR.

}
return highestSeverity;
}, Severity.Info);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Above may be just a forEach will be good.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

/>
</Box>
);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

It will be useful to extract above component into separate file. We try to keep confirmation code lesser number of lines per file and smaller well defined components.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This makes sense, is it ok to extract in a different PR? I'm happy to do it.

jpuri
jpuri previously approved these changes May 24, 2024
Copy link
Contributor

@jpuri jpuri left a comment

Choose a reason for hiding this comment

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

I left some small feedbacks, changes largely look good.

@metamaskbot
Copy link
Collaborator

Builds ready [555e858]
Page Load Metrics (1426 ± 599 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint591861022914
domContentLoaded9351463
load48323714261248599
domInteractive9351463
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 0 Bytes (0.00%)
  • ui: 19.95 KiB (0.29%)
  • common: 196 Bytes (0.00%)

matthewwalsh0
matthewwalsh0 previously approved these changes May 24, 2024
jpuri
jpuri previously approved these changes May 27, 2024
@metamaskbot
Copy link
Collaborator

Builds ready [3e092e3]
Page Load Metrics (788 ± 528 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint631941013316
domContentLoaded96417116
load5127477881100528
domInteractive96417116
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 0 Bytes (0.00%)
  • ui: 19.95 KiB (0.30%)
  • common: 196 Bytes (0.00%)

@vinistevam vinistevam dismissed stale reviews from jpuri and matthewwalsh0 via 6568ea8 May 27, 2024 09:07
@vinistevam vinistevam force-pushed the feat/implement-personal-sign-alerts branch from 6568ea8 to fc35032 Compare May 27, 2024 09:40
@metamaskbot
Copy link
Collaborator

Builds ready [fc35032]
Page Load Metrics (554 ± 470 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint65148892311
domContentLoaded86419178
load512862554979470
domInteractive86419178
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 0 Bytes (0.00%)
  • ui: 19.95 KiB (0.30%)
  • common: 196 Bytes (0.00%)

@metamaskbot
Copy link
Collaborator

Builds ready [05041ce]
Page Load Metrics (414 ± 392 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint6313890199
domContentLoaded84914115
load512469414816392
domInteractive84914115
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 0 Bytes (0.00%)
  • ui: 19.95 KiB (0.30%)
  • common: 196 Bytes (0.00%)

@vinistevam vinistevam merged commit 17de691 into develop May 28, 2024
71 of 72 checks passed
@vinistevam vinistevam deleted the feat/implement-personal-sign-alerts branch May 28, 2024 11:08
@github-actions github-actions bot locked and limited conversation to collaborators May 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
QA Passed release-12.0.0 team-confirmations Push issues to confirmations team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants