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

Site settings: only update clean fields with updated poll data #1167

Merged
merged 1 commit into from
Dec 7, 2015

Conversation

gwwar
Copy link
Contributor

@gwwar gwwar commented Dec 1, 2015

Fixes #43 #40 and #42 where unsaved changes to site settings could be wiped out on rerender. This is triggered by SitesList polling periodically via the /me/sites endpoint. Note that this affects all settings, not just the site tagline.

Testing Instructions

  1. Navigate to: http://calypso.localhost:3000/settings/
  2. Select a site when prompted
  3. Update some site settings
  4. Wait around 30 seconds for SitesList to update

Expected: Your unsaved changes are still there.

cc @hoverduck @rralian

@gwwar gwwar added [Feature] Site Settings All other general site settings. [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Dec 1, 2015
@mtias
Copy link
Member

mtias commented Dec 2, 2015

I don't think we should disable the refreshing of data completely. That means that once I hit the settings page, any changes that may happen externally won't be reflected. It's specially noticeable if you open two tabs with settings and in the second one you change the site title. After the poller kicks in, you'll see that the sidebar in the first site updates the selected site with the new title, however, the from field would still have keep the old one.

I think a better solution would be to have the notion of "dirty" for the fields, and leave alone fields that the user may have changed during a poller cycle update.

@mtias mtias added [Status] Needs Author Reply and removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Dec 2, 2015
@rralian
Copy link
Contributor

rralian commented Dec 2, 2015

I think a better solution would be to have the notion of "dirty" for the fields, and leave alone fields that the user may have changed during a poller cycle update.

Yeah, I agree with this.

@gwwar gwwar force-pushed the fix/tagline-content-blur-43 branch from 278123b to 260a661 Compare December 2, 2015 20:07
@gwwar gwwar changed the title Site settings: only update site setting state on initial fetch Site settings: only update clean fields with updated poll data Dec 2, 2015
@gwwar
Copy link
Contributor Author

gwwar commented Dec 2, 2015

I think a better solution would be to have the notion of "dirty" for the fields, and leave alone fields that the user may have changed during a poller cycle update.

@mtias @rralian added in 7a65179 Let me know if the mixin should live somewhere else, or if you have a better idea for a name.

@gwwar gwwar added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. and removed [Status] Needs Author Reply labels Dec 2, 2015
@gwwar gwwar force-pushed the fix/tagline-content-blur-43 branch 2 times, most recently from 7a65179 to c163086 Compare December 3, 2015 20:43
@gwwar gwwar self-assigned this Dec 3, 2015
@gwwar gwwar force-pushed the fix/tagline-content-blur-43 branch from c163086 to b293f2b Compare December 4, 2015 19:07
@gwwar gwwar added this to the Core: Iteration 17 milestone Dec 4, 2015
@@ -131,7 +139,9 @@ module.exports = {

notices.clearNotices( 'notices' );

this.setState( { submittingForm: true } );
//for dirtyFields, see lib/mixins/dirty-linked-state
this.setState( { submittingForm: true, dirtyFields: [] } );
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we move the clearing of dirtyFields down to the success case below? If there's some transient internet hiccup and you're in the error case where you just need to resubmit, I think we'd still want the dirtyFields to be retained until the form is successfully submitted. Otherwise your changes would potentially be cleared out while you are in that error state.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 good catch, I'll only clear that out in the success case

@rralian
Copy link
Contributor

rralian commented Dec 7, 2015

This is great. I had one suggestion, and if you agree, I think this is good to 🚢 once that change is made. I wonder if this would be a useful module to open source separately and publish via npm? I wouldn't do so in this PR, but I think we need some sort of strategy around open sourcing smaller modules. I think this is what @retrofox was talking about in our hangout last week.

this.setState( { submittingForm: true } );
//for dirtyFields, see lib/mixins/dirty-linked-state
this.setState( { submittingForm: true, dirtyFields: [] } );

site.saveSettings( this.state, function( error ) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll also add an omit( this.state, 'dirtyFields' ) so we don't send over an unneeded field.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍 likewise, good catch

@gwwar
Copy link
Contributor Author

gwwar commented Dec 7, 2015

I wonder if this would be a useful module to open source separately and publish via npm?

It's a pretty good candidate for it. Sounds like we might want to add in some generators to make publishing npm packages easier? Like boilerplate babel config/testing setup.

…ly update clean fields with updated poll data.
@gwwar gwwar force-pushed the fix/tagline-content-blur-43 branch from b293f2b to 83aba4d Compare December 7, 2015 18:41
@gwwar
Copy link
Contributor Author

gwwar commented Dec 7, 2015

Should we move the clearing of dirtyFields down to the success case below?

@rralian Fixed in 83aba4d

@gwwar gwwar added [Status] Ready to Merge and removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Dec 7, 2015
gwwar added a commit that referenced this pull request Dec 7, 2015
Site settings: only update clean fields with updated poll data
@gwwar gwwar merged commit bb52c4d into master Dec 7, 2015
@gwwar gwwar deleted the fix/tagline-content-blur-43 branch December 7, 2015 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Site Settings All other general site settings.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants