-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Dataviews: All templates: Add: Sorting to template author and add author_text to the rest API. #56333
Conversation
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
This pull request has changed or added PHP files. Please confirm whether these changes need to be synced to WordPress Core, and therefore featured in the next release of WordPress. If so, it is recommended to create a new Trac ticket and submit a pull request to the WordPress Core Github repository soon after this pull request is merged. If you're unsure, you can always ask for help in the #core-editor channel in WordPress Slack. Thank you! ❤️ View changed files❔ lib/compat/wordpress-6.5/rest-api.php ❔ phpunit/class-gutenberg-rest-templates-controller-test.php |
Size Change: +47 B (0%) Total Size: 1.7 MB
ℹ️ View Unchanged
|
packages/edit-site/src/components/page-templates/dataviews-templates.js
Outdated
Show resolved
Hide resolved
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.
Thanks for the PR Jorge! I've just skimmed through the code and I definitely agree that this should be done in the REST API layer. I have a few notes though.
I think the endpoint besides the author_text
, should be augmented to return the origin type(ex ENUM: user, theme, site, plugin). This could be useful in the codebase to in order to avoid doing the exact same checks again client side. And this leads to my second note, that we should refactor
useAddedBy` hook(maybe in a follow up? 🤔 ). Additionally the templates list(data views) use the above hook, so some changes might be needed to use the data from the items now.
Finally since this PR updates PHP, it would be good to add the PHP tests here, to make the backport to core more smooth.
42e92e5
to
aaecaa8
Compare
Hi @ntsekouras, I added an original_source field which can be Regarding the backporting in this case it will always be tricky because here we use API to add a new field while in core we will refactor the current endpoint to include the new field natively. The tests created for the plugin would be different from the ones in core, I guess the simplest way to make the backporting of this PR simpler would be to create an equivalent PR to this one in core right now, with the tests and all other required changes. What do you think? Besides the creation of an equivalent core PR backporting the REST API changes and including tests, is there any other change you think we should do before the merge? |
Flaky tests detected in aaecaa8. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/6995573616
|
Regarding the tests I was thinking adding here the |
aaecaa8
to
f2d4451
Compare
packages/edit-site/src/components/page-templates/dataviews-templates.js
Outdated
Show resolved
Hide resolved
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.
Thanks Jorge! This works well and besides the test updates and the liniting issues, it should be good to land.
'update_callback' => null, | ||
'schema' => array( | ||
'type' => 'string', | ||
'description' => __( 'Human readable text for the author.' ), |
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 think we need to add the domain gutenberg
in __
call. I believe there was a linting rule for that in the past.
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.
Fixed 👍
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.
With 🟢 CI let's ship. Thank you!
79776c5
to
71eb4de
Compare
'id' => 'emptytheme//my_template', | ||
'theme' => 'emptytheme', | ||
'slug' => 'my_template', | ||
'source' => 'custom', | ||
'origin' => null, | ||
'type' => 'wp_template', | ||
'description' => 'Description of my template.', | ||
'title' => array( | ||
'id' => 'emptytheme//my_template', | ||
'theme' => 'emptytheme', | ||
'slug' => 'my_template', | ||
'source' => 'custom', | ||
'origin' => null, | ||
'type' => 'wp_template', | ||
'description' => 'Description of my template.', | ||
'title' => array( |
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.
Confirmed that these changes are not backported to Core version of this test file.
👋 Hi @jorgefilipecosta. I think the changes to |
Confirmed this is happening in WordPress/wordpress-develop#5940 |
Part of the follow-ups on #55848 (comment).
Adds sorting to the template author text field. To make sorting possible, we also add an author_text to the rest API of wp_templates.
Testing
Go to the manage all templates page.
Verify sorting works as expected.