Sha256: 38a98fc2ad0a1b1fd5d22b5c890cf9e7120a3e940d2a6af2fd128dc442428807

Contents?: true

Size: 1.47 KB

Versions: 16

Compression:

Stored size: 1.47 KB

Contents

import React from 'react';
import PropTypes from 'prop-types';
import { orderBy } from 'lodash';
import { Grid, ListView, noop } from 'patternfly-react';
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, ['insights_hit.total_risk'], ['desc']);
    const items = hitsSorted.map(
      (
        {
          insights_hit: {
            title,
            total_risk: totalRisk,
            results_url: resultsUrl,
            solution_url: solutionUrl,
          },
        },
        index
      ) => (
        <ListItem
          key={index}
          title={title}
          totalRisk={totalRisk}
          resultsUrl={resultsUrl}
          solutionUrl={solutionUrl}
        />
      )
    );
    return (
      <Grid.Row>
        <Grid.Col xs={12}>
          <h2>Recommendations</h2>
          <ListView id="hits_list">{items}</ListView>
        </Grid.Col>
      </Grid.Row>
    );
  }
}

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

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

export default InsightsHostDetailsTab;

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
foreman_rh_cloud-1.0.18 webpack/InsightsHostDetailsTab/InsightsTab.js
foreman_rh_cloud-1.0.17 webpack/InsightsHostDetailsTab/InsightsTab.js
foreman_rh_cloud-1.0.16 webpack/InsightsHostDetailsTab/InsightsTab.js
foreman_rh_cloud-1.0.15 webpack/InsightsHostDetailsTab/InsightsTab.js
foreman_rh_cloud-1.0.14 webpack/InsightsHostDetailsTab/InsightsTab.js
foreman_rh_cloud-0.9.14 webpack/InsightsHostDetailsTab/InsightsTab.js
foreman_rh_cloud-0.9.13.1 webpack/InsightsHostDetailsTab/InsightsTab.js
foreman_rh_cloud-1.0.13.1 webpack/InsightsHostDetailsTab/InsightsTab.js
foreman_rh_cloud-0.9.13 webpack/InsightsHostDetailsTab/InsightsTab.js
foreman_rh_cloud-1.0.13 webpack/InsightsHostDetailsTab/InsightsTab.js
foreman_rh_cloud-0.9.12 webpack/InsightsHostDetailsTab/InsightsTab.js
foreman_rh_cloud-1.0.12 webpack/InsightsHostDetailsTab/InsightsTab.js
foreman_rh_cloud-2.0.12 webpack/InsightsHostDetailsTab/InsightsTab.js
foreman_rh_cloud-0.9.11 webpack/InsightsHostDetailsTab/InsightsTab.js
foreman_rh_cloud-1.0.11 webpack/InsightsHostDetailsTab/InsightsTab.js
foreman_rh_cloud-2.0.11 webpack/InsightsHostDetailsTab/InsightsTab.js