import React from 'react';
import { Grid, ListView, Badge, Icon } from 'patternfly-react';
import EmptyInfoItem from './EmptyInfoItem';
export const itemIteratorId = (entry, ...rest) =>
`${entry.id}-${entry.preupgradeReportId}-${rest.join('-')}`;
export const presentSeverity = severity => {
switch (severity) {
case 'low':
return '#39a5dc';
case 'medium':
return '#f0ab00';
case 'high':
return '#cc0000';
default:
return '#39a5dc';
}
};
export const tagInfo = tags =>
tags.map(attr => (
{attr}
));
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
{' '}
{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 ;
};