Sha256: af8b2e7528ba707485a813da209713dbc42094749a5585c8643dfc44bb4a6658

Contents?: true

Size: 1.52 KB

Versions: 21

Compression:

Stored size: 1.52 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 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

21 entries across 21 versions & 1 rubygems

Version Path
foreman_rh_cloud-3.0.33 webpack/InsightsHostDetailsTab/InsightsTab.js
foreman_rh_cloud-3.0.32 webpack/InsightsHostDetailsTab/InsightsTab.js
foreman_rh_cloud-3.0.29 webpack/InsightsHostDetailsTab/InsightsTab.js
foreman_rh_cloud-3.0.28 webpack/InsightsHostDetailsTab/InsightsTab.js
foreman_rh_cloud-3.0.26 webpack/InsightsHostDetailsTab/InsightsTab.js
foreman_rh_cloud-3.0.25 webpack/InsightsHostDetailsTab/InsightsTab.js
foreman_rh_cloud-3.0.24.1 webpack/InsightsHostDetailsTab/InsightsTab.js
foreman_rh_cloud-4.0.24.1 webpack/InsightsHostDetailsTab/InsightsTab.js
foreman_rh_cloud-3.0.24 webpack/InsightsHostDetailsTab/InsightsTab.js
foreman_rh_cloud-4.0.24 webpack/InsightsHostDetailsTab/InsightsTab.js
foreman_rh_cloud-3.0.23 webpack/InsightsHostDetailsTab/InsightsTab.js
foreman_rh_cloud-4.0.23 webpack/InsightsHostDetailsTab/InsightsTab.js
foreman_rh_cloud-3.0.22 webpack/InsightsHostDetailsTab/InsightsTab.js
foreman_rh_cloud-4.0.22 webpack/InsightsHostDetailsTab/InsightsTab.js
foreman_rh_cloud-4.0.21.1 webpack/InsightsHostDetailsTab/InsightsTab.js
foreman_rh_cloud-3.0.21.1 webpack/InsightsHostDetailsTab/InsightsTab.js
foreman_rh_cloud-3.0.21 webpack/InsightsHostDetailsTab/InsightsTab.js
foreman_rh_cloud-3.0.20 webpack/InsightsHostDetailsTab/InsightsTab.js
foreman_rh_cloud-3.0.19 webpack/InsightsHostDetailsTab/InsightsTab.js
foreman_rh_cloud-3.0.18.1 webpack/InsightsHostDetailsTab/InsightsTab.js