-
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
Jetpack Sites: Use active modules list added to /me/sites endpoint #1700
Conversation
JetpackSite.prototype.toggleModule = function( moduleId, callback ) { | ||
const isActive = this.isModuleActive( moduleId ), | ||
method = isActive ? 'jetpackModulesDeactivate' : 'jetpackModulesActivate', | ||
prevActiveModules = Object.assign( {}, this.modules ); |
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.
could we name this prevStateModules
or something like that? if I'm not understanding it wrong, it saves the previous state of the modules to be able to restore them if there's an error, but the name suggest me a subset of the modules that includes only the active ones
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.
(maybe I'm not getting it 100%)
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.modules
only contains active modules, maybe that's the one we should change
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.
no, ok, I wasn't understand that... sounds good to me then 👍
if ( typeof module === 'string' ) { | ||
module = this.getModule( module ); | ||
if ( isActive ) { | ||
this.modules = this.modules.fiter( module => module === moduleId ); |
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.
fiter
... filter
?
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.
👍
ad7d82f
to
c9f0b8f
Compare
I just a bit more testing and I wasn't able to activate and deactivate modules in sites security setting any more. The JS error that I get is to test go to http://calypso.localhost:3000/settings/security/example.com |
Thanks for the exhaustive testing @enejb! I was able to get the error once, but now I can't reproduce it anymore ¯_(ツ)_/¯ |
c9f0b8f
to
68f9027
Compare
@enejb I was able to reproduce the error, I was filtering the active modules list the wrong way. It's fixed now. |
Works great!! And the feeling of having that data right away, without having to fetch it and have content screen and then a manage disabled error (for example) is awesome! \o/ 🚢 |
Jetpack Sites: Use active modules list added to /me/sites endpoint
@@ -63,11 +63,6 @@ module.exports = React.createClass( { | |||
MediaActions.setLibrarySelectedItems( nextProps.site.ID, [] ); | |||
} | |||
|
|||
if ( nextProps.site && nextProps.site.jetpack && ! nextProps.site.modulesFetched && | |||
( ! this.props.site || this.props.site.ID !== nextProps.site.ID ) ) { | |||
nextProps.site.fetchModules(); |
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 makes me happy to see removed 😃
Does this fix #1425 ? |
It does — single render sidebar finally :) |
it also fixes a lot of ugly content flashes in jetpack sites with manage turned off ... this is truly a great update! \o/ |
if ( selectedSite && | ||
selectedSite.modulesFetched && | ||
! selectedSite.canManage() ) { | ||
if ( selectedSite && ! selectedSite.canManage() ) { |
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.
Just to note somewhere: canManage
only exists on Jetpack sites, so we need to either check selectedSite.jetpack
before calling it, or add the same method to a .com site in a way that makes sense. I'm not sure what the best solution is, but we pushed an update to check if the site is a Jetpack site before calling this to fix it in the meantime.
Use
jetpack_modules
list of active modules recently added to/me/sites
endpoint, instead of fetching the list of modules on individual requests.How to test
cc @mtias @jkudish @aduth @enejb