1
0
mirror of https://github.com/yldio/copilot.git synced 2024-11-28 22:20:06 +02:00
copilot/frontend/src/containers/service/metrics.js

47 lines
969 B
JavaScript
Raw Normal View History

const ReactRedux = require('react-redux');
2017-01-16 21:45:15 +02:00
const actions = require('@state/actions');
2017-01-16 21:45:15 +02:00
const Metrics = require('@containers/metrics');
const selectors = require('@state/selectors');
2017-01-03 00:32:29 +02:00
const {
connect
} = ReactRedux;
const {
metricsByServiceIdSelector,
serviceByIdSelector
} = selectors;
const {
addMetric
} = actions;
const mapStateToProps = (state, {
params = {}
}) => ({
metrics: metricsByServiceIdSelector(params.serviceId)(state),
metricTypes: state.metrics.ui.types,
service: serviceByIdSelector(params.serviceId)(state)
});
const mapDispatchToProps = (dispatch) => ({
2017-01-16 21:45:15 +02:00
addMetric: (service) => (metric) => dispatch(addMetric({
id: metric,
service: service
}))
});
const mergeProps = (stateProps, dispatchProps, ownProps) => ({
...stateProps,
...dispatchProps,
...ownProps,
addMetric: dispatchProps.addMetric(stateProps.service)
});
module.exports = connect(
mapStateToProps,
2017-01-16 21:45:15 +02:00
mapDispatchToProps,
mergeProps
)(Metrics);