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(containers/editabletext): create container #1601

Merged

Conversation

ncomont
Copy link
Contributor

@ncomont ncomont commented Aug 8, 2018

What is the problem this PR is trying to solve?

EditableText has no container.

What is the chosen solution to this problem?

Create it.

Please check if the PR fulfills these requirements

  • The PR commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features) And non reg done before need review
  • Docs have been added / updated (for bug fixes / features)
  • Related design / discussions / pages (not in jira), if any, are all linked or available in the PR

[ ] This PR introduces a breaking change

@build-travis-ci
Copy link
Collaborator

:octocat: Demo is available here

@build-travis-ci
Copy link
Collaborator

:octocat: Demo is available here

@build-travis-ci
Copy link
Collaborator

:octocat: Demo is available here

1 similar comment
@build-travis-ci
Copy link
Collaborator

:octocat: Demo is available here

@build-travis-ci
Copy link
Collaborator

:octocat: Demo is available here

@build-travis-ci
Copy link
Collaborator

:octocat: Demo is available here

@build-travis-ci
Copy link
Collaborator

:octocat: Demo is available here

...rest
}) {
if (loading) {
return <Skeleton type={Skeleton.TYPES.text} size={Skeleton.SIZES.large} />;
}

const Renderer = Inject.getAll(getComponent, { EditableText });
Copy link
Contributor

Choose a reason for hiding this comment

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

Use const InjectedEditableText = Inject.get(getComponent, 'EditableText', EditableText)

</small>
)}
{subTitle && (
<small
Copy link
Contributor

Choose a reason for hiding this comment

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

Now this subTitle is rendered even if we are in edit mode. Is this wanted ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now the SubHeader component has no way to know if its EditableText is in editMode or not. I don't see other solution, but if you have suggestions I'll be glad to ear it

}
}

onChange(event) {
Copy link
Contributor

Choose a reason for hiding this comment

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

You removed all those methods but in the render you still refer to them instead of the props.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ow, thank you, fixed

* @param {object} state
* @param {string} idComponent
*/
export function getEditMode(state, idComponent) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Be careful this is a breaking change. This can impact the apps. Please communicate on this after the merge and fill properly https://github.com/Talend/ui/wiki/BREAKING-CHANGE

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👌

actionCreatorEdit: PropTypes.string,
actionCreatorSubmit: PropTypes.string,
actionCreatorChange: PropTypes.string,
actionCreatorGoBack: PropTypes.string,
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not used and is proper to SubHeader not Editable Text

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oops

}

onSubmit(event, data) {
this.props.setState(() => ({
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't need the function version, just call setState({ editMode: false })

Copy link
Contributor Author

Choose a reason for hiding this comment

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

}

onCancel(event) {
this.props.setState(() => ({
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

Copy link
Contributor Author

Choose a reason for hiding this comment

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


onEdit(event) {
this.props.setState(() => ({
editMode: !this.props.state.get('editMode', false),
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here, or take the state from the arguments instead of props.state

Copy link
Contributor

Choose a reason for hiding this comment

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

BTW this seems weird in fact, don't you want to set editMode to true instead of toggle it ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh you're probably right. I moved this code from the SubHeader container, but I agree, I don't see any reason to toggle it here. I corrected it, thanks.

setState: jest.fn(),
};
shallow(<Container {...props} />).simulate('submit', event, data);
expect(props.setState).toHaveBeenCalled();
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not necessary, you already tested it in the previous test

expect(props.onEdit).toHaveBeenCalledWith(event);
});
it('should call onEdit when edit event trigger', () => {
// Given
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add the // given/when/then separators everywhere or remove them everywhere within the file ?

import Container, { DEFAULT_STATE } from './EditableText.container';

export default cmfConnect({
componentId: ownProps => ownProps.id,
Copy link
Contributor

@jmfrancois jmfrancois Aug 10, 2018

Choose a reason for hiding this comment

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

please remove this, here you mix component id and id.
They have two different purpose:
id is for HTML
componentId is for CMF

props: this.props,
data,
});
}
Copy link
Contributor

Choose a reason for hiding this comment

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

you need this ? onSubmitActionCreator should work (become a onSubmit)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As discussed, this will cause a lot of breaking changes. Maybe we could do that in a second time...

*/
export function getComponentState(state, idComponent) {
return state.cmf.components.getIn([DISPLAY_NAME, idComponent], DEFAULT_STATE);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

now this is generated

@build-travis-ci
Copy link
Collaborator

:octocat: Demo is available here

1 similar comment
@build-travis-ci
Copy link
Collaborator

:octocat: Demo is available here

import Connect from './EditableText.connect';
import { getEditMode } from './EditableText.selectors';

describe('Connect', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I might be wrong, but I don't feel that this has any testing purpose around the current container

@build-travis-ci
Copy link
Collaborator

:octocat: Demo is available here

2 similar comments
@build-travis-ci
Copy link
Collaborator

:octocat: Demo is available here

@build-travis-ci
Copy link
Collaborator

:octocat: Demo is available here

@jsomsanith-tlnd jsomsanith-tlnd merged commit bfb75d0 into master Aug 13, 2018
@jsomsanith-tlnd jsomsanith-tlnd deleted the ncomont/feat/containers/editabletext/create_container branch August 13, 2018 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants