-
Notifications
You must be signed in to change notification settings - Fork 55
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(forms): switch to UIform if uischema is an array #1282
fix(forms): switch to UIform if uischema is an array #1282
Conversation
1 similar comment
@@ -44,7 +44,7 @@ export default class UIForm extends React.Component { | |||
if (!this.props.onChange) { | |||
return; | |||
} else if (this.props.moz) { | |||
this.props.onChange(payload); | |||
this.props.onChange(null, payload); |
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.
Here you have the event (which can be null), just pass it.
With that you can even remove this if/elseif/else by
if (this.props.onChange) {
this.props.onChange(event, payload);
}
packages/forms/src/Form.js
Outdated
@@ -132,6 +132,9 @@ class Form extends React.Component { | |||
} | |||
return <UIForm {...props} />; | |||
} | |||
if (Array.isArray(this.props.data.uiSchema)) { |
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.
Not a big deal, but isn't that the most determinant condition ? If so it should be the first test in the render
method.
- if it's uiSpec v1 --> render directly the UIForm with all the props
- if we have the uiForm flag, it means that we have uiSpec v0 but we want to use UIForm --> widget adaptation and render UIForm
- else render RJSFForm
packages/forms/src/Form.test.js
Outdated
@@ -373,3 +375,17 @@ describe('<Form/>', () => { | |||
}); | |||
}); | |||
}); | |||
|
|||
describe('<UIForm/>', () => { |
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.
No need for another describe
because you're still testing <Form>
. Please move the test in the previous describe
.
packages/forms/src/Form.test.js
Outdated
props = initProps(); | ||
}); | ||
|
||
it('should render uiform', () => { |
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.
should render UIForm with uiSchema array format
?
…//github.com/Talend/ui into jmfrancois/fix/forms/better-switch-to-uiform
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, works on catalog
const props = initProps(); | ||
// when | ||
wrapper = shallow(<Form data={dataUIForm} {...props} />); | ||
expect(wrapper.getElement()).toMatchSnapshot(); |
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.
The shallow snapshot doesn't check that we have a UIForm.
- Don't forget to check the snapshot when you write/modify one
- Here you can check that without snapshot (which will log a lot more info than what you want to test)
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.
My bad I will learn to read
What is the problem this PR is trying to solve?
What is the chosen solution to this problem?
props.onChange(...args)
props.onChange(null, ...args)
props.onSubmit(changes)
props.onSubmit(null, changes)
This last change can impact projects using directly the component Form.js
To summarize : Now we can have three cases with usage of Form container
Please check if the PR fulfills these requirements
[ ] This PR introduces a breaking change