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

49 lines
1.1 KiB
JavaScript
Raw Normal View History

import React from 'react';
import { connect } from 'react-redux';
import { toggleInstanceCollapsed } from '@state/actions';
import EmptyInstances from '@components/empty/instances';
import PropTypes from '@root/prop-types';
import InstanceList from '@components/instance-list';
import { instancesByServiceIdSelector } from '@state/selectors';
const Instances = ({
instances = [],
toggleCollapsed = () => null
}) => {
2017-01-09 21:08:47 +02:00
const empty = instances.length ? null : (
<EmptyInstances />
);
return (
<div>
{empty}
2017-01-12 18:13:45 +02:00
<InstanceList
instances={instances}
toggleCollapsed={toggleCollapsed}
/>
2017-01-09 21:08:47 +02:00
</div>
);
};
Instances.propTypes = {
2017-01-11 23:11:48 +02:00
instances: React.PropTypes.arrayOf(PropTypes.instance),
toggleCollapsed: React.PropTypes.func
2017-01-09 21:08:47 +02:00
};
const mapStateToProps = (state, {
2017-02-07 11:55:18 +02:00
match = {
params: {}
}
2017-01-09 21:08:47 +02:00
}) => ({
2017-02-06 20:27:10 +02:00
instances: instancesByServiceIdSelector(match.params.serviceId)(state)
2017-01-09 21:08:47 +02:00
});
2017-01-11 23:11:48 +02:00
const mapDispatchToProps = (dispatch) => ({
toggleCollapsed: (uuid) => dispatch(toggleInstanceCollapsed(uuid))
});
export default connect(
2017-01-11 23:11:48 +02:00
mapStateToProps,
mapDispatchToProps
2017-01-09 21:08:47 +02:00
)(Instances);