Skip to content
This repository was archived by the owner on Aug 25, 2021. It is now read-only.

Conversation

@martinpovolny
Copy link
Member

The primary goal of this PR is to export more components that need to be used one-by-one in the ManageIQ.

Secondary, more tests and storybooks are provided.

@miq-bot
Copy link
Member

miq-bot commented May 22, 2018

Checked commits martinpovolny/react-ui-components@67625ac~...f35d04f with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
0 files checked, 0 offenses detected
Everything looks fine. 👍

image: PropTypes.string,
icon: PropTypes.string,
value: PropTypes.any,
label: PropTypes.any,
Copy link
Contributor

Choose a reason for hiding this comment

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

We should avoid using PropTypes.any. I know that sometimes it can be difficult, especially dorm some dynamic objects, but props like label should be defined properly.

Also, if you don't mark object attributes as required, prop validation will pass even for empty object. If there are some conditions, when should be attribute required, and whet it should be undefined, you can create custom prop validator. You can check this example: https://reactjs.org/docs/typechecking-with-proptypes.html

Copy link
Member Author

@martinpovolny martinpovolny May 22, 2018

Choose a reason for hiding this comment

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

Right. I did not describe all the data types in a lot of detail. I plan to improve that in follow up PRs. Together with the use of patternfly-react components where applicable.

storiesOf('TextualSummary', module)
.add('GenericGroup', () => {
return (
<GenericGroup items={genericGroupData.items} title={genericGroupData.title} onClick={e => null} />
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the purpose of onClick={e => null}? I would advise specifying this inside the GenericGroup component and simply don't pass any props.

You can use defaultProps of that component. Something like

GenericGroup.propTypes = {
  onClick: PropTypes.func
...
}

GenericGroup.defaultProps = {
  onClick: () => {}
}

Copy link
Member Author

Choose a reason for hiding this comment

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

For a real use the onClick is mandatory. In the Storybook, I don't care.

I can replace it with some alert("You clicked!") if you want. But it looks silly.

No I don't want to have a default value. For a real use there needs to be a handler.

See https://github.com/ManageIQ/manageiq-ui-classic/pull/3420/files#diff-ea54a250fdb683370b39733f087cfbdeR5

There I have a default on-click handler. BUT: that behavior is manageiq-ui-classic specific internal. For that reason it's there and not here.

Does that address your concerns?

Copy link
Contributor

@Hyperkid123 Hyperkid123 May 23, 2018

Choose a reason for hiding this comment

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

Ahh ok i remember now. I thought that there is some rule. Never mind then.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't like e => null as well, since it does not give any information to user of such storybook. Can you please use https://github.com/storybooks/storybook/tree/master/addons/actions so the action is logged at least into storybook action list?

<MultilinkTable
title={multilinkTableData.title}
items={multilinkTableData.items}
onClick={e => null}
Copy link
Contributor

Choose a reason for hiding this comment

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

again e => null, not a fan

Copy link
Member Author

Choose a reason for hiding this comment

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

The explanation remains the same here ;-)

@Hyperkid123
Copy link
Contributor

@karelhala can you merge this?

Copy link
Contributor

@karelhala karelhala left a comment

Choose a reason for hiding this comment

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

Overall looks good, just small change with logging click action to storybook action list.

storiesOf('TextualSummary', module)
.add('GenericGroup', () => {
return (
<GenericGroup items={genericGroupData.items} title={genericGroupData.title} onClick={e => null} />
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't like e => null as well, since it does not give any information to user of such storybook. Can you please use https://github.com/storybooks/storybook/tree/master/addons/actions so the action is logged at least into storybook action list?

@himdel himdel self-assigned this May 23, 2018
@himdel himdel merged commit 8ca0bf7 into ManageIQ:master May 23, 2018
@himdel
Copy link
Contributor

himdel commented May 23, 2018

Uh, sorry, timing :) so .. what Karel said :)

@karelhala
Copy link
Contributor

Btw @martinpovolny if you want to show this storybook to outsiders, you can do it by using http://netlify.com from your repository and with build command as npm run vendor; npm run build-storybook. Once the first build starts to run you can add deploy to all branches you push to your repository.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants