-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
feat(admin): Add button to remove UserEmail #94072
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
base: master
Are you sure you want to change the base?
Conversation
leedongwei
commented
Jun 23, 2025


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.
Also - just a design nit, but usually we hide row actions behind an ellipsis menu to avoid a bunch of angry red icons on the page. But since it's the only action it's probably okay?
| const primary = user.email; | ||
| const emails = user.emails ? user.emails : [{email: primary}]; | ||
|
|
||
| const handleRemoveEmail = async (email: string) => { |
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.
Can you use useMutation() instead? It uses react query and is the ✨ new way ✨
https://develop.sentry.dev/frontend/network-requests/#mutations-postputdelete-requests
| {data.email !== primary && ( | ||
| <Confirm | ||
| message={`Are you sure you want to remove the email ${data.email}?`} | ||
| onConfirm={() => handleRemoveEmail(data.email)} |
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.
If you use the useMutation hook, you can use mutateAsync here to keep the async functionality
| name: 'Addresses', | ||
| content: ({Panel}) => <UserEmails Panel={Panel} user={user} />, | ||
| content: ({Panel}) => ( | ||
| <UserEmails Panel={Panel} user={user} onUserUpdate={refetchUser} /> |
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.
You can also directly modify the cache after this succeeds if you want the list to immediately update instead of having a delay: https://develop.sentry.dev/frontend/network-requests/#updating-your-query-data
ameliahsu
left a comment
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.
mainly nits about testing
|
|
||
| expect(screen.getByText('primary@example.com')).toBeInTheDocument(); | ||
| expect(screen.getByText('secondary@example.com')).toBeInTheDocument(); | ||
| expect(screen.getByText('— primary')).toBeInTheDocument(); |
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.
you can use textWithMarkupMatcher to match text within multiple nodes, to make sure that the correct email is being labeled as primary
| render(<UserEmails Panel={mockPanel} user={mockUser} />); | ||
|
|
||
| // Should show remove button for secondary email | ||
| expect(screen.getByTestId('remove-email-button')).toBeInTheDocument(); |
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.
should use screen.getByRole() instead of using test id
| > | ||
| <Button | ||
| data-test-id="remove-email-button" | ||
| priority="danger" |
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.
|
This pull request has gone three weeks without activity. In another week, I will close it. But! If you comment or otherwise update it, I will reset the clock, and if you add the label "A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀 |
