Skip to content
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 78 commits into from
Jun 7, 2017
Merged
Show file tree
Hide file tree
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 Apr 27, 2017
6f0f362
Dependency : talend-json-schema-form-core
jsomsanith May 9, 2017
cf7ba60
Bump schema form core version
jsomsanith May 10, 2017
5356a01
Integrate simple text field with validation, description, placeholder…
jsomsanith May 10, 2017
dac6b4e
Rename file
jsomsanith May 11, 2017
dd4b1ba
Add structured model story
jsomsanith May 11, 2017
7e39984
Move info in schemas
jsomsanith May 11, 2017
f7fc2d0
Fieldsets
jsomsanith May 11, 2017
400040f
Tabs
jsomsanith May 11, 2017
2512674
Remove unnecessery arrow functions
jsomsanith May 11, 2017
0dda421
Trigger after
jsomsanith May 12, 2017
1ded597
Add role on message
jsomsanith May 15, 2017
51f54ea
Custom validation
jsomsanith-tlnd May 15, 2017
1830168
test(ci): update code style outputs
May 15, 2017
7ec9032
Clean
jsomsanith-tlnd May 15, 2017
0463505
Split UIForm component and base state change on reducers
jsomsanith-tlnd May 15, 2017
2766c30
test(ci): update code style outputs
May 16, 2017
bc9b56a
Redux connection implem
jsomsanith-tlnd May 16, 2017
d547e87
test(ci): update code style outputs
May 16, 2017
cc546ac
Use reducer in container
jsomsanith-tlnd May 16, 2017
ab5ff8a
test(ci): update code style outputs
May 16, 2017
9f3f7f0
Add autoFocus feature
jsomsanith-tlnd May 18, 2017
d226a6c
Set submit intelligence in component
jsomsanith-tlnd May 18, 2017
fd81b52
Trigger on buttons
jsomsanith-tlnd May 18, 2017
d86502f
test(ci): update code style outputs
May 18, 2017
324c312
Align onChange api to onTrigger
jsomsanith-tlnd May 18, 2017
db352cf
Trigger form change
jsomsanith-tlnd May 18, 2017
ffea877
test(ci): update code style outputs
May 18, 2017
8a5e149
Uniformize callbacks args, proper trigger management
jsomsanith May 18, 2017
8166191
test(ci): update code style outputs
May 18, 2017
47d9452
Improve form change consolidation
jsomsanith-tlnd May 19, 2017
0a47b84
Custom widgets
jsomsanith-tlnd May 19, 2017
1e52f35
Prefix redux actions, add README
jsomsanith-tlnd May 19, 2017
5405b1f
Merge master on branch
jsomsanith-tlnd May 22, 2017
8c7f241
test(ci): update code style outputs
May 22, 2017
a5f6f14
Add text disabled mode
jsomsanith-tlnd May 22, 2017
beb4b14
fix(theme) : input colors
jsomsanith-tlnd May 22, 2017
91bfac1
Merge branch 'master' into jmfrancois/forms-uischema-refactor
jsomsanith-tlnd May 22, 2017
b31228d
Add id
jsomsanith Jun 2, 2017
ae655d2
Change validate(All) to setError(s)
jsomsanith Jun 2, 2017
918bc05
Add more details in comment
jsomsanith Jun 2, 2017
d52186d
Add test for redux actions
Jun 2, 2017
bed7260
Merge remote-tracking branch 'origin/jmfrancois/forms-uischema-refact…
Jun 2, 2017
f6204ac
Fit unit tests
jsomsanith Jun 2, 2017
c0030ba
test(ci): update screenshots
Jun 2, 2017
64c6b9a
test(ci): update code style outputs
Jun 2, 2017
e341f87
Unit tests
jsomsanith Jun 2, 2017
82b44b8
test(ci): update code style outputs
Jun 4, 2017
74dd53a
Unit tests on model reducers
jsomsanith-tlnd Jun 5, 2017
343c097
Unit tests on validations reducers
jsomsanith-tlnd Jun 5, 2017
bb6ff02
OnFormChange --> updateForm
jsomsanith-tlnd Jun 5, 2017
84c9436
mutateValue --> updateFormData
jsomsanith-tlnd Jun 5, 2017
75459f7
Utils unit tests
jsomsanith-tlnd Jun 5, 2017
12bdd2c
Message unit tests
jsomsanith-tlnd Jun 5, 2017
2ef3c5e
Widget unit tests
jsomsanith-tlnd Jun 5, 2017
c9b456a
Fields widgets unit tests
jsomsanith-tlnd Jun 5, 2017
38f131f
Fieldsets unit tests
jsomsanith-tlnd Jun 5, 2017
15033d4
Start UIForm component unit tests
jsomsanith-tlnd Jun 5, 2017
75a94aa
test(ci): update code style outputs
Jun 5, 2017
985c923
Continue UIForm component unit tests
jsomsanith Jun 5, 2017
4d59b5b
test(ci): update code style outputs
Jun 5, 2017
cb62f45
UIForm component unit tests
jsomsanith-tlnd Jun 6, 2017
5d38875
UIForm container unit tests
jsomsanith-tlnd Jun 6, 2017
ee44a89
UIForm connect unit tests
jsomsanith-tlnd Jun 6, 2017
25826cf
Export triggers
jsomsanith Jun 6, 2017
0c41a45
Several changes after review
jsomsanith Jun 6, 2017
ddde2b6
Several changes after review
jsomsanith Jun 7, 2017
1e3e2f5
Suppress unwanted lint error
jsomsanith Jun 7, 2017
0c4e75a
Update snapshots
jsomsanith Jun 7, 2017
3a93ed7
test(ci): update code style outputs
Jun 7, 2017
ca567ac
Make the old and new stories works in the storybook
jsomsanith Jun 7, 2017
14f5e5a
Use classNames
jsomsanith Jun 7, 2017
f1aa008
Merge master
jsomsanith Jun 7, 2017
ee48ec7
Update snapshot
jsomsanith Jun 7, 2017
9914da8
Revert breaking changes log
jsomsanith Jun 7, 2017
bbb51a6
test(ci): update code style outputs
Jun 7, 2017
86eb719
Merge branch 'master' into jmfrancois/forms-uischema-refactor
jsomsanith-tlnd Jun 7, 2017
733f375
test(ci): update code style outputs
Jun 7, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/forms/.storybook/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ setAddon(infoAddon);

function loadStories() {
require('../stories');
require('../stories-core');
}

configure(loadStories, module);
99 changes: 99 additions & 0 deletions packages/forms/__mocks__/data.js
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);
}
10 changes: 8 additions & 2 deletions packages/forms/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,12 @@
"react-bootstrap": "^0.30.3",
"react-css-transition": "^0.7.4",
"react-dom": "^15.4.0",
"react-redux": "^5.0.4",
"react-talend-components": "^0.79.0",
"react-test-renderer": "15.4.0",
"react-virtualized": "^9.1.0",
"redux": "^3.6.0",
"redux-mock-store": "^1.2.3",
"rimraf": "^2.5.4",
"sass-lint": "^1.10.2",
"sass-loader": "^4.1.1",
Expand All @@ -60,13 +63,16 @@
"classnames": "^2.2.5",
"keycode": "^2.1.8",
"react-autowhatever": "^7.0.0",
"react-jsonschema-form": "^0.42.0"
"react-jsonschema-form": "^0.42.0",
"talend-json-schema-form-core": "1.0.2-alpha.2"
},
"peerDependencies": {
"react": "^15.4.0",
"react-bootstrap": "^0.30.3",
"react-dom": "^15.4.0",
"react-talend-components": "^0.79.0"
"react-redux": "^5.0.4",
"react-talend-components": "^0.79.0",
"redux": "^3.6.0"
},
"scripts": {
"prepublish": "rimraf lib && babel -d lib ./src/ && cpx \"./src/**/*.scss\" lib",
Expand Down
29 changes: 29 additions & 0 deletions packages/forms/src/UIForm/Message/Message.component.js
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"
Copy link
Contributor

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 packages/forms/src/UIForm/Message/Message.component.test.js
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();
});
});
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>
`;
3 changes: 3 additions & 0 deletions packages/forms/src/UIForm/Message/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Message from './Message.component';

export default Message;
Loading