-
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
Editor: Use TermTokenField to edit non-hierarchical CPT taxonomies #6348
Conversation
</span> | ||
<QueryTerms | ||
siteId={ this.props.siteId } | ||
taxonomy={ this.props.taxonomyName } |
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.
QueryTerms
uses the default number
of 100 per page for a query. I think in the old <TokenField/>
looks like we are fetching 1,000 tags in the first request. Do we want to make a larger request here too?
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.
How does paging for these query components usally work? Will it initiate another page on its own, or is there an easy way to do that?
If not, then I agree we should go ahead and fetch 1,000 tags.
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.
Looking through the code some more, it doesn't look like it. Pushed 0532210 to address this. I'm having trouble fully testing the fix due to /me/sites timing out but will try again tomorrow.
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.
How does paging for these query components usally work?
Sorry missed this question earlier. Pagination so far has been implemented using react-virtualized/VirtualScroll
seen here in conjunction with the 🔮 of QueryManager
.
Currently we don't do any pagination in the TokenField correct? So I do think grabbing the large number of tags up-front is the way to go.
Confirmed that 100 tags are being loaded, I have up to "Tag100" and a few other random ones and not all of the Tag9x are showing up: Guessing we want to do 1,000 just like post-tags, but not sure. Couple of other minor items above but looking great!
I have that working locally and would be happy to add to this branch or wait for a follow-up PR. |
Fine with me if you wanna push stuff up here too, it's one less link in the chain of PRs we have to wait on. |
render() { | ||
const termNames = ( this.props.terms || [] ).map( term => term.name ); | ||
|
||
const query = { |
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.
Since this query is static, what do you think about putting it in TermsConstants
in-lieu of a new const
on each render?
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.
Good idea, this also allowed me to use the query in the existing EditorTags
component. Done in rebased 53a571b.
I'll follow up with another PR after this one lands. This is looking good to me. Left a few small comments above, but fine to merge as-is, or you can make changes if you please. |
This component will be used to render categories and/or tags, if supported by the current post type. The more generic EditorDrawerTaxonomies will render all taxonomies.
0532210
to
53a571b
Compare
number: module.exports.MAX_TAGS, | ||
order_by: 'count', | ||
order: 'DESC' | ||
}; |
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 considered bringing this file up to date with ES6 but didn't want to also change the existing imports and usage in this PR.
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.
Doesn't matter much here since I suspect this is a file we'll seek to eliminate altogether, but in general I don't think it's a big deal to mix import / export syntaxes. If anything, the eyesore will hasten follow-up 😄
} | ||
|
||
render() { | ||
const termNames = ( this.props.terms || [] ).map( term => term.name ); |
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 a bit Lodash obsessed, but the Lodash map
implementation could simplify this a bit, removing the need for fallback array and callback function:
const termNames = map( this.props.terms, 'name' );
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'll incorporate this into #6548.
This PR adds support for fetching and editing non-hierarchical terms using a
TokenField
. Adds a newTermTokenField
component which is modeled afterpost-editor/editor-tags/index.jsx
.Planned future steps:
postTerms
property in favor ofgetEditedPostValue( ..., 'terms' )
TermTreeSelector
andTermTokenField
inEditorCategoriesTagsAccordion
to edit categories and tags, respectively. (This is why I renamedEditorTaxonomiesAccordion
toEditorCategoriesTagsAccordion
- I expect the logic there will still be used, but to render only categories and tags rather than all taxonomies.)EditorDrawerTaxonomies
to render all taxonomies, including tags and categories if presentTagListData
andCategoryListData
componentsTo test
Edit a post of a custom type that has one or more non-hierarchical taxonomies. Ensure that existing taxonomies are loaded correctly in the
TokenField
:Ensure that terms can be updated and saved as expected.
Test live: https://calypso.live/?branch=update/editor/cpt-term-token-field