-
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
Stats: create redux version of stats-list. #6135
Conversation
|
||
return { | ||
requesting: isRequestingSiteStatsForQuery( state, siteId, statType, query ), | ||
siteSlug: site ? site.slug : '', |
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.
slug
shouldn't exist as a property on site
, and if it does, we have bigger problems 😄
slug
is a computed property added by the legacy lib/site
module, you should use the getSiteSlug
selector instead.
But I'm very curious if site.slug
is returning a value here.
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 particular component never renders a summary link, but to answer your question, yes slug
is on the site object from the state tree here:
But this seems valid to me, as slug
is defined on the schema
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.
Well, thank you for finding this at least. Looks like folks have been adding back computed properties originally removed in #4060. See discussion at #5966 (comment).
Thanks for the review @aduth. I added the I will do my best to clean-up the |
57ff9ce
to
286ebb4
Compare
Cleaned up some of the |
cae0b81
to
67bc660
Compare
Rebased and ready for another review. |
return '/stats/' + period.period + '/' + path + '/' + siteSlug + '?startDate=' + date; | ||
} | ||
|
||
return null; |
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.
Minor and maybe arguable to have the explicitness, but you could omit the fallback return
, as the default return value undefined
would work just as well for your use case.
* @param {Object} data Stats query | ||
* @return {Array} Parsed publicize data array | ||
*/ | ||
statsPublicize: ( data = {} ) => { |
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.
Minor again: This can be shortened to:
statsPublicize( data = {} ) {
import React from 'react'; | ||
import PureComponent from 'react-pure-render/component'; | ||
|
||
export default class StatsModuleExpand extends PureComponent { |
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 was going to suggest this would make a good stateless function component, though one downside being it's not possible to have pure stateless function components without using something like connect
or pulling in recompose
.
I see two network requests for |
This is working well in my testing. A few questions noted, but otherwise good to merge I think 👍 |
Good catch, the removal of the old list logic in the controller was lost during my rebase. Fixed in 86fb690 |
86fb690
to
7e6429a
Compare
As part of migrating from the legacy
stats-list
to utilizing the global state tree across stats, this branch introduces a new version of the<StatsModule />
component. The<StatsConnectedModule />
will help ease the transition of all legacy<StatsModule />
usage to utilize Redux.I attempted to cobble together support for redux +
stats-list
within the existing<StatsModule />
but after fighting backwards compatibility - I felt creating a new temporary module to use during the transition was the best approach.The first stats module to use this new
Connected
component is the "Publicize" module on the Insights page. This is a very basic module with no row actions or summary page support - so it seemed like a great place to start.To Test
Implementation Notes
Additionally this branch introduces a new selector
getSiteStatsParsedData
. Akin to the legacystats-list
, this selector will call the appropriate utility method instate/stats/lists/utils
for the givenstatType
. In this branch you can see tests added for this new selector along with tests for parsingstatsPublicize
data.After all existing stats modules are updated to use
<StatsConnectedModule />
my plan will be to delete the old version of<StatsModule />
and let the connected version become the default use case. This approach will allow us to do smaller/focused PRs to migrate all stats modules over to redux.Test live: https://calypso.live/?branch=update/stats/publicize