Guest User

Untitled

a guest
Dec 8th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. import { Actions as KafkaActions } from 'redux-lenses-streaming';
  2.  
  3. class Connect extends React.Component {
  4.  
  5. ...
  6.  
  7. onConnectClick() {
  8. const { connection } = this.props;
  9. const { authRequired } = this.state;
  10.  
  11. if (connection) {
  12. this.props.disconnect();
  13. } else if (authRequired) {
  14. const options = {
  15. host: this.props.host,
  16. clientId: this.props.clientId,
  17. user: this.props.user,
  18. password: this.props.password,
  19. };
  20. this.props.connect(options);
  21. } else {
  22. const options = {
  23. host: this.props.host,
  24. clientId: this.props.clientId,
  25. };
  26. this.props.connect(options);
  27. }
  28. }
  29.  
  30. onLogin() {
  31. const options = {
  32. user: this.props.user,
  33. password: this.props.password,
  34. };
  35. this.props.login(options);
  36. }
  37. }
  38.  
  39. const mapDispatchToProps = dispatch => ({
  40. connect: (option) => {
  41. dispatch(KafkaActions.connect(option));
  42. },
  43. disconnect: () => {
  44. dispatch(KafkaActions.disconnect());
  45. },
  46. login: (option) => {
  47. dispatch(KafkaActions.login(option));
  48. },
  49. });
  50.  
  51. export default connect(mapStateToProps, mapDispatchToProps)(Connect);
Add Comment
Please, Sign In to add comment