-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Support dedicated /me/security UI to change email address #44117
base: trunk
Are you sure you want to change the base?
Conversation
Note that for now, we redirect via `userSettings` when available to work with the existing account management UI, but use normal Redux state handling otherwise.
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: Webpack Runtime (~95 bytes added 📈 [gzipped])
Webpack runtime for loading modules. It is included in the HTML page as an inline script. Is downloaded and parsed every time the app is loaded. App Entrypoints (~61 bytes added 📈 [gzipped])
Common code that is always downloaded and parsed every time the app is loaded, no matter which route is used. Sections (~7238 bytes added 📈 [gzipped])
Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to. Async-loaded Components (~1771 bytes added 📈 [gzipped])
React components that are loaded lazily, when a certain part of UI is displayed for the first time. Legend What is parsed and gzip size?Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory. Generated by performance advisor bot at iscalypsofastyet.com. |
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.
Thanks for improving this abandoned, but super important section in Calypso! 🥇
As expected with a big refactor of an old code, some issues crept in, but overall I love the direction.
One thing that could use still improvement is loading/read error handling, as it seems the UI is just permanently stuck in loading state if the backend returns an error (there's not even an error notice). For updates, it seems much better, though.
I've also noticed a bit confusing state when the account email component is loaded:
When the state of the email is being fetched from the backend, the button actually changes to Updating...
- same as if I actually pressed it to update. And, as mentioned above, if there's an error when loading the state, the button is stuck in the Updating...
state.
if ( props.userSettings ) { | ||
return props.userSettings.getSetting( 'user_email' ); | ||
} | ||
if ( props.unsavedUserSettings && typeof props.unsavedUserSettings.user_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.
I think there might be still something wrong with this logic (or the way we handle the data in Redux/flux?). There's a different behaviour still for the empty email case.
In /me/account
, when the field is empty, there's an explicit error message shown:
However, in account-email
, there is no error message:
The field is highlighted as error, though - and you can't submit the form... unless you go to a different view and come back:
😁
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 was basically the same underlying logic issue around ''
being falsey that I worked on in 6e6d760, but I didn't catch the problem in the validation checks. This should be fixed now.
Thanks for the thorough testing, @klimeryk! 😍😍💖💖💖 I've addressed almost all of the issues you flagged. The one area that's still a bit suspect overall is clearer handling for successful/failed requests to the server. I believe that other state management logic uses distinct _SUCCESS and _FAILURE actions for this purpose, but I am not sure how much bigger that would make this PR. 😐 (Even the code in this PR would benefit from being able to detect successful saves in particular.) I also want to note that the existing |
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.
Nice, thanks for the updates! The validation is indeed working much better now. And I agree that the error handling there is indeed a bit bare-bones. If it means the PR would get bigger, I think it's fine to leave it for a follow-up one. At least now there's no error - the update button just hangs in the "Updating..." state. But refreshing or going back and again to the view fixes it.
Speaking of which, I noticed one more bug: if you change the email to an invalid value in me/security/account-email
, you get a validation error and the update button is inactive. But if you click the Back button and go back to the view, the value remains the same (invalid), but there's no validation error and you can submit the form. I have not tested if the backend will actually accept it (hopefully not :D). I'm guessing it's related to that whole mess with Redux and flux stores. Up to you if you want to fix it. Looks like there is backend validation so it should not be a blocker.
Thanks for taking another look, @klimeryk! I did spend some time on the state-related work yesterday, and I came away realising that it needs some serious work to support good error handling for fetches and saves. Pretty much anything I do at the moment is somewhere between a work-around and a hack. 😬 I'll take another look at the weird cases you tripped over, and will likely wrap this PR with those fixes. |
@daledupreez are you still working on this PR? As a FYI I started working on removing |
Thanks for checking, @flootr! |
This PR has been marked as stale due to lack of activity within the last 30 days. |
Changes proposed in this Pull Request
This PR may well be too big, but it takes on a number of closely related tasks to expand the work in #43527:
isFetchingUserSettings()
selector (and the related wiring) so fetches and updates can be reflected in the UIisPendingEmailChange()
selector has been updated to force a boolean return value./me/account
into a dedicated componentUserSettings
object or expecting the component to rely on the Redux state./me/security/account-email
that is only responsible for updating the account email address, and fits the UX for the other menu items listed under/me/security
.Testing instructions
There is a LOT to test here.
Regression Tests for
/me/account
Our main goal here is to make sure that the existing email modification UI continues to work. Make sure the following work:
/me/account
and update the email address field.It may also be worth verifying an email to check that the UI updates appropriately -- this is existing behaviour, but I don't believe I touched it in this case.
Testing the email option in
/me/security
Using a local Calypso version, or by using the calypso.live UI for this branch, try the following:
/me/security
./me/security/account-email
, and that clicking the "Back" button gets you back to the menu. Click on the "Account Email" entry again.