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
Make updateContentTypeConfiguration endpoint return full data #13676
Make updateContentTypeConfiguration endpoint return full data #13676
Conversation
…tType and components) Fix issue 13675
Codecov Report
@@ Coverage Diff @@
## master #13676 +/- ##
==========================================
- Coverage 54.19% 54.18% -0.01%
==========================================
Files 1197 1197
Lines 30588 30590 +2
Branches 5562 5562
==========================================
Hits 16576 16576
- Misses 12191 12193 +2
Partials 1821 1821
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
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.
That looks fairly straight forward. Just an open question as maybe we can avoid refecthing everything
packages/core/admin/admin/src/content-manager/hooks/useFetchContentTypeLayout/index.js
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.
LGTM
Thanks for the fix 👍 |
This PR fixes the issue #13675
The Content-type controller returns the same response object as the "findConfiguration" now.
What does it do?
This PR changes the response of the
PUT /content-types/:uid/configuration
to be the same asGET /content-types/:uid/configuration
.In general it is a good practice for the REST APIs to have the same response object for
GET
andPUT
for the same route with thePUT
returning modified resource.Why is it needed?
As described in the linked issue, attempting to change view configuration for a single-type entry will fail if the entry contains components.
What happens is that the
PUT /content-types/:uid/configuration
responds with only half of the data that the "Admin" UI package needs for correct behaviour. And theupdateLayout
method simply hardcodes the missing piece with an empty objectcomponents: {}
.The problem happens when later in the execution flow tree there is an attempt to dereference a null pointer:
strapi/packages/core/admin/admin/src/content-manager/hooks/useFetchContentTypeLayout/utils/formatLayouts.js
Lines 167 to 170 in 8b719b1
Here the
components
is an empty object, hence thecomponent
is undefined. Which meanscomponent.settings
expression is doomed to fail.How to test it?
Related issue(s)/PR(s)
fixes #13675
Note: No tests have been added for this code change. I don't have capacity to look into and update/add tests, sorry.