-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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
Fix: Publishing single-type if config is true, and allow updating the drafts - api #14767
Conversation
Codecov ReportBase: 60.49% // Head: 60.50% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #14767 +/- ##
=======================================
Coverage 60.49% 60.50%
=======================================
Files 1352 1352
Lines 33174 33180 +6
Branches 6337 6338 +1
=======================================
+ Hits 20070 20074 +4
- Misses 11271 11273 +2
Partials 1833 1833
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
ef345ea
to
1f1cd8c
Compare
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.
Hello, thank you for the PR! 😃
I think it is perfect for the first fix.
For the second fix, can you try to write:
const entity = await this.find({ ...params, publicationState: 'preview' });
line 40 of packages/core/strapi/lib/core-api/service/single-type.js
?
I think it would fix the issue and would be cleaner :)
If you don't have time to handle this, just tell me and I'll take over, sorry for the delay :)
Also It would be nice to add a test to ensure both issues won't happen again (someting inside or similar to what is done in strapi/packages/core/strapi/tests/api/basic-dp.test.e2e.js
)
Thank you for your time reviewing this @petersg83, I will make sure to work on the points you mentioned by the next week |
Signed-off-by: iifawzi <iifawzie@gmail.com>
79e3f06
to
3ae29ee
Compare
@@ -65,6 +66,8 @@ describe('Content Manager single types', () => { | |||
}, | |||
}); | |||
|
|||
expect(res.body.data.attributes.publishedAt).toBeISODate(); |
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.
Hi, I've pushed the changes and updated the tests.
The first issue, it's now covered by this line.
For the second issue, no need for additional tests, because the Update keeps the same data id
is not failing after having draftAndPublish
set to true ( Before the changes introduced in this pr, it would fail if draftAndPublish
is true ).
Would appreciate if you can take another look @petersg83, and let me know if you think anything can be improved :) |
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.
Hi @iifawzi , apologies for the delay. Thank you for these changes the code looks great and is working well 👍🏻
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.
Thank you @iifawzi! It's perfect :) Sorry for the delay, I was in holidays for 2 weeks :)
It should be in the next release!
Signed-off-by: iifawzi iifawzie@gmail.com
What does it do?
Hi, this PR is addressing #14719, which mainly had two issues:
1- Creating a single type entry using API results in the type not being published (draft):
To handle this, I've added a check as we do in the collection types, that will publish based on the config
2- The second issue is that, if the type is draft, it can't be updated using the API:
This is caused because of the query filters
strapi/packages/core/utils/lib/convert-query-params.js
Lines 384 to 388 in 788ea22
I've fixed it with a
onlyPublished
parameter, that will be propagated to the function, to set the$notNull
operator to false.I feel like this's more of a hacky solution than a fix, let me know if you do suggest any better solutions, my only concern was that I didn't want to mess around with the
transformParamsToQuery
method, since it's used in a lot of places.Related issue(s)/PR(s)
Fix #14719