[WEB-4513] refactor: consolidate password strength meter into shared ui package#7462
Conversation
WalkthroughThis change removes all usages and implementations of the legacy Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant PasswordForm
participant PasswordStrengthIndicator
participant Utils (getPasswordStrength/getPasswordCriteria)
User->>PasswordForm: Types password
PasswordForm->>PasswordStrengthIndicator: Passes password & focus state
PasswordStrengthIndicator->>Utils: getPasswordStrength(password)
Utils-->>PasswordStrengthIndicator: Returns strength enum
PasswordStrengthIndicator->>Utils: getPasswordCriteria(password)
Utils-->>PasswordStrengthIndicator: Returns criteria array
PasswordStrengthIndicator-->>PasswordForm: Renders strength meter & criteria
PasswordForm-->>User: Displays password feedback
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~45 minutes Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (8)
✅ Files skipped from review due to trivial changes (3)
🚧 Files skipped from review as they are similar to previous changes (5)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
Pull Request Linked with Plane Work Items Comment Automatically Generated by Plane |
There was a problem hiding this comment.
Actionable comments posted: 0
♻️ Duplicate comments (1)
apps/space/package.json (1)
40-53: Double-check Space app for stale imports after droppingzxcvbnSame rationale as Admin & Web apps.
🧹 Nitpick comments (2)
packages/ui/src/form-fields/index.ts (1)
5-5: Barrel export looks correct – consider adding type re-exportsThe new line properly surfaces the
passwordfield package; no issues spotted. If the sub-module exposes types/interfaces (PasswordCriteria, etc.), re-exporting them here would simplify consumer imports.packages/ui/src/form-fields/password/indicator.tsx (1)
22-22: Simplify the ternary operator as flagged by static analysis.The nested ternary operator can be simplified for better readability and performance.
- const isPasswordMeterVisible = isFocused ? true : strength === E_PASSWORD_STRENGTH.STRENGTH_VALID ? false : true; + const isPasswordMeterVisible = isFocused || strength !== E_PASSWORD_STRENGTH.STRENGTH_VALID;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
yarn.lockis excluded by!**/yarn.lock,!**/*.lock
📒 Files selected for processing (24)
apps/admin/core/components/common/password-strength-meter.tsx(0 hunks)apps/admin/core/components/instance/setup-form.tsx(2 hunks)apps/admin/package.json(1 hunks)apps/space/core/components/account/auth-forms/password.tsx(2 hunks)apps/space/core/components/account/helpers/index.ts(0 hunks)apps/space/core/components/account/helpers/password-strength-meter.tsx(0 hunks)apps/space/core/components/account/index.ts(0 hunks)apps/space/helpers/password.helper.ts(0 hunks)apps/space/package.json(1 hunks)apps/web/app/(all)/[workspaceSlug]/(settings)/settings/account/security/page.tsx(2 hunks)apps/web/app/(all)/accounts/reset-password/page.tsx(2 hunks)apps/web/app/(all)/accounts/set-password/page.tsx(2 hunks)apps/web/app/(all)/profile/security/page.tsx(2 hunks)apps/web/core/components/account/auth-forms/password.tsx(2 hunks)apps/web/core/components/account/index.ts(0 hunks)apps/web/core/components/account/password-strength-meter.tsx(0 hunks)apps/web/core/components/onboarding/profile-setup.tsx(2 hunks)apps/web/package.json(1 hunks)packages/ui/src/form-fields/index.ts(1 hunks)packages/ui/src/form-fields/password/helper.tsx(1 hunks)packages/ui/src/form-fields/password/index.ts(1 hunks)packages/ui/src/form-fields/password/indicator.tsx(1 hunks)packages/utils/package.json(1 hunks)packages/utils/src/auth.ts(2 hunks)
🧠 Learnings (1)
apps/web/core/components/onboarding/profile-setup.tsx (1)
Learnt from: janreges
PR: #6743
File: packages/i18n/src/store/index.ts:160-161
Timestamp: 2025-03-11T19:42:41.769Z
Learning: In the Plane project, the file 'packages/i18n/src/store/index.ts' already includes support for Polish language translations with the case "pl".
🪛 Biome (1.9.4)
packages/ui/src/form-fields/password/indicator.tsx
[error] 22-22: Unnecessary use of boolean literals in conditional expression.
Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with
(lint/complexity/noUselessTernary)
💤 Files with no reviewable changes (7)
- apps/space/core/components/account/index.ts
- apps/web/core/components/account/index.ts
- apps/space/core/components/account/helpers/index.ts
- apps/space/core/components/account/helpers/password-strength-meter.tsx
- apps/web/core/components/account/password-strength-meter.tsx
- apps/admin/core/components/common/password-strength-meter.tsx
- apps/space/helpers/password.helper.ts
🧰 Additional context used
🧠 Learnings (1)
apps/web/core/components/onboarding/profile-setup.tsx (1)
Learnt from: janreges
PR: #6743
File: packages/i18n/src/store/index.ts:160-161
Timestamp: 2025-03-11T19:42:41.769Z
Learning: In the Plane project, the file 'packages/i18n/src/store/index.ts' already includes support for Polish language translations with the case "pl".
🪛 Biome (1.9.4)
packages/ui/src/form-fields/password/indicator.tsx
[error] 22-22: Unnecessary use of boolean literals in conditional expression.
Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with
(lint/complexity/noUselessTernary)
🔇 Additional comments (28)
apps/web/package.json (1)
17-69: No residual zxcvbn imports in apps/webI searched all
apps/webJS/TS files for bothimportandrequirereferences tozxcvbnand found none. Removing it frompackage.jsonis safe and won’t break the build.packages/utils/package.json (1)
23-33: No incompatibleuuidimports detected – safe to upgrade
- Searched for CommonJS
require('uuid')and default ES imports (import uuid from 'uuid') across all JS/TS files; no occurrences found.- All existing imports use the named syntax
import { v4 as uuidv4 } from "uuid", which is compatible with v10.apps/admin/package.json (1)
38-44: No leftover zxcvbn or password-strength references
Searches forzxcvbn,password-strengthand related component files underapps/admin/returned no matches—all helpers and components have been removed.apps/web/app/(all)/accounts/reset-password/page.tsx (2)
14-14: LGTM: Import updated correctly for the new shared component.The import has been properly updated to use
PasswordStrengthIndicatorfrom the shared UI package as part of the consolidation effort.
195-195: LGTM: Component usage updated consistently.The component replacement maintains the same props interface (
passwordandisFocused), ensuring seamless migration to the new shared password strength indicator.apps/web/app/(all)/[workspaceSlug]/(settings)/settings/account/security/page.tsx (2)
10-10: LGTM: Import correctly updated for consolidated component.The import statement has been properly updated to use the new
PasswordStrengthIndicatorfrom the shared UI package.
110-110: LGTM: Component replacement maintains consistent interface.The component usage has been updated while preserving the same props and conditional rendering logic.
apps/web/app/(all)/accounts/set-password/page.tsx (2)
14-14: LGTM: Import statement correctly updated.The import has been properly updated to use the new shared
PasswordStrengthIndicatorcomponent.
189-189: LGTM: Component usage updated with consistent interface.The component replacement maintains the same props structure, ensuring smooth transition to the shared component.
apps/web/app/(all)/profile/security/page.tsx (2)
10-10: LGTM: Import updated consistently with refactor.The import statement has been correctly updated to use the new shared password strength indicator component.
110-110: LGTM: Component usage updated maintaining same interface.The component replacement preserves the existing props and conditional rendering behavior.
apps/web/core/components/account/auth-forms/password.tsx (2)
11-11: LGTM: Import correctly updated for shared component.The import statement has been properly updated to use the new
PasswordStrengthIndicatorfrom the consolidated UI package.
98-98: LGTM: Final component replacement completes the consistent refactor.The component usage has been updated while maintaining the same props interface. This completes a well-executed consolidation across all password forms, ensuring consistent password strength feedback throughout the application.
packages/ui/src/form-fields/password/index.ts (1)
1-2: Clean module organization for password form fields.The index file properly follows the standard pattern of re-exporting related functionality, making it easy for consumers to import password strength components and helpers from a single entry point.
apps/admin/core/components/instance/setup-form.tsx (2)
10-10: Clean migration to the shared password strength component.The import has been properly updated to use the new
PasswordStrengthIndicatorfrom the shared UI package, aligning with the consolidation objectives.
276-276: Consistent API usage for password strength indicator.The component usage maintains the same props (
passwordandisFocused), demonstrating good API compatibility between the old and new components.apps/web/core/components/onboarding/profile-setup.tsx (2)
14-14: Successfully migrated to shared password strength component.The import statement correctly references the new
PasswordStrengthIndicatorfrom the UI package, supporting the consolidation effort.
456-459: Proper component usage with consistent API.The
PasswordStrengthIndicatoris correctly implemented with the same props pattern as the previous component, ensuring seamless functionality.apps/space/core/components/account/auth-forms/password.tsx (2)
7-10: Comprehensive migration to shared password utilities.The imports correctly transition from local implementations to the shared utilities (
PasswordStrengthIndicatorfrom UI andgetPasswordStrengthfrom utils), supporting both the component consolidation and logic centralization objectives.
72-72: Consistent component usage in conditional rendering.The
PasswordStrengthIndicatoris properly integrated within the conditional logic, maintaining the same props pattern for seamless functionality.packages/ui/src/form-fields/password/helper.tsx (3)
3-7: Well-defined interface for password strength feedback.The
StrengthInfointerface provides a clean structure for encapsulating password strength UI data with clear property names and appropriate types.
12-45: Comprehensive strength evaluation with proper fallback.The function correctly maps all password strength states to appropriate UI feedback. The default case provides a sensible fallback, ensuring robust behavior.
50-65: Clean color logic for visual strength indicators.The fragment coloring logic is well-structured with appropriate fallbacks. The color mapping (red→orange→green) provides intuitive visual feedback for password strength progression.
packages/ui/src/form-fields/password/indicator.tsx (3)
1-11: LGTM! Clean imports and well-structured interface.The component interface is well-designed with appropriate optional props and sensible defaults.
28-46: LGTM! Well-implemented visual strength indicator.The strength meter with animated fragments and conditional message display is well-structured. The accessibility concern of color-only indication is mitigated by the accompanying text message and detailed criteria list.
48-72: LGTM! Well-structured criteria list with good accessibility.The criteria list provides clear visual and textual feedback for each password requirement, with proper conditional styling and responsive layout.
packages/utils/src/auth.ts (2)
43-78: LGTM! Well-structured criteria validation with clear user feedback.The
PasswordCriteriatype andgetPasswordCriteriafunction provide excellent separation between validation logic and UI display. The criteria labels are user-friendly and the validation logic is consistent withgetPasswordStrength.The regex pattern consistency between both functions ensures reliable validation behavior.
21-41: Include double-quote in special-character regexThe Python test shows that the current regex doesn’t match
"(double‐quote), so if you intend to treat"as a valid special character you’ll need to add it to the character class.Locations to update:
- File:
packages/utils/src/auth.ts- Function:
getPasswordStrength- Line where
hasSpecialCharis definedSuggested diff:
- const hasSpecialChar = /[!@#$%^&*()\-_+=\[\]{}|;:'",.<>?/]/.test(password); + const hasSpecialChar = /[!@#$%^&*()\-_+=\[\]{}|;:'",.<>?\/]/.test(password);If you intentionally exclude
"from your policy, no change is needed.Likely an incorrect or invalid review comment.
…ui package (#7462) * refactor: consolidate password strength indicator into shared UI package * chore: remove old password strength meter implementations * chore: update package dependencies for password strength refactor * chore: code refactor * fix: lock file --------- Co-authored-by: sriramveeraghanta <veeraghanta.sriram@gmail.com>
Summary
Type of Change
Media
References
Work-item: [WEB-4513]
Summary by CodeRabbit
New Features
Refactor
Chores