Sha256: f2d5241bb74469f47257b6fb6ad32bd8d4e68b4125a34d54cfe450b987e24cf5

Contents?: true

Size: 1.62 KB

Versions: 65

Compression:

Stored size: 1.62 KB

Contents

import React, { Fragment } from 'react';
import { ListView, Icon } from 'patternfly-react';
import PropTypes from 'prop-types';
import { translate as __ } from 'foremanReact/common/I18n';

const labelMapper = {
  1: __('Low'),
  2: __('Moderate'),
  3: __('Important'),
  4: __('Critical'),
};

const ListItem = ({ title, totalRisk, resultsUrl, solutionUrl }) => {
  const heading = (
    <p className="ellipsis list-item-heading" title={title}>
      {title}
    </p>
  );

  const riskLabel = labelMapper[totalRisk];
  const additionalInfo = [
    <span key={`risk-info-${title}`} className={`risk-label risk-${totalRisk}`}>
      <p>{riskLabel}</p>
    </span>,
  ];

  const knowledgebaseLink = solutionUrl && (
    <p>
      <a href={solutionUrl} target="_blank" rel="noopener noreferrer">
        {__('Knowledgebase article')} <Icon name="external-link" />
      </a>
    </p>
  );

  const insightsCloudLink = resultsUrl && (
    <p>
      <a href={resultsUrl} target="_blank" rel="noopener noreferrer">
        {__('Read more about it in RH cloud insights')}{' '}
        <Icon name="external-link" />
      </a>
    </p>
  );

  return (
    <ListView.Item
      heading={heading}
      additionalInfo={additionalInfo}
      hideCloseIcon
    >
      <Fragment>
        <p>{title}</p>
        {knowledgebaseLink}
        {insightsCloudLink}
      </Fragment>
    </ListView.Item>
  );
};

ListItem.propTypes = {
  title: PropTypes.string.isRequired,
  totalRisk: PropTypes.number.isRequired,
  resultsUrl: PropTypes.string,
  solutionUrl: PropTypes.string,
};

ListItem.defaultProps = {
  resultsUrl: '',
  solutionUrl: '',
};

export default ListItem;

Version data entries

65 entries across 65 versions & 1 rubygems

Version Path
foreman_rh_cloud-11.2.0 webpack/InsightsHostDetailsTab/components/ListItem/ListItem.js
foreman_rh_cloud-9.0.60 webpack/InsightsHostDetailsTab/components/ListItem/ListItem.js
foreman_rh_cloud-10.0.4 webpack/InsightsHostDetailsTab/components/ListItem/ListItem.js
foreman_rh_cloud-11.1.0 webpack/InsightsHostDetailsTab/components/ListItem/ListItem.js
foreman_rh_cloud-10.0.3 webpack/InsightsHostDetailsTab/components/ListItem/ListItem.js
foreman_rh_cloud-11.0.3 webpack/InsightsHostDetailsTab/components/ListItem/ListItem.js
foreman_rh_cloud-9.0.59 webpack/InsightsHostDetailsTab/components/ListItem/ListItem.js
foreman_rh_cloud-11.0.2 webpack/InsightsHostDetailsTab/components/ListItem/ListItem.js
foreman_rh_cloud-11.0.1 webpack/InsightsHostDetailsTab/components/ListItem/ListItem.js
foreman_rh_cloud-11.0.0 webpack/InsightsHostDetailsTab/components/ListItem/ListItem.js
foreman_rh_cloud-9.0.58 webpack/InsightsHostDetailsTab/components/ListItem/ListItem.js
foreman_rh_cloud-10.0.2 webpack/InsightsHostDetailsTab/components/ListItem/ListItem.js
foreman_rh_cloud-9.0.57 webpack/InsightsHostDetailsTab/components/ListItem/ListItem.js
foreman_rh_cloud-10.0.1 webpack/InsightsHostDetailsTab/components/ListItem/ListItem.js
foreman_rh_cloud-9.0.56 webpack/InsightsHostDetailsTab/components/ListItem/ListItem.js
foreman_rh_cloud-9.0.55 webpack/InsightsHostDetailsTab/components/ListItem/ListItem.js
foreman_rh_cloud-9.0.54 webpack/InsightsHostDetailsTab/components/ListItem/ListItem.js
foreman_rh_cloud-9.0.53 webpack/InsightsHostDetailsTab/components/ListItem/ListItem.js
foreman_rh_cloud-9.0.52 webpack/InsightsHostDetailsTab/components/ListItem/ListItem.js
foreman_rh_cloud-8.0.52 webpack/InsightsHostDetailsTab/components/ListItem/ListItem.js