-
Notifications
You must be signed in to change notification settings - Fork 474
feat(ui): Add phone, delete phone dialogs and set primary action #9717
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
Open
austincalvelage
wants to merge
14
commits into
main
Choose a base branch
from
austin/user-profile-add-phone
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
c7f3ac5
feat(ui): add phone number entry and verification dialog
austincalvelage bd07111
fix(ui): format phone numbers in the account section
austincalvelage 4605e27
feat(swingset): demonstrate add phone in the account section
austincalvelage 3dd4212
feat(ui): support setting a primary phone number
austincalvelage b02f42e
feat(ui): confirm phone number removal
austincalvelage 86786a9
refactor(ui): align phone form with card composition
austincalvelage aab445a
chore(ui): merge main into user profile add phone
austincalvelage 9ee489e
chore(ui): remove redundant phone test comment
austincalvelage 9df3d23
refactor(ui): add phone flow controller
austincalvelage ed3cdd7
refactor(ui): mount add phone flow in account section
austincalvelage b48b8c8
fix(swingset): wire phone flow into full user profile
austincalvelage f43716b
refactor(ui): remove legacy add phone callback
austincalvelage 65f3672
refactor(ui): expose phone code callbacks on account section
austincalvelage 292144a
refactor(ui): centralize user profile phone messages
austincalvelage File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| --- | ||
| --- | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
packages/swingset/src/stories/fixtures/user-profile-add-phone.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import type { UserProfileAccountSectionViewProps } from '@clerk/ui/mosaic/user-profile/user-profile-account-section/user-profile-account-section.view'; | ||
| import type { UserProfileAddPhoneViewProps } from '@clerk/ui/mosaic/user-profile/user-profile-add-phone.view'; | ||
|
|
||
| interface FixtureOptions { | ||
| failAt?: UserProfileAddPhoneViewProps['step']; | ||
| onVerified?: (phoneNumber: string) => void; | ||
| } | ||
|
|
||
| export function createUserProfileAddPhoneFixture({ failAt, onVerified }: FixtureOptions = {}): Pick< | ||
| UserProfileAccountSectionViewProps, | ||
| 'onSendPhoneCode' | 'onVerifyPhoneCode' | ||
| > { | ||
| return { | ||
| onSendPhoneCode: async () => { | ||
| await new Promise(resolve => setTimeout(resolve, 700)); | ||
| if (failAt === 'phone') { | ||
| throw new Error('We couldn’t send a code. Try again.'); | ||
| } | ||
| }, | ||
| onVerifyPhoneCode: async (phoneNumber, code) => { | ||
| await new Promise(resolve => setTimeout(resolve, 700)); | ||
| if (failAt === 'verify' || code === '000000') { | ||
| throw new Error('That code is incorrect. Try again.'); | ||
| } | ||
| onVerified?.(phoneNumber); | ||
| }, | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
packages/ui/src/mosaic/user-profile/__tests__/user-profile-add-phone.integration.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| import { render, screen, waitFor } from '@testing-library/react'; | ||
| import userEvent from '@testing-library/user-event'; | ||
| import { describe, expect, it, vi } from 'vitest'; | ||
|
|
||
| import { MosaicProvider } from '../../MosaicProvider'; | ||
| import { UserProfileProfilePanelView } from '../user-profile-profile-panel.view'; | ||
|
|
||
| describe('profile add phone', () => { | ||
| it.each([false, true])( | ||
| 'owns the dialog and returns focus with multiple accounts = %s', | ||
| async allowMultipleAccounts => { | ||
| const user = userEvent.setup(); | ||
| const onSend = vi.fn(() => Promise.resolve()); | ||
| const onVerify = vi.fn(() => Promise.resolve()); | ||
| render( | ||
| <MosaicProvider> | ||
| <UserProfileProfilePanelView | ||
| allowMultipleAccounts={allowMultipleAccounts} | ||
| name='Test' | ||
| username='test' | ||
| emails={[]} | ||
| phones={[]} | ||
| onSendPhoneCode={onSend} | ||
| onVerifyPhoneCode={onVerify} | ||
| /> | ||
| </MosaicProvider>, | ||
| ); | ||
| const trigger = screen.getByRole('button', { name: 'Add phone number' }); | ||
| await user.click(trigger); | ||
| expect(screen.getByRole('dialog', { name: 'Add phone number' })).toBeInTheDocument(); | ||
| await user.type(screen.getByRole('textbox', { name: 'Phone' }), '8015550100'); | ||
| await user.click(screen.getByRole('button', { name: 'Send code' })); | ||
| await waitFor(() => expect(screen.getByRole('textbox', { name: 'Verification code' })).toHaveFocus()); | ||
| await user.keyboard('123456'); | ||
| await waitFor(() => expect(screen.queryByRole('dialog')).not.toBeInTheDocument()); | ||
| expect(onSend).toHaveBeenCalledExactlyOnceWith('+18015550100'); | ||
| expect(onVerify).toHaveBeenCalledExactlyOnceWith('+18015550100', '123456'); | ||
| await waitFor(() => expect(trigger).toHaveFocus()); | ||
| }, | ||
| ); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Add a patch release entry for
@clerk/ui.@clerk/uiis publicly published, and the empty changeset omits version and changelog output. This change updates phone-flow messages and error handling; it does not removeonAddPhone. Use a patch release.🤖 Prompt for AI Agents