Files
weave-scope/client/app/scripts/components/node-details/node-details-table-node-link.js
Matthias Radestock 9754bf2385 refactor: remove support for non-linkable nodes
since they are now always linkable.
2018-01-02 10:19:22 +00:00

54 lines
1.3 KiB
JavaScript

import React from 'react';
import { connect } from 'react-redux';
import { clickRelative } from '../../actions/app-actions';
import { trackAnalyticsEvent } 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();
trackAnalyticsEvent('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 } = this.props;
const title = !labelMinor ? label : `${label} (${labelMinor})`;
return (
<span
className="node-details-table-node-link"
title={title}
ref={this.saveNodeRef}
onClick={this.handleClick}
{...dismissRowClickProps}
>
{label}
</span>
);
}
}
// Using this instead of PureComponent because of props.dispatch
export default connect()(NodeDetailsTableNodeLink);