import React from 'react';
import PropTypes from 'prop-types';
import { capitalize } from 'lodash';
import './StatusCell.scss';
const StatusCell = ({ format, value }) => {
switch (format) {
case 'puppet':
return (
{value.map(status => {
let style = '';
switch (status[0]) {
case 'failed':
style = 'label-danger';
break;
case 'failed_to_restart':
style = 'label-warning';
break;
default:
style = 'label-info';
}
if (!status[2]) style = 'label-default';
return (
-
{`${status[1]}: `}
{status[2]}
);
})}
|
);
case 'ansible':
return (
{Object.keys(value).map(status => {
let style = '';
switch (status) {
case 'failed':
style = 'label-danger';
break;
case 'skipped':
style = 'label-warning';
break;
default:
style = 'label-info';
}
if (!value[status]) style = 'label-default';
return (
-
{`${capitalize(status)}: `}
{value[status]}
);
})}
|
);
default:
return N/A | ;
}
};
StatusCell.propTypes = {
format: PropTypes.string,
value: PropTypes.any.isRequired,
};
StatusCell.defaultProps = {
format: 'plain',
};
export default StatusCell;