2017-02-28 20:34:48 +02:00
|
|
|
import React from 'react';
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import PropTypes from '@root/prop-types';
|
|
|
|
import ServiceItem from '@components/service/item';
|
|
|
|
|
|
|
|
import {
|
|
|
|
orgByIdSelector,
|
|
|
|
projectByIdSelector,
|
|
|
|
servicesByProjectIdSelector
|
|
|
|
} from '@state/selectors';
|
|
|
|
|
|
|
|
const Services = (props) => {
|
|
|
|
const {
|
|
|
|
org = {},
|
|
|
|
project = {},
|
|
|
|
services = []
|
|
|
|
} = props;
|
|
|
|
|
|
|
|
const serviceList = services.map((service) => (
|
|
|
|
<ServiceItem
|
|
|
|
key={service.uuid}
|
|
|
|
org={org.id}
|
|
|
|
project={project.id}
|
|
|
|
service={service}
|
|
|
|
/>
|
|
|
|
));
|
|
|
|
|
|
|
|
return (
|
2017-03-06 19:27:45 +02:00
|
|
|
<div>
|
2017-02-28 20:34:48 +02:00
|
|
|
{serviceList}
|
2017-03-06 19:27:45 +02:00
|
|
|
</div>
|
2017-02-28 20:34:48 +02:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
Services.propTypes = {
|
|
|
|
org: PropTypes.org,
|
|
|
|
project: PropTypes.project,
|
|
|
|
services: React.PropTypes.arrayOf(PropTypes.service)
|
|
|
|
};
|
|
|
|
|
|
|
|
const mapStateToProps = (state, {
|
|
|
|
match = {
|
|
|
|
params: {}
|
|
|
|
},
|
|
|
|
push
|
|
|
|
}) => ({
|
|
|
|
org: orgByIdSelector(match.params.org)(state),
|
|
|
|
project: projectByIdSelector(match.params.projectId)(state),
|
|
|
|
services: servicesByProjectIdSelector(match.params.projectId)(state)
|
|
|
|
});
|
|
|
|
|
|
|
|
export default connect(
|
|
|
|
mapStateToProps
|
|
|
|
)(Services);
|