Skip to content

Commit

Permalink
fix(ESSNTL-3760): handle insights disconnected hosts for patch, advis…
Browse files Browse the repository at this point in the history
…or, vuln tabs (#1791)

Co-authored-by: Aleksandr Voznesenskii <[email protected]>
  • Loading branch information
mkholjuraev and Fewwy committed Mar 29, 2023
1 parent 0d0632c commit c9b5d3f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/components/InventoryDetail/ApplicationDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ import React, { useState, useEffect, Suspense } from 'react';
import PropTypes from 'prop-types';
import { useSelector, useStore } from 'react-redux';
import { Tabs, Tab, Spinner, TabContent } from '@patternfly/react-core';
import { verifyCulledInsightsClient } from '../../Utilities/sharedFunctions';
import { getFact } from './helpers';
import { NotConnected } from '@redhat-cloud-services/frontend-components/NotConnected';

/**
* Component that renders tabs for each application detail and handles clicking on each item.
* @param {*} props onTabSelect can be used to notify parent component that detail has been selected.
*/
const ApplicationDetails = ({ onTabSelect, appList, activeApp, inventoryId, ...props }) => {
const ApplicationDetails = ({ onTabSelect, appList, activeApp, inventoryId, entity, ...props }) => {
const store = useStore();
const items = useSelector(({ entityDetails }) => {
return (entityDetails?.activeApps || appList || [])
Expand All @@ -31,6 +34,8 @@ const ApplicationDetails = ({ onTabSelect, appList, activeApp, inventoryId, ...p
}
}, [disabledApps]);

const isDisconnected = verifyCulledInsightsClient(getFact('per_reporter_staleness', entity));

return (
<React.Fragment>
<section className='pf-u-pr-lg pf-u-pl-lg pf-u-background-color-100-on-md'>
Expand Down Expand Up @@ -71,10 +76,12 @@ const ApplicationDetails = ({ onTabSelect, appList, activeApp, inventoryId, ...p
>
{item.name === currentApp && <Suspense fallback={Spinner}>
<section className='pf-c-page__main-section'>
<Cmp
inventoryId={inventoryId}
store={store}
/>
{isDisconnected && ['patch', 'vulnerabilities', 'advisor']
.includes(currentApp) ? <NotConnected/>
: <Cmp
inventoryId={inventoryId}
store={store}
/>}
</section>
</Suspense>}
</TabContent>
Expand All @@ -93,7 +100,8 @@ ApplicationDetails.propTypes = {
})),
onTabSelect: PropTypes.func,
activeApp: PropTypes.string.isRequired,
inventoryId: PropTypes.string.isRequired
inventoryId: PropTypes.string.isRequired,
entity: PropTypes.object
};

export default ApplicationDetails;
1 change: 1 addition & 0 deletions src/components/InventoryDetail/InventoryDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ const InventoryDetail = ({
activeApp={activeApp}
appList={appList}
inventoryId={inventoryId}
entity={entity}
/>
)}
</>)
Expand Down

0 comments on commit c9b5d3f

Please sign in to comment.