diff --git a/webpack/ForemanRhCloudFills.js b/webpack/ForemanRhCloudFills.js index cc190926..9d1eb86c 100644 --- a/webpack/ForemanRhCloudFills.js +++ b/webpack/ForemanRhCloudFills.js @@ -2,7 +2,8 @@ import React from 'react'; import { addGlobalFill } from 'foremanReact/components/common/Fill/GlobalFill'; import InventoryAutoUploadSwitcher from './ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload'; import NewHostDetailsTab from './InsightsHostDetailsTab/NewHostDetailsTab'; -import InsightsTotalRiskCard from './InsightsHostDetailsTab/InsightsTotalRiskChart'; +import { InsightsTotalRiskChartWrapper } from './InsightsHostDetailsTab/InsightsTotalRiskChartWrapper'; +import { isNotRhelHost } from './ForemanRhCloudHelpers'; const fills = [ { @@ -16,22 +17,27 @@ const fills = [ name: 'Insights', component: props => , weight: 400, + metadata: { + hideTab: isNotRhelHost, + }, }, { slot: 'host-overview-cards', name: 'insights-total-risk-chart', - component: props => , + component: props => , weight: 2800, }, ]; export const registerFills = () => { - fills.forEach(({ slot, name, component: Component, weight }, index) => - addGlobalFill( - slot, - name, - , - weight - ) + fills.forEach( + ({ slot, name, component: Component, weight, metadata }, index) => + addGlobalFill( + slot, + name, + , + weight, + metadata + ) ); }; diff --git a/webpack/ForemanRhCloudHelpers.js b/webpack/ForemanRhCloudHelpers.js index 8d65788d..fe81fcde 100644 --- a/webpack/ForemanRhCloudHelpers.js +++ b/webpack/ForemanRhCloudHelpers.js @@ -4,3 +4,7 @@ * should be imported once core moves it to the ReactApp folder. */ export const foremanUrl = path => `${window.URL_PREFIX}${path}`; + +export const isNotRhelHost = ({ hostDetails }) => + // eslint-disable-next-line camelcase + !new RegExp('red\\s?hat', 'i').test(hostDetails?.operatingsystem_name); diff --git a/webpack/InsightsHostDetailsTab/InsightsTotalRiskChartWrapper.js b/webpack/InsightsHostDetailsTab/InsightsTotalRiskChartWrapper.js new file mode 100644 index 00000000..3e24043f --- /dev/null +++ b/webpack/InsightsHostDetailsTab/InsightsTotalRiskChartWrapper.js @@ -0,0 +1,23 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import InsightsTotalRiskChart from './InsightsTotalRiskChart'; +import { isNotRhelHost } from '../ForemanRhCloudHelpers'; + +export const InsightsTotalRiskChartWrapper = props => { + if (props.status === 'RESOLVED') { + return ( + !isNotRhelHost(props.hostDetails) && // check for RHEL hosts + ); + } + return null; +}; + +InsightsTotalRiskChartWrapper.propTypes = { + status: PropTypes.string, + hostDetails: PropTypes.object, +}; + +InsightsTotalRiskChartWrapper.defaultProps = { + status: 'PENDING', + hostDetails: {}, +};