mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-03 18:20:27 +00:00
Refactored mixins into utils ES2015 module exports ES2015-style imports WIP Fixing tests Fixes tests after es2015 code migrations. We we're require()ing an ES2015 module[1]. Have to make sure you account for the .default in this case. [1] We had to use ES5 `require` in Jest: (https://github.com/babel/babel-jest/issues/16)
54 lines
1.2 KiB
JavaScript
54 lines
1.2 KiB
JavaScript
import React from 'react';
|
|
|
|
import NodesChart from '../charts/nodes-chart';
|
|
|
|
const navbarHeight = 160;
|
|
const marginTop = 0;
|
|
|
|
export default class Nodes extends React.Component {
|
|
constructor(props, context) {
|
|
super(props, context);
|
|
this.handleResize = this.handleResize.bind(this);
|
|
|
|
this.state = {
|
|
width: window.innerWidth,
|
|
height: window.innerHeight - navbarHeight - marginTop
|
|
};
|
|
}
|
|
|
|
componentDidMount() {
|
|
window.addEventListener('resize', this.handleResize);
|
|
}
|
|
|
|
componentWillUnmount() {
|
|
window.removeEventListener('resize', this.handleResize);
|
|
}
|
|
|
|
render() {
|
|
return (
|
|
<NodesChart
|
|
highlightedEdgeIds={this.props.highlightedEdgeIds}
|
|
highlightedNodeIds={this.props.highlightedNodeIds}
|
|
selectedNodeId={this.props.selectedNodeId}
|
|
nodes={this.props.nodes}
|
|
width={this.state.width}
|
|
height={this.state.height}
|
|
topologyId={this.props.topologyId}
|
|
detailsWidth={this.props.detailsWidth}
|
|
topMargin={this.props.topMargin}
|
|
/>
|
|
);
|
|
}
|
|
|
|
handleResize() {
|
|
this.setDimensions();
|
|
}
|
|
|
|
setDimensions() {
|
|
const width = window.innerWidth;
|
|
const height = window.innerHeight - navbarHeight - marginTop;
|
|
|
|
this.setState({height, width});
|
|
}
|
|
}
|