1
0
mirror of https://github.com/yldio/copilot.git synced 2025-01-10 11:00:13 +02:00
copilot/frontend/src/containers/service/instances.js

66 lines
1.2 KiB
JavaScript
Raw Normal View History

2017-01-03 00:32:29 +02:00
const React = require('react');
2017-01-09 21:08:47 +02:00
const ReactRedux = require('react-redux');
2017-01-03 00:32:29 +02:00
2017-01-09 21:08:47 +02:00
const EmptyInstances = require('@components/empty/instances');
const PropTypes = require('@root/prop-types');
const List = require('@ui/components/list');
const selectors = require('@state/selectors');
const {
connect
} = ReactRedux;
const {
instancesByServiceIdSelector
} = selectors;
const {
ListItem,
ListItemView,
ListItemMeta,
ListItemTitle,
ListItemOptions
} = List;
const Instances = ({
instances = []
}) => {
const empty = instances.length ? null : (
<EmptyInstances />
);
const instanceList = instances.map((service) => (
<ListItem collapsed key={service.uuid}>
<ListItemView>
<ListItemMeta>
<ListItemTitle>{service.name}</ListItemTitle>
</ListItemMeta>
</ListItemView>
<ListItemOptions>
</ListItemOptions>
</ListItem>
));
return (
<div>
{empty}
{instanceList}
</div>
);
};
Instances.propTypes = {
instances: React.PropTypes.arrayOf(PropTypes.instance)
};
const mapStateToProps = (state, {
params = {}
}) => ({
instances: instancesByServiceIdSelector(params.serviceId)(state)
});
module.exports = connect(
mapStateToProps
)(Instances);