-
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
CPT: Move PostTypeListPost to standalone block directory #7195
Conversation
font-weight: 700; | ||
white-space: nowrap; | ||
|
||
a { |
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.
It'd be nice to have a class for this.
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.
It'd be nice to have a class for this.
Refactored in 0483005
Looks good to me. |
@aduth can we plan on adding it to the blocks gallery in devdocs? |
To better align with request tracking for individual sites on “requesting” state
1b3a81c
to
e0d92da
Compare
@mtias : Pushed up a handful of new commits to document and add a DevDocs example for Looping in @gwwar as the original author of this state and query component (#5066). |
} | ||
|
||
request( props ) { | ||
if ( ! props.siteId && ! props.requestingSites ) { |
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.
Do we need to be careful about the case where we may need to wait until a siteId is available? We might accidentally trigger an all sites request if we pass through a falsy value before we pass through a siteId.
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.
Do we need to be careful about the case where we may need to wait until a siteId is available? We might accidentally trigger an all sites request if we pass through a falsy value before we pass through a siteId.
Yes, but I think that should be on the developer to ensure that if they're intending to request a single site that they not render the <QuerySites />
component until the site ID is ready. That said, we could/should probably have better documentation about this behavior.
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.
The sites request is heavy enough that I'd think it be worthwhile to try and avoid this case. I can see this being overlooked in a PR pretty easily.
Have we considered creating a QuerySites and QuerySite component?
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.
Have we considered creating a QuerySites and QuerySite component?
I know it had come up previously in the case of single post vs. all posts for a site, and IIRC there was a desire to keep it to a single flexible component that could accommodate both cases. I see benefits to both angles. Separate components not only avoids this as a mistake, but is also a simpler implementation for the individual components. Another alternative to consider is only doing the "mass" request if explicitly passing a null
parameter for siteId
or a separate allSites
(or similarly named) prop.
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.
Some context: #2350 (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.
This shouldn't hold up the PR, but I think splitting it into two keeps it simple and makes it easier to use.
Passing an explicit null
parameter works too, but we'd need to communicate the convention. Currently, selectors often return null
so this would be easy to accidentally trigger.
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.
To me it's just an attribute difference of the same query — the same way I can say "query only posts for this author" I should be able to say "query all my latest drafts". Mentally I'm querying for the same item (posts) and I don't care how our API is setup, or whether I'm hitting different endpoints. Agreed on guarding against triggering unnecessary fetches, though. Perhaps allSites
is a good prop to have.
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.
Fair enough, and if we ever end up paging the results this makes sense too. I think an extra prop works better than giving extra meaning to null
. Usage then looks like:
<QuerySites allSites />
<QuerySites siteId={ siteId } />
This pull request seeks to move the
<PostTypeListPost>
component tomy-sites/post-type-list/post.jsx
toblocks/post-item/index.jsx
, renamed as a standalone<PostItem>
component. This is part of a series of pull requests aimed at refactoring the custom pots types listing components for more generalized and customizable usage.Testing instructions:
Verify that there are no regressions in the display and interaction of the custom post types list page post items.
/cc @mtias
Test live: https://calypso.live/?branch=move/cpt-list-post-item