LdapAuthTestModal.jsx 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import { withTranslation } from 'react-i18next';
  4. import {
  5. Modal,
  6. ModalHeader,
  7. ModalBody,
  8. ModalFooter,
  9. } from 'reactstrap';
  10. import { createSubscribedElement } from '../../UnstatedUtils';
  11. import AppContainer from '../../../services/AppContainer';
  12. import AdminLdapSecurityContainer from '../../../services/AdminLdapSecurityContainer';
  13. import LdapAuthTest from './LdapAuthTest';
  14. class LdapAuthTestModal extends React.Component {
  15. constructor(props) {
  16. super(props);
  17. this.state = {
  18. username: '',
  19. password: '',
  20. };
  21. this.onChangeUsername = this.onChangeUsername.bind(this);
  22. this.onChangePassword = this.onChangePassword.bind(this);
  23. }
  24. /**
  25. * Change username
  26. */
  27. onChangeUsername(username) {
  28. this.setState({ username });
  29. }
  30. /**
  31. * Change password
  32. */
  33. onChangePassword(password) {
  34. this.setState({ password });
  35. }
  36. render() {
  37. return (
  38. <Modal isOpen={this.props.isOpen} toggle={this.props.onClose}>
  39. <ModalHeader tag="h4" className="modal-header" toggle={this.props.onClose}>
  40. Test LDAP Account
  41. </ModalHeader>
  42. <ModalBody>
  43. <LdapAuthTest
  44. username={this.state.username}
  45. password={this.state.password}
  46. onChangeUsername={this.onChangeUsername}
  47. onChangePassword={this.onChangePassword}
  48. />
  49. </ModalBody>
  50. <ModalFooter />
  51. </Modal>
  52. );
  53. }
  54. }
  55. LdapAuthTestModal.propTypes = {
  56. t: PropTypes.func.isRequired, // i18next
  57. appContainer: PropTypes.instanceOf(AppContainer).isRequired,
  58. adminLdapSecurityContainer: PropTypes.instanceOf(AdminLdapSecurityContainer).isRequired,
  59. isOpen: PropTypes.bool.isRequired,
  60. onClose: PropTypes.func.isRequired,
  61. };
  62. const LdapAuthTestModalWrapper = (props) => {
  63. return createSubscribedElement(LdapAuthTestModal, props, [AppContainer, AdminLdapSecurityContainer]);
  64. };
  65. export default withTranslation()(LdapAuthTestModalWrapper);