import React from 'react'; import { Grid, ListView, Badge, Icon } from 'patternfly-react'; import EmptyInfoItem from './EmptyInfoItem'; import SeverityHigh from './images/i_severity-high.svg'; import SeverityMedium from './images/i_severity-med.svg'; import SeverityLow from './images/i_severity-low.svg'; export const itemIteratorId = (entry, ...rest) => `${entry.id}-${entry.preupgradeReportId}-${rest.join('-')}`; export const tagInfo = tags => tags.map(attr => ( {attr} )); export const getSeverityImg = entry => { const key = itemIteratorId(entry, `sv${entry.id}`); switch (entry.severity) { case 'low': return ( Low Severity ); case 'medium': return ( Medium Severity ); case 'high': return ( High Severity ); default: return ( Low Severity ); } }; export const hasRemediations = entry => { const key = itemIteratorId(entry, `rm${entry.id}`); if (entry.detail && entry.detail.remediations) { return ( Has Remediation ); } return ; }; export const getTitle = entry => { if (entry.title) { return ( Title {entry.title} ); } return
; }; export const getSeverity = entry => { if (entry.severity) { return ( Risk Factor {getSeverityImg(entry)} {entry.severity} ); } return
; }; export const getSummary = entry => { if (entry.summary) { return ( Summary {entry.summary} ); } return
; }; export const getTags = entry => { if (entry.tags) { return ( Tags {tagInfo(entry.tags)} ); } return
; }; export const getExternals = entry => { if (entry.detail && entry.detail.external) { return entry.detail.external.map(attr => { const key = itemIteratorId(entry, attr); return ( Links {attr.title} ); }); } return
; }; export const getRemediations = entry => { if (entry.detail && entry.detail.remediations) { return entry.detail.remediations.map(attr => { const key = itemIteratorId(entry, attr); if (attr.type === 'hint') { return ( Hint {attr.context} ); } if (attr.type === 'command') { return ( Command {attr.context.join(' ')} ); } return
; }); } return
; };