fix(cp-frontend): handle no data in metrics loop
This commit is contained in:
parent
3db2cfaea5
commit
d08a8b00a9
@ -12,7 +12,7 @@ import {
|
||||
const ServiceScale = ({
|
||||
service,
|
||||
handleSubmit = () => {},
|
||||
onCancelClick = () => {},
|
||||
onCancel = () => {},
|
||||
invalid,
|
||||
pristine
|
||||
}) => (
|
||||
@ -32,7 +32,7 @@ const ServiceScale = ({
|
||||
<FormMeta />
|
||||
<NumberInput minValue={1} />
|
||||
</FormGroup>
|
||||
<Button secondary onClick={onCancelClick}>
|
||||
<Button type="button" secondary onClick={onCancel}>
|
||||
Cancel
|
||||
</Button>
|
||||
<Button type="submit" disabled={pristine || invalid} secondary>
|
||||
|
@ -1,7 +1,9 @@
|
||||
import React, { Component } from 'react';
|
||||
import { compose, graphql } from 'react-apollo';
|
||||
import moment from 'moment';
|
||||
import find from 'lodash.find';
|
||||
import uniqBy from 'lodash.uniqby';
|
||||
import get from 'lodash.get';
|
||||
import moment from 'moment';
|
||||
|
||||
export const MetricNames = [
|
||||
'AVG_MEM_BYTES',
|
||||
@ -53,8 +55,13 @@ export const withServiceMetricsGql = ({
|
||||
instanceId,
|
||||
metricName
|
||||
) => {
|
||||
return previousResult.deploymentGroup.services
|
||||
.find(s => s.id === serviceId)
|
||||
const service = find(get(previousResult, 'deploymentGroup.services', []), ['id', serviceId]);
|
||||
|
||||
if (!service) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return service
|
||||
.instances.find(i => i.id === instanceId)
|
||||
.metrics.find(m => m.name === metricName).metrics;
|
||||
};
|
||||
|
@ -184,7 +184,13 @@ export default compose(
|
||||
return false;
|
||||
}
|
||||
|
||||
const previousEnd = services
|
||||
const _services = forceArray(services);
|
||||
|
||||
if (!_services.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const previousEnd = _services
|
||||
.map(service => get(service, 'instances[0].metrics[0].end', null))
|
||||
.filter(Boolean)
|
||||
.shift();
|
||||
|
Loading…
Reference in New Issue
Block a user