-
Notifications
You must be signed in to change notification settings - Fork 373
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
Allow the translation of enum value used for elementLabelProp in ExpandPanelRenderer #2289
Allow the translation of enum value used for elementLabelProp in ExpandPanelRenderer #2289
Conversation
✅ Deploy Preview for jsonforms-examples ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
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.
Looks good already. However we should also support the one of enum case
packages/material-renderers/src/layouts/ExpandPanelRenderer.tsx
Outdated
Show resolved
Hide resolved
packages/material-renderers/src/layouts/ExpandPanelRenderer.tsx
Outdated
Show resolved
Hide resolved
packages/material-renderers/src/layouts/ExpandPanelRenderer.tsx
Outdated
Show resolved
Hide resolved
938e125
to
42ef5c1
Compare
Resolved the conflicts, rebased and squashed |
…label-prop # Conflicts: # packages/material-renderers/test/renderers/MaterialArrayLayout.test.tsx
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 had a look, improved the types and aligned the function declarations to arrow style as the rest of the code base.
I also noticed the following behavior.
Assume the following JSON Schema in use:
{
type: 'object',
properties: {
comments: {
type: 'array',
title: 'Messages',
items: {
type: 'object',
properties: {
message1: {
type: 'string',
},
message2: {
type: 'string',
enum: ['foo', 'bar'],
},
},
},
},
},
}
Then the auto generated keys for the enum will be comments.message2.foo
and comments.message2.bar
.
However for the summary title in the expand panel, the following keys will be used: comments.foo
and comments.bar
. Therefore if a proper translation of the enum is used, it will not automatically show up in the expand panel, instead another key needs to be additionally translated.
I assume that this was not on purpose?
Can you fix the issue? Ideally the test case should also be improved. In the moment there is just a mock translator in there which does not check the handed over keys. I assume that is why the issue was overlooked.
You were right, the previous code had problems on translation key, and on elementLabelProp on deeper path. I fixed it and added some tests for the deep cases. |
packages/material-renderers/test/renderers/MaterialArrayLayout.test.tsx
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.
I found one minor and one major issue with the current state. Besides that it looks good!
packages/material-renderers/src/layouts/ExpandPanelRenderer.tsx
Outdated
Show resolved
Hide resolved
packages/material-renderers/src/layouts/ExpandPanelRenderer.tsx
Outdated
Show resolved
Hide resolved
packages/material-renderers/test/renderers/MaterialArrayLayout.test.tsx
Outdated
Show resolved
Hide resolved
I just saw that the same behaviour exist in ListWithDetail, and that the solution don't support if |
Update: I will re-review this PR again this week |
PR for #2288