LdapAuthTestModal.jsx 1.9 KB

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