2017-02-20 18:15:36 +02:00
|
|
|
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))
|
|
|
|
});
|
|
|
|
|
2017-02-20 18:15:36 +02:00
|
|
|
export default connect(
|
2017-01-11 23:11:48 +02:00
|
|
|
mapStateToProps,
|
|
|
|
mapDispatchToProps
|
2017-01-09 21:08:47 +02:00
|
|
|
)(Instances);
|