const forceArray = require('force-array');
const React = require('react');
const ReactRouter = require('react-router-dom');
const Anchor = require('@ui/components/anchor');
const List = require('@ui/components/list');
const MetricsOutlet = require('@components/metrics-outlet');
const PropTypes = require('@root/prop-types');
const {
Link
} = ReactRouter;
const {
ListItem,
ListItemView,
ListItemMeta,
ListItemTitle,
ListItemSubTitle,
ListItemDescription,
ListItemGroupView,
ListItemOptions,
ListItemHeader
} = List;
const ServiceItem = ({
org = '',
project = '',
service = {}
}) => {
const isChild = !!service.parent;
const childs = forceArray(service.services).map((service) => (
));
const to = `/${org}/projects/${project}/services/${service.id}`;
const title = isChild ? (
{service.name}
) : (
{Anchor.fn(
{service.name}
)}
);
const subtitle = (
{service.instances} instances
);
const description = (
Flags
);
const header = isChild ? null : (
{title}
{subtitle}
{description}
…
);
const view = childs.length ? (
{childs}
) : (
{isChild && title}
{isChild && subtitle}
{description}
);
return (
1)}
>
{header}
{view}
);
};
ServiceItem.propTypes = {
org: React.PropTypes.string,
project: React.PropTypes.string,
service: PropTypes.service
};
module.exports = ServiceItem;