Skip to content

Commit

Permalink
fix(inventoryList): issues/10 missing platform component (#385)
Browse files Browse the repository at this point in the history
  • Loading branch information
cdcabrera committed Sep 29, 2020
1 parent 62141ec commit 189ff58
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,18 @@ exports[`InventoryList Component should handle variations in data: filtered data
<CardFooter
className=""
>
<Connect(Pagination)
dropDirection="up"
isDisabled={false}
itemCount={0}
perPageDefault={10}
productId="lorem"
viewId="inventoryList"
/>
<TableToolbar
isFooter={true}
>
<Connect(Pagination)
dropDirection="up"
isDisabled={false}
itemCount={0}
perPageDefault={10}
productId="lorem"
viewId="inventoryList"
/>
</TableToolbar>
</CardFooter>
</Card>
`;
Expand Down Expand Up @@ -137,14 +141,18 @@ exports[`InventoryList Component should handle variations in data: variable data
<CardFooter
className=""
>
<Connect(Pagination)
dropDirection="up"
isDisabled={false}
itemCount={0}
perPageDefault={10}
productId="lorem"
viewId="inventoryList"
/>
<TableToolbar
isFooter={true}
>
<Connect(Pagination)
dropDirection="up"
isDisabled={false}
itemCount={0}
perPageDefault={10}
productId="lorem"
viewId="inventoryList"
/>
</TableToolbar>
</CardFooter>
</Card>
`;
Expand Down Expand Up @@ -193,14 +201,18 @@ exports[`InventoryList Component should render a non-connected component: non-co
<CardFooter
className=""
>
<Connect(Pagination)
dropDirection="up"
isDisabled={false}
itemCount={0}
perPageDefault={10}
productId="lorem"
viewId="inventoryList"
/>
<TableToolbar
isFooter={true}
>
<Connect(Pagination)
dropDirection="up"
isDisabled={false}
itemCount={0}
perPageDefault={10}
productId="lorem"
viewId="inventoryList"
/>
</TableToolbar>
</CardFooter>
</Card>
`;
47 changes: 39 additions & 8 deletions src/components/inventoryList/inventoryList.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
import _isEqual from 'lodash/isEqual';
import { TableVariant } from '@patternfly/react-table';
import { Card, CardActions, CardBody, CardFooter, CardHeader, CardTitle, Title } from '@patternfly/react-core';
import { TableToolbar } from '@redhat-cloud-services/frontend-components/components/cjs/TableToolbar';
import { helpers } from '../../common';
import { connect, reduxActions, reduxSelectors } from '../../redux';
import Table from '../table/table';
Expand All @@ -11,6 +12,11 @@ import { inventoryListHelpers } from './inventoryListHelpers';
import Pagination from '../pagination/pagination';
import { RHSM_API_QUERY_TYPES } from '../../types/rhsmApiTypes';

/**
* A system inventory component.
*
* @augments React.Component
*/
class InventoryList extends React.Component {
componentDidMount() {
this.onUpdateInventoryData();
Expand All @@ -32,6 +38,11 @@ class InventoryList extends React.Component {
}
};

/**
* Render an inventory table.
*
* @returns {Node}
*/
renderTable() {
const { filterInventoryData, listData } = this.props;
let updatedColumnHeaders = [];
Expand Down Expand Up @@ -60,6 +71,11 @@ class InventoryList extends React.Component {
);
}

/**
* Render an inventory card.
*
* @returns {Node}
*/
render() {
const {
cardTitle,
Expand Down Expand Up @@ -118,20 +134,29 @@ class InventoryList extends React.Component {
</div>
</CardBody>
<CardFooter className={(error && 'blur') || ''}>
<Pagination
isDisabled={pending || error}
itemCount={itemCount}
productId={productId}
viewId={viewId}
perPageDefault={updatedPerPage}
dropDirection="up"
/>
<TableToolbar isFooter>
<Pagination
isDisabled={pending || error}
itemCount={itemCount}
productId={productId}
viewId={viewId}
perPageDefault={updatedPerPage}
dropDirection="up"
/>
</TableToolbar>
</CardFooter>
</Card>
);
}
}

/**
* Prop types.
*
* @type {{viewId: string, productId: string, filterInventoryData: Array, listData: Array, pending: boolean, query: object,
* getHostsInventory: Function, perPageDefault: number, isDisabled: boolean, error: boolean, cardTitle: string,
* itemCount: number}}
*/
InventoryList.propTypes = {
error: PropTypes.bool,
cardTitle: PropTypes.string,
Expand Down Expand Up @@ -163,6 +188,12 @@ InventoryList.propTypes = {
viewId: PropTypes.string
};

/**
* Default props.
*
* @type {{viewId: string, filterInventoryData: Array, listData: Array, pending: boolean, getHostsInventory: Function,
* perPageDefault: number, isDisabled: boolean, error: boolean, cardTitle: null, itemCount: number}}
*/
InventoryList.defaultProps = {
error: false,
cardTitle: null,
Expand Down

0 comments on commit 189ff58

Please sign in to comment.