1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-05-08 01:15:49 +02:00
unleash.unleash/frontend/src/component/feature/metric-container.jsx
2017-01-06 15:21:58 +01:00

30 lines
891 B
JavaScript

import { connect } from 'react-redux';
import { fetchFeatureMetrics, fetchSeenApps } from '../../store/feature-metrics-actions';
import MatricComponent from './metric-component';
function getMetricsForToggle (state, toggleName) {
if (!toggleName) {
return;
}
const result = {};
if (state.featureMetrics.hasIn(['seenApps', toggleName])) {
result.seenApps = state.featureMetrics.getIn(['seenApps', toggleName]);
}
if (state.featureMetrics.hasIn(['lastHour', toggleName])) {
result.lastHour = state.featureMetrics.getIn(['lastHour', toggleName]);
result.lastMinute = state.featureMetrics.getIn(['lastMinute', toggleName]);
}
return result;
}
export default connect((state, props) => ({
metrics: getMetricsForToggle(state, props.featureToggle.name),
}), {
fetchFeatureMetrics,
fetchSeenApps,
})(MatricComponent);