-
Notifications
You must be signed in to change notification settings - Fork 54
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
feat(Forms) : rendering lib based on json-schema-form-core #415
Merged
Merged
Changes from 75 commits
Commits
Show all changes
78 commits
Select commit
Hold shift + click to select a range
9013edc
chore: start trying a refactor
jmfrancois 6f0f362
Dependency : talend-json-schema-form-core
jsomsanith cf7ba60
Bump schema form core version
jsomsanith 5356a01
Integrate simple text field with validation, description, placeholder…
jsomsanith dac6b4e
Rename file
jsomsanith dd4b1ba
Add structured model story
jsomsanith 7e39984
Move info in schemas
jsomsanith f7fc2d0
Fieldsets
jsomsanith 400040f
Tabs
jsomsanith 2512674
Remove unnecessery arrow functions
jsomsanith 0dda421
Trigger after
jsomsanith 1ded597
Add role on message
jsomsanith 51f54ea
Custom validation
jsomsanith-tlnd 1830168
test(ci): update code style outputs
7ec9032
Clean
jsomsanith-tlnd 0463505
Split UIForm component and base state change on reducers
jsomsanith-tlnd 2766c30
test(ci): update code style outputs
bc9b56a
Redux connection implem
jsomsanith-tlnd d547e87
test(ci): update code style outputs
cc546ac
Use reducer in container
jsomsanith-tlnd ab5ff8a
test(ci): update code style outputs
9f3f7f0
Add autoFocus feature
jsomsanith-tlnd d226a6c
Set submit intelligence in component
jsomsanith-tlnd fd81b52
Trigger on buttons
jsomsanith-tlnd d86502f
test(ci): update code style outputs
324c312
Align onChange api to onTrigger
jsomsanith-tlnd db352cf
Trigger form change
jsomsanith-tlnd ffea877
test(ci): update code style outputs
8a5e149
Uniformize callbacks args, proper trigger management
jsomsanith 8166191
test(ci): update code style outputs
47d9452
Improve form change consolidation
jsomsanith-tlnd 0a47b84
Custom widgets
jsomsanith-tlnd 1e52f35
Prefix redux actions, add README
jsomsanith-tlnd 5405b1f
Merge master on branch
jsomsanith-tlnd 8c7f241
test(ci): update code style outputs
a5f6f14
Add text disabled mode
jsomsanith-tlnd beb4b14
fix(theme) : input colors
jsomsanith-tlnd 91bfac1
Merge branch 'master' into jmfrancois/forms-uischema-refactor
jsomsanith-tlnd b31228d
Add id
jsomsanith ae655d2
Change validate(All) to setError(s)
jsomsanith 918bc05
Add more details in comment
jsomsanith d52186d
Add test for redux actions
bed7260
Merge remote-tracking branch 'origin/jmfrancois/forms-uischema-refact…
f6204ac
Fit unit tests
jsomsanith c0030ba
test(ci): update screenshots
64c6b9a
test(ci): update code style outputs
e341f87
Unit tests
jsomsanith 82b44b8
test(ci): update code style outputs
74dd53a
Unit tests on model reducers
jsomsanith-tlnd 343c097
Unit tests on validations reducers
jsomsanith-tlnd bb6ff02
OnFormChange --> updateForm
jsomsanith-tlnd 84c9436
mutateValue --> updateFormData
jsomsanith-tlnd 75459f7
Utils unit tests
jsomsanith-tlnd 12bdd2c
Message unit tests
jsomsanith-tlnd 2ef3c5e
Widget unit tests
jsomsanith-tlnd c9b456a
Fields widgets unit tests
jsomsanith-tlnd 38f131f
Fieldsets unit tests
jsomsanith-tlnd 15033d4
Start UIForm component unit tests
jsomsanith-tlnd 75a94aa
test(ci): update code style outputs
985c923
Continue UIForm component unit tests
jsomsanith 4d59b5b
test(ci): update code style outputs
cb62f45
UIForm component unit tests
jsomsanith-tlnd 5d38875
UIForm container unit tests
jsomsanith-tlnd ee44a89
UIForm connect unit tests
jsomsanith-tlnd 25826cf
Export triggers
jsomsanith 0c41a45
Several changes after review
jsomsanith ddde2b6
Several changes after review
jsomsanith 1e3e2f5
Suppress unwanted lint error
jsomsanith 0c4e75a
Update snapshots
jsomsanith 3a93ed7
test(ci): update code style outputs
ca567ac
Make the old and new stories works in the storybook
jsomsanith 14f5e5a
Use classNames
jsomsanith f1aa008
Merge master
jsomsanith ee48ec7
Update snapshot
jsomsanith 9914da8
Revert breaking changes log
jsomsanith bbb51a6
test(ci): update code style outputs
86eb719
Merge branch 'master' into jmfrancois/forms-uischema-refactor
jsomsanith-tlnd 733f375
test(ci): update code style outputs
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import React from 'react'; | ||
import configureMockStore from 'redux-mock-store'; | ||
|
||
export const data = { | ||
jsonSchema: { | ||
type: 'object', | ||
title: 'Comment', | ||
properties: { | ||
lastname: { | ||
type: 'string', | ||
minLength: 10, | ||
}, | ||
firstname: { | ||
type: 'string', | ||
}, | ||
check: {}, | ||
}, | ||
required: [ | ||
'firstname', | ||
], | ||
}, | ||
uiSchema: [ | ||
{ | ||
key: 'lastname', | ||
title: 'Last Name (with description)', | ||
description: 'Hint: this is the last name', | ||
autoFocus: true, | ||
}, | ||
{ | ||
key: 'firstname', | ||
title: 'First Name (with placeholder)', | ||
placeholder: 'Enter your firstname here', | ||
triggers: ['after'], | ||
}, | ||
{ | ||
key: 'check', | ||
type: 'button', | ||
title: 'Check the thing', | ||
triggers: ['after'], | ||
}, | ||
], | ||
properties: {}, | ||
errors: {}, | ||
}; | ||
|
||
export const mergedSchema = [ | ||
{ | ||
autoFocus: true, | ||
description: 'Hint: this is the last name', | ||
key: ['lastname'], | ||
minlength: 10, | ||
ngModelOptions: {}, | ||
schema: { minLength: 10, type: 'string' }, | ||
title: 'Last Name (with description)', | ||
type: 'text', | ||
}, | ||
{ | ||
key: ['firstname'], | ||
ngModelOptions: {}, | ||
placeholder: 'Enter your firstname here', | ||
required: true, | ||
schema: { type: 'string' }, | ||
title: 'First Name (with placeholder)', | ||
triggers: ['after'], | ||
type: 'text', | ||
}, | ||
{ | ||
key: ['check'], | ||
title: 'Check the thing', | ||
triggers: ['after'], | ||
type: 'button', | ||
}, | ||
]; | ||
|
||
export function initProps() { | ||
return { | ||
autoComplete: 'off', | ||
customValidation: jest.fn(), | ||
formName: 'myFormName', | ||
id: 'myFormId', | ||
onChange: jest.fn(), | ||
onSubmit: jest.fn(), | ||
onTrigger: jest.fn(), | ||
widgets: { | ||
custom: () => (<div>Custom</div>), | ||
}, | ||
}; | ||
} | ||
|
||
export function initStore(formName, form) { | ||
const mockStore = configureMockStore(); | ||
const state = { forms: {} }; | ||
|
||
if (formName && form) { | ||
state.forms[formName] = { ...form }; | ||
} | ||
|
||
return mockStore(state); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import React, { PropTypes } from 'react'; | ||
|
||
export default function Message(props) { | ||
const { | ||
errorMessage, | ||
description, | ||
isValid, | ||
} = props; | ||
|
||
const message = isValid ? description : errorMessage; | ||
return message ? | ||
( | ||
<p | ||
className="help-block" | ||
role="status" | ||
> | ||
{ message } | ||
</p> | ||
) : | ||
null; | ||
} | ||
|
||
if (process.env.NODE_ENV !== 'production') { | ||
Message.propTypes = { | ||
errorMessage: PropTypes.string, | ||
description: PropTypes.string, | ||
isValid: PropTypes.bool, | ||
}; | ||
} |
47 changes: 47 additions & 0 deletions
47
packages/forms/src/UIForm/Message/Message.component.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
|
||
import Message from './Message.component'; | ||
|
||
describe('Message component', () => { | ||
it('should render provided description if the field is valid', () => { | ||
// when | ||
const wrapper = shallow( | ||
<Message | ||
errorMessage={'My error message'} | ||
description={'My description'} | ||
isValid | ||
/> | ||
); | ||
|
||
// then | ||
expect(wrapper.node).toMatchSnapshot(); | ||
}); | ||
|
||
it('should render provided error message if the field is invalid', () => { | ||
// when | ||
const wrapper = shallow( | ||
<Message | ||
errorMessage={'My error message'} | ||
description={'My description'} | ||
isValid={false} | ||
/> | ||
); | ||
|
||
// then | ||
expect(wrapper.node).toMatchSnapshot(); | ||
}); | ||
|
||
it('should render nothing when field is valid and no description is provided', () => { | ||
// when | ||
const wrapper = shallow( | ||
<Message | ||
errorMessage={'My error message'} | ||
isValid | ||
/> | ||
); | ||
|
||
// then | ||
expect(wrapper.node).toMatchSnapshot(); | ||
}); | ||
}); |
17 changes: 17 additions & 0 deletions
17
packages/forms/src/UIForm/Message/__snapshots__/Message.component.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
exports[`Message component should render nothing when field is valid and no description is provided 1`] = `null`; | ||
|
||
exports[`Message component should render provided description if the field is valid 1`] = ` | ||
<p | ||
className="help-block" | ||
role="status"> | ||
My description | ||
</p> | ||
`; | ||
|
||
exports[`Message component should render provided error message if the field is invalid 1`] = ` | ||
<p | ||
className="help-block" | ||
role="status"> | ||
My error message | ||
</p> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import Message from './Message.component'; | ||
|
||
export default Message; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
You could use some Boostrap helper classes
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.
In fact I'm using Bootstrap Form Control Validation classes