Skip to content

Commit

Permalink
Fixes #34816 - Add Installed Products card (#10075)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremylenz authored Apr 26, 2022
1 parent ffda83f commit a26097c
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,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
overrideGridProps={{ rowSpan: 2 }}
header={__('Installed products')}
expandable
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;
2 changes: 2 additions & 0 deletions webpack/global_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import RegistrationCommands from './components/extensions/RegistrationCommands';
import ContentTab from './components/extensions/HostDetails/Tabs/ContentTab';
import ContentViewDetailsCard from './components/extensions/HostDetails/Cards/ContentViewDetailsCard/ContentViewDetailsCard';
import ErrataOverviewCard from './components/extensions/HostDetails/Cards/ErrataOverviewCard';
import InstalledProductsCard from './components/extensions/HostDetails/DetailsTabCards/InstalledProductsCard';

// import SubscriptionTab from './components/extensions/HostDetails/Tabs/SubscriptionTab';
import RepositorySetsTab from './components/extensions/HostDetails/Tabs/RepositorySetsTab/RepositorySetsTab';
Expand Down Expand Up @@ -41,3 +42,4 @@ addGlobalFill(
700,
);
addGlobalFill('details-cards', 'Installable errata', <ErrataOverviewCard key="errata-overview" />, 1900);
addGlobalFill('host-tab-details-cards', 'Installed products', <InstalledProductsCard key="installed-products" />, 100);

0 comments on commit a26097c

Please sign in to comment.