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

Conversation

@martinpovolny
Copy link
Member

This is a continuation of ManageIQ/manageiq-ui-classic#3420

  • I am moving the components to the components repo, trying to decouple the specifics.
  • Adding more specs,
  • Adding simple storybook

"dependencies": {
"lodash": "^4.17.4",
"patternfly-react": "^1.8.0",
"patternfly-react": "^1.16.4",
Copy link
Member

Choose a reason for hiding this comment

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

might make sense to bump to 2.x as it already introduced api changes (for something we dont use yet - but can't see the value of using an older version now).

Copy link
Member Author

@martinpovolny martinpovolny May 3, 2018

Choose a reason for hiding this comment

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

I need this compatible with ui-classic. The goal is to replace TextualSummaries in ui-classic. UI-classic is on 1.X.

title: 'Operation Ranges',
items: [
{
label: 'CPU',
Copy link
Member

Choose a reason for hiding this comment

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

should these strings be extracted? or are they used as props somewhere else?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is test data. It is used in stories and tests.


export default function EmptyGroup(props) {
return (
<table className="table table-bordered table-striped table-summary-screen">
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

I can do it, but not in the first implementation. My goal in this PR is to create React components from HAML files.

@ohadlevy
Copy link
Member

ohadlevy commented May 3, 2018 via email

@martinpovolny
Copy link
Member Author

  1. I don't think that this is a problem I have.
  2. I have other things that I need to do now.
  3. Size (scope) of a PR is to be limited. A step at a time. I am already splitting the original PR into 4 parts. I don't feel I should be adding more to the scope now.

@miq-bot
Copy link
Member

miq-bot commented May 3, 2018

This pull request is not mergeable. Please rebase and repush.

import TableListView from './table_list_view';
import EmptyGroup from './empty_group';

const renderComponent = (props) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe rewriting this to hash might be better than using switch

const componentMapper = {
  GenericGroup: props => (
    <GenericGroup onClick={props.onClick} items={props.group.items} title={props.group.title} />
  ),
  TagGroup: props => <TagGroup items={props.group.items} title={props.group.title} />,
  SimpleTable: props => (
    <SimpleTable
      labels={props.group.labels}
      rows={props.group.rows}
      title={props.group.title}
    />
  ),
  OperationRanges: props => <OperationRanges items={props.group.items} title={props.group.title} />,
  MultilinkTable: props => (
    <MultilinkTable
      onClick={props.onClick}
      items={props.group.items}
      title={props.group.title}
    />
  ),
  TableListView: props => (
    <TableListView
      rowLabel={props.group.rowLabel}
      onClick={props.onClick}
      title={props.group.title}
      headers={props.group.headers}
      values={props.group.values}
      colOrder={props.group.colOrder}
    />
  ),
  EmptyGroup: props => <EmptyGroup title={props.group.title} text={props.group.text} />
};

That way you can specify which component is using which propTypes

componentMapper.GenericGroup.propTypes = {
  group: PropTypes.shape({
    title: PropTypes.string.isRequired,
    items: PropTypes.any,
  }).isRequired,
  onClick: PropTypes.func.isRequired,
};

componentMapper.TagGroup.propTypes = {
  group: PropTypes.shape({
    title: PropTypes.string.isRequired,
    items: PropTypes.any,
  }).isRequired,
};

Or use spread operator and inherit these properties.

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe rewriting this to hash might be better than using switch

If you mean a simple hash, that it would not work, because a hash is not lazy evaluated. All the branches would get called and then the apropriate result would be selected. So that approach would crash on the propTypes mismatch (different case branches need diffferent properties).

Copy link
Member Author

@martinpovolny martinpovolny May 3, 2018

Choose a reason for hiding this comment

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

Oh, you mean a hash of functions. Then yes, it would work but is a hash of functions actually better than what I have now?

Copy link
Member Author

Choose a reason for hiding this comment

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

Anyway. If it's a 'maybe changing it will look better' then I am not changing it unless you insist. I see the difference as marginal.

@miq-bot
Copy link
Member

miq-bot commented May 7, 2018

Checked commits martinpovolny/react-ui-components@a143eb5~...2b22d5f 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. 🍪

@karelhala karelhala merged commit 5a37fb8 into ManageIQ:master May 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants