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

33 lines
975 B
React
Raw Normal View History

import { connect } from 'react-redux';
2017-08-28 21:40:44 +02:00
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]);
2017-08-28 21:40:44 +02:00
result.lastMinute = state.featureMetrics.getIn(['lastMinute', toggleName]);
}
return result;
}
export default connect(
(state, props) => ({
metrics: getMetricsForToggle(state, props.featureToggle.name),
location: state.settings.toJS().location || {},
}),
{
fetchFeatureMetrics,
fetchSeenApps,
}
)(MatricComponent);