-
Notifications
You must be signed in to change notification settings - Fork 286
/
InstalledProductsCard.js
45 lines (41 loc) · 1.28 KB
/
InstalledProductsCard.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import React from 'react';
import PropTypes from 'prop-types';
import { translate as __ } from 'foremanReact/common/I18n';
import { List, ListItem } from '@patternfly/react-core';
import CardTemplate from 'foremanReact/components/HostDetails/Templates/CardItem/CardTemplate';
const InstalledProductsCard = ({ isExpandedGlobal, hostDetails }) => {
const installedProducts = hostDetails?.subscription_facet_attributes?.installed_products;
if (!installedProducts?.length) return null;
return (
<CardTemplate
header={__('Installed products')}
expandable
masonryLayout
isExpandedGlobal={isExpandedGlobal}
>
<List isPlain>
{installedProducts.map(product => (
<ListItem key={product.productId}>
{product.productName}
</ListItem>
))}
</List>
</CardTemplate>
);
};
InstalledProductsCard.propTypes = {
isExpandedGlobal: PropTypes.bool,
hostDetails: PropTypes.shape({
subscription_facet_attributes: PropTypes.shape({
installed_products: PropTypes.arrayOf(PropTypes.shape({
productId: PropTypes.string,
productName: PropTypes.string,
})),
}),
}),
};
InstalledProductsCard.defaultProps = {
isExpandedGlobal: false,
hostDetails: {},
};
export default InstalledProductsCard;