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

[PM-13876] replace angular validation with html constraints validation #11816

Merged
merged 19 commits into from
Nov 6, 2024

Conversation

audreyality
Copy link
Contributor

@audreyality audreyality commented Oct 31, 2024

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-13876

📔 Objective

Improve the UX of credential generator validation logic by removing validation.

🕵🏻 What to expect

  • If you are typing into a spinbox or text field the generator doesn't update until the value is committed (HTML "change" event). You can commit the value by pressing [enter] or tabbing out of the field.
  • If you are interacting with a checkbox, the generator updates immediately.
  • If you click generate, the generator updates immediately.

In all of the above cases, the generator automatically saves and, if necessary, applies policy to the settings. For field edits:

  • Out-of-bound numbers return to their closest bound.
  • Missing numbers (e.g. an empty field) returns to the application default.
  • Strings that are too long are truncated to their maximum length.

Clicking the generator button has undefined behavior when the settings are incorrect. It may correct the setting, as above, or it may load the settings before your edit.

This branch also fixes the janky behavior of a few settings that validation wasn't handling well:

  • The generate and copy buttons are now disabled when there's no algorithm to run (e.g. when you have not selected a forwarder).
  • "Catchall" now populates the domain from the active user's email address.
  • "Plus address" now populates the email from the active user's email address.

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

@audreyality audreyality added the hold do not merge, do not approve yet label Oct 31, 2024
@audreyality audreyality requested a review from a team as a code owner October 31, 2024 20:35
Copy link

codecov bot commented Oct 31, 2024

Codecov Report

Attention: Patch coverage is 30.35714% with 39 lines in your changes missing coverage. Please review.

Project coverage is 33.51%. Comparing base (bb79fdb) to head (c356c7a).
Report is 48 commits behind head on main.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...enerator/core/src/policies/catchall-constraints.ts 12.50% 14 Missing ⚠️
...erator/core/src/policies/subaddress-constraints.ts 8.33% 11 Missing ⚠️
libs/tools/generator/core/src/data/generators.ts 37.50% 10 Missing ⚠️
libs/common/src/tools/state/user-state-subject.ts 33.33% 0 Missing and 2 partials ⚠️
.../core/src/services/credential-generator.service.ts 85.71% 1 Missing ⚠️
...ols/send/send-ui/src/send-form/send-form.module.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #11816      +/-   ##
==========================================
- Coverage   33.53%   33.51%   -0.02%     
==========================================
  Files        2814     2817       +3     
  Lines       87475    87602     +127     
  Branches    16676    16698      +22     
==========================================
+ Hits        29332    29361      +29     
- Misses      55836    55931      +95     
- Partials     2307     2310       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@audreyality audreyality marked this pull request as draft November 1, 2024 17:20
@audreyality audreyality removed the hold do not merge, do not approve yet label Nov 1, 2024
@audreyality audreyality marked this pull request as ready for review November 1, 2024 18:20
Comment on lines +15 to +19
/** Splits an email into a username, subaddress, and domain named group.
* Subaddress is optional.
*/
export const DOMAIN_PARSER = new RegExp("[^@]+@(?<domain>.+)");

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ I don't see this being used anywhere. Possibly a relict before moving it to catchall-constraints.ts.

></button>
</div>
</bit-card>
<tools-password-settings
#passwordSettings
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️⛏️ The usage of viewChild got introduced with dd23ce0 but got removed with e02e08c, so there's no need to keep the reference within the markup.

This applies to credential-generator.component.html, password-generator.component.html and username-generator.component.html

Copy link
Contributor

@djsmith85 djsmith85 left a comment

Choose a reason for hiding this comment

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

Approving this, so we can merge and let QA start testing. The nits I mentioned will be addressed in a follow-up PR by me, which @audreyality can review.

@djsmith85 djsmith85 merged commit 414bdde into main Nov 6, 2024
66 of 67 checks passed
@djsmith85 djsmith85 deleted the tools/PM-13876/remove-validation branch November 6, 2024 16:54
jaasen-livefront pushed a commit that referenced this pull request Nov 7, 2024
#11816)

* rough-in passphrase validation failure handling

* trigger valid change from settings

* fix `max` constraint enforcement

* add taps for generator validation monitoring/debugging

* HTML constraints validation rises like a phoenix

* remove min/max boundaries to fix chrome display issue

* bind settings components as view children of options components

* remove defunct `okSettings$`

* extend validationless generator to passwords

* extend validationless generator to catchall emails

* extend validationless generator to forwarder emails

* extend validationless generator to subaddress emails

* extend validationless generator to usernames

* fix observable cycle

* disable generate button when no algorithm is selected

* prevent duplicate algorithm emissions

* add constraints that assign email address defaults
jaasen-livefront pushed a commit that referenced this pull request Nov 7, 2024
#11816)

* rough-in passphrase validation failure handling

* trigger valid change from settings

* fix `max` constraint enforcement

* add taps for generator validation monitoring/debugging

* HTML constraints validation rises like a phoenix

* remove min/max boundaries to fix chrome display issue

* bind settings components as view children of options components

* remove defunct `okSettings$`

* extend validationless generator to passwords

* extend validationless generator to catchall emails

* extend validationless generator to forwarder emails

* extend validationless generator to subaddress emails

* extend validationless generator to usernames

* fix observable cycle

* disable generate button when no algorithm is selected

* prevent duplicate algorithm emissions

* add constraints that assign email address defaults
jaasen-livefront pushed a commit that referenced this pull request Nov 7, 2024
#11816)

* rough-in passphrase validation failure handling

* trigger valid change from settings

* fix `max` constraint enforcement

* add taps for generator validation monitoring/debugging

* HTML constraints validation rises like a phoenix

* remove min/max boundaries to fix chrome display issue

* bind settings components as view children of options components

* remove defunct `okSettings$`

* extend validationless generator to passwords

* extend validationless generator to catchall emails

* extend validationless generator to forwarder emails

* extend validationless generator to subaddress emails

* extend validationless generator to usernames

* fix observable cycle

* disable generate button when no algorithm is selected

* prevent duplicate algorithm emissions

* add constraints that assign email address defaults
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants