topology-option-action.js 714 B

1234567891011121314151617181920212223242526
  1. import React from 'react';
  2. export default class TopologyOptionAction extends React.Component {
  3. constructor(props, context) {
  4. super(props, context);
  5. this.onClick = this.onClick.bind(this);
  6. }
  7. onClick(ev) {
  8. ev.preventDefault();
  9. const { optionId, topologyId, item } = this.props;
  10. this.props.onClick(optionId, item.get('value'), topologyId);
  11. }
  12. render() {
  13. const { activeValue, item } = this.props;
  14. const className = activeValue.includes(item.get('value'))
  15. ? 'topology-option-action topology-option-action-selected'
  16. : 'topology-option-action';
  17. return (
  18. <div className={className} onClick={this.onClick}>
  19. {item.get('label')}
  20. </div>
  21. );
  22. }
  23. }