Files
weave-scope/client/app/scripts/components/node-details/node-details-table-node-link.js
Roland Schilter 0d381a34d6 Link scope-ui graphs clickable to prometheus queries (#2664)
scope-app:
* Adds `-app.metrics-graph` cli flag for configuring the base url to
use for graph links; supports :orgID and :query placeholders
* Assigns query URLs to existing metrics and appends empty metrics if missing

scope-ui:
* Extends <CloudFeature /> with option alwaysShow
* Adds <CloudLink /> to simplify routing when in cloud vs not in cloud
* Links metric graphs in the ui's node details view for all k8s
toplogies and containers so far
* Tracks metric graph click in mixpanel `scope.node.metric.click`
* Uses percentages and MB for CPU/Memory urls
* Passes timetravel timestamp to cortex in deeplink
2017-08-15 18:56:23 +01:00

59 lines
1.5 KiB
JavaScript

import React from 'react';
import { connect } from 'react-redux';
import { clickRelative } from '../../actions/app-actions';
import { trackMixpanelEvent } from '../../utils/tracking-utils';
import { dismissRowClickProps } from './node-details-table-row';
class NodeDetailsTableNodeLink extends React.Component {
constructor(props, context) {
super(props, context);
this.handleClick = this.handleClick.bind(this);
this.saveNodeRef = this.saveNodeRef.bind(this);
}
handleClick(ev) {
ev.preventDefault();
trackMixpanelEvent('scope.node.relative.click', {
topologyId: this.props.topologyId,
});
this.props.dispatch(clickRelative(
this.props.nodeId,
this.props.topologyId,
this.props.label,
this.node.getBoundingClientRect()
));
}
saveNodeRef(ref) {
this.node = ref;
}
render() {
const { label, labelMinor, linkable } = this.props;
const title = !labelMinor ? label : `${label} (${labelMinor})`;
if (linkable) {
return (
<span
className="node-details-table-node-link" title={title}
ref={this.saveNodeRef} onClick={this.handleClick}
{...dismissRowClickProps}
>
{label}
</span>
);
}
return (
<span className="node-details-table-node" title={title}>
{label}
</span>
);
}
}
// Using this instead of PureComponent because of props.dispatch
export default connect()(NodeDetailsTableNodeLink);