mirror of
https://github.com/yldio/copilot.git
synced 2024-11-28 22:20:06 +02:00
47 lines
969 B
JavaScript
47 lines
969 B
JavaScript
const ReactRedux = require('react-redux');
|
|
|
|
const actions = require('@state/actions');
|
|
const Metrics = require('@containers/metrics');
|
|
const selectors = require('@state/selectors');
|
|
|
|
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) => ({
|
|
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,
|
|
mapDispatchToProps,
|
|
mergeProps
|
|
)(Metrics);
|