Sha256: c6495190af2d69101a2837ff47bc953004a64085c65bc1920200f5de8fc9313e

Contents?: true

Size: 1.59 KB

Versions: 60

Compression:

Stored size: 1.59 KB

Contents

import React from 'react';
import PropTypes from 'prop-types';
import { orderBy } from 'lodash';
import { Grid, ListView } from 'patternfly-react';
import { noop } from 'foremanReact/common/helpers';
import { translate as __ } from 'foremanReact/common/I18n';
import ListItem from './components/ListItem';
import './InsightsTab.scss';

class InsightsHostDetailsTab extends React.Component {
  componentDidMount() {
    const { fetchHits, hostID } = this.props;
    fetchHits(hostID);
  }

  render() {
    const { hits } = this.props;

    if (!hits.length) {
      return <h2>{__('No recommendations were found for this host!')}</h2>;
    }
    const hitsSorted = orderBy(hits, ['total_risk'], ['desc']);
    const items = hitsSorted.map(
      (
        {
          title,
          total_risk: totalRisk,
          results_url: resultsUrl,
          solution_url: solutionUrl,
        },
        index
      ) => (
        <ListItem
          key={index}
          title={title}
          totalRisk={totalRisk}
          resultsUrl={resultsUrl}
          solutionUrl={solutionUrl}
        />
      )
    );
    return (
      <div id="host_details_insights_tab">
        <Grid.Row>
          <Grid.Col xs={12}>
            <h2>{__('Recommendations')}</h2>
            <ListView id="hits_list">{items}</ListView>
          </Grid.Col>
        </Grid.Row>
      </div>
    );
  }
}

InsightsHostDetailsTab.propTypes = {
  hostID: PropTypes.number.isRequired,
  fetchHits: PropTypes.func,
  hits: PropTypes.array,
};

InsightsHostDetailsTab.defaultProps = {
  fetchHits: noop,
  hits: [],
};

export default InsightsHostDetailsTab;

Version data entries

60 entries across 60 versions & 1 rubygems

Version Path
foreman_rh_cloud-11.0.3 webpack/InsightsHostDetailsTab/InsightsTab.js
foreman_rh_cloud-9.0.59 webpack/InsightsHostDetailsTab/InsightsTab.js
foreman_rh_cloud-11.0.2 webpack/InsightsHostDetailsTab/InsightsTab.js
foreman_rh_cloud-11.0.1 webpack/InsightsHostDetailsTab/InsightsTab.js
foreman_rh_cloud-11.0.0 webpack/InsightsHostDetailsTab/InsightsTab.js
foreman_rh_cloud-9.0.58 webpack/InsightsHostDetailsTab/InsightsTab.js
foreman_rh_cloud-10.0.2 webpack/InsightsHostDetailsTab/InsightsTab.js
foreman_rh_cloud-9.0.57 webpack/InsightsHostDetailsTab/InsightsTab.js
foreman_rh_cloud-10.0.1 webpack/InsightsHostDetailsTab/InsightsTab.js
foreman_rh_cloud-9.0.56 webpack/InsightsHostDetailsTab/InsightsTab.js
foreman_rh_cloud-9.0.55 webpack/InsightsHostDetailsTab/InsightsTab.js
foreman_rh_cloud-9.0.54 webpack/InsightsHostDetailsTab/InsightsTab.js
foreman_rh_cloud-9.0.53 webpack/InsightsHostDetailsTab/InsightsTab.js
foreman_rh_cloud-9.0.52 webpack/InsightsHostDetailsTab/InsightsTab.js
foreman_rh_cloud-8.0.52 webpack/InsightsHostDetailsTab/InsightsTab.js
foreman_rh_cloud-9.0.51 webpack/InsightsHostDetailsTab/InsightsTab.js
foreman_rh_cloud-8.0.51 webpack/InsightsHostDetailsTab/InsightsTab.js
foreman_rh_cloud-7.0.48 webpack/InsightsHostDetailsTab/InsightsTab.js
foreman_rh_cloud-7.0.47 webpack/InsightsHostDetailsTab/InsightsTab.js
foreman_rh_cloud-8.0.50 webpack/InsightsHostDetailsTab/InsightsTab.js