-
-
Notifications
You must be signed in to change notification settings - Fork 9.2k
DynamicZone - extend FriendlyName with MainValue #12500
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
Conversation
|
@godzzo Thanks for your contribution again :) We had a quick look into the PR today and think it's a nice addition. I'll check & review your code in the coming days. |
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.
As I already said: thank you for the contribution. I've added a couple of comments, but overall this is an addition we'd like to welcome.
...es/core/admin/admin/src/content-manager/components/DynamicZone/components/Component/index.js
Outdated
Show resolved
Hide resolved
...es/core/admin/admin/src/content-manager/components/DynamicZone/components/Component/index.js
Outdated
Show resolved
Hide resolved
...ges/core/admin/admin/src/content-manager/components/DynamicZone/components/Component/util.js
Outdated
Show resolved
Hide resolved
...ges/core/admin/admin/src/content-manager/components/DynamicZone/components/Component/util.js
Outdated
Show resolved
Hide resolved
...es/core/admin/admin/src/content-manager/components/DynamicZone/components/Component/index.js
Outdated
Show resolved
Hide resolved
| import { get, toString } from 'lodash'; | ||
| import { useCMEditViewDataManager } from '@strapi/helper-plugin'; | ||
|
|
||
| function useMainValue(schema, componentFieldName) { |
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.
Could you add a test for this file?
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 am not familiar the testing in this project. Could you give me some docs and an example?
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 the best would be to copy this file into a utils folder (e.g. ./utils/useMainValue.js. Then you can add a test folder within utils and write a basic unit-test similar to this one, which tests input / output.
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 have decoupled the displayedValue logic and pushed a unit test file for it.
In Win10 the jest could not find any test file, I tested on WSL2-Ubuntu.
testMatch: /**/tests/**/?(*.)+(spec|test).[jt]s?(x) - 0 matches
Codecov ReportBase: 59.33% // Head: 59.33% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #12500 +/- ##
==========================================
- Coverage 59.33% 59.33% -0.01%
==========================================
Files 1338 1342 +4
Lines 32724 32757 +33
Branches 6197 6199 +2
==========================================
+ Hits 19417 19436 +19
- Misses 11438 11450 +12
- Partials 1869 1871 +2
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. |
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 again @godzzo. I've added two small comments. It would still be nice to have tests for useMainValue(). You can find a way to test hooks here: https://github.com/strapi/strapi/pull/12893/files#diff-9530f953e7c9e1ef6b200896b0fbcb9ee54c81ff875bbae6dc61b080e2c10d7f , but since the tests seem to create problems on your machine, you can let me know if you want me to push a test for it?
...es/core/admin/admin/src/content-manager/components/DynamicZone/components/Component/index.js
Outdated
Show resolved
Hide resolved
.../admin/src/content-manager/components/DynamicZone/components/Component/utils/useMainValue.js
Outdated
Show resolved
Hide resolved
|
|
||
| return layout; | ||
| }, [componentUid, getComponentLayout]); | ||
| const mainValue = useMainValue(componentLayoutData, [name, index]); |
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 would recommend to pass the mainValue as a prop from the DynamicZone/utils/select.js hook to avoid extreme rerendering of the components, it can cause performance issues at some point.
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 have created a new wrapper with utils/connect for DynamicZone/Component.
Please check this out. It is okay for using this separately for each Component?
(it feel cleaner for me and the RepeatableComponent/DraggedItem using the same way, if I see it correctly).
Or should I move the mainValue parsing here DynamicZone/utils/select.js:
const dynamicDisplayedComponents = useMemo(
() => get(modifiedData, [name], []).map(data => data.__component),
[modifiedData, name]
);
.../admin/src/content-manager/components/DynamicZone/components/Component/hooks/useMainValue.js
Outdated
Show resolved
Hide resolved
|
This pull request has been mentioned on Strapi Community Forum. There might be relevant details there: https://forum.strapi.io/t/component-entry-titel-display-in-dynamic-zone/15478/3 |
|
Any chance this will get reviewed and merged? Would love to be able to use this feature |
|
@sjaga003 I'll do another review as soon as possible - I think I'll manage it by next week. |
Nice, we need this. |
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
|
Hey all, let me request and update from the team |
|
@derrickmehaffy I'm on it. The required design-System work is done, but I have to find some time to review this PR again. |
No problem thank you! |
62c179f to
5e8d63b
Compare
|
Hello 👋🏼 I've checked the PR again today, because now all required changes to the I've found a couple of bugs:
Would you still be available to fix those? |
|
Hello @gu-stav ! Yes! I have tried to fix the 3 bugs you mentioned. Please review it.
|
082ec47 to
1404123
Compare
…nent This commit fixes strapi#12499
…ieldName (string) parameter reorged to componentFieldPath (array)
…ue and add a unit test for it - without call the test.
…the proper hooks/ folder.
Co-authored-by: Gustav Hansen <gu@stav.dev>
1404123 to
9b2d5b0
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.
It works well on my side now. 🚀 Thanks for staying on it and fixing all the problems!

...like RepeatableComponent
This commit fixes #12499
What does it do?
Show the MainValue of the Components of a DynamicZone in the AccordionToggle.
Why is it needed?
To be able to distingish the Dzone components without unfold them.
How to test it?
Sample:

Related issue(s)/PR(s)
Related issue: #12499