2016-12-19 20:53:49 +01:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
2017-08-28 21:40:44 +02:00
|
|
|
import { fetchFeatureMetrics, fetchSeenApps } from '../../store/feature-metrics-actions';
|
2016-12-19 20:53:49 +01:00
|
|
|
|
|
|
|
import MatricComponent from './metric-component';
|
|
|
|
|
2017-08-28 19:15:47 +02:00
|
|
|
function getMetricsForToggle(state, toggleName) {
|
2016-12-19 20:53:49 +01:00
|
|
|
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]);
|
2016-12-19 20:53:49 +01:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2017-08-28 19:15:47 +02:00
|
|
|
export default connect(
|
|
|
|
(state, props) => ({
|
|
|
|
metrics: getMetricsForToggle(state, props.featureToggle.name),
|
2018-02-07 14:25:02 +01:00
|
|
|
location: state.settings.toJS().location || {},
|
2017-08-28 19:15:47 +02:00
|
|
|
}),
|
|
|
|
{
|
|
|
|
fetchFeatureMetrics,
|
|
|
|
fetchSeenApps,
|
|
|
|
}
|
|
|
|
)(MatricComponent);
|