1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-10-18 20:09:08 +02:00
unleash.unleash/frontend/src/component/feature/metric-container.jsx

30 lines
891 B
React
Raw Normal View History

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) => ({
2016-12-22 10:42:52 +01:00
metrics: getMetricsForToggle(state, props.featureToggle.name),
}), {
fetchFeatureMetrics,
fetchSeenApps,
})(MatricComponent);