node-resources-layer-topology.js 1.0 KB

12345678910111213141516171819202122232425262728293031
  1. import React from 'react';
  2. import pick from 'lodash/pick';
  3. import { applyTransform } from '../../utils/transform-utils';
  4. import {
  5. RESOURCES_LAYER_TITLE_WIDTH,
  6. RESOURCES_LAYER_HEIGHT,
  7. } from '../../constants/styles';
  8. export default class NodeResourcesLayerTopology extends React.Component {
  9. render() {
  10. // This component always has a fixed horizontal position and width,
  11. // so we only apply the vertical zooming transformation to match the
  12. // vertical position and height of the resource boxes.
  13. const verticalTransform = pick(this.props.transform, ['translateY', 'scaleY']);
  14. const { width, height, y } = applyTransform(verticalTransform, {
  15. height: RESOURCES_LAYER_HEIGHT,
  16. width: RESOURCES_LAYER_TITLE_WIDTH,
  17. y: this.props.verticalPosition,
  18. });
  19. return (
  20. <foreignObject width={width} height={height} y={y}>
  21. <div className="node-resources-layer-topology" style={{ lineHeight: `${height}px` }}>
  22. {this.props.topologyId}
  23. </div>
  24. </foreignObject>
  25. );
  26. }
  27. }