node-details-table-node-metric-link.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import React from 'react';
  2. import CloudLink from '../cloud-link';
  3. import { formatMetric } from '../../utils/string-utils';
  4. import { trackAnalyticsEvent } from '../../utils/tracking-utils';
  5. import { dismissRowClickProps } from '../../utils/dom-utils';
  6. class NodeDetailsTableNodeMetricLink extends React.Component {
  7. constructor(props) {
  8. super(props);
  9. this.onClick = this.onClick.bind(this);
  10. }
  11. onClick() {
  12. trackAnalyticsEvent('scope.node.metric.click', { topologyId: this.props.topologyId });
  13. }
  14. render() {
  15. const {
  16. url, style, value, valueEmpty
  17. } = this.props;
  18. return (
  19. <td
  20. className="node-details-table-node-metric"
  21. style={style}
  22. {...dismissRowClickProps}
  23. >
  24. <CloudLink
  25. alwaysShow
  26. url={url}
  27. className={url && 'node-details-table-node-metric-link'}
  28. onClick={this.onClick}
  29. >
  30. {!valueEmpty && formatMetric(value, this.props)}
  31. </CloudLink>
  32. </td>
  33. );
  34. }
  35. }
  36. export default NodeDetailsTableNodeMetricLink;