[Infra UI] Change node detail link to set time range to 1 hour (#26977) (#27134)

* Change time range for link to -1h

* Moving timeRange manipulation up a level to the node component
This commit is contained in:
Chris Cowan 2018-12-13 10:13:14 -07:00 committed by GitHub
parent 0065fc5043
commit 1ab598c646
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5,6 +5,7 @@
*/
import { EuiToolTip } from '@elastic/eui';
import moment from 'moment';
import { darken, readableColor } from 'polished';
import React from 'react';
import styled from 'styled-components';
@ -40,6 +41,12 @@ export class Node extends React.PureComponent<Props, State> {
const rawValue = (metric && metric.value) || 0;
const color = colorFromValue(options.legend, rawValue, bounds);
const value = formatter(rawValue);
const newTimerange = {
...timeRange,
from: moment(timeRange.to)
.subtract(1, 'hour')
.valueOf(),
};
return (
<NodeContextMenu
node={node}
@ -47,7 +54,7 @@ export class Node extends React.PureComponent<Props, State> {
isPopoverOpen={isPopoverOpen}
closePopover={this.closePopover}
options={options}
timeRange={timeRange}
timeRange={newTimerange}
>
<EuiToolTip position="top" content={`${node.name} | ${value}`}>
<NodeContainer