import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { Modal, ModalHeader, ModalBody, ModalFooter, Button, Input, InputGroup, InputGroupAddon } from 'reactstrap'; import { gettext } from '../../utils/constants'; const propTypes = { password: PropTypes.string.isRequired, updatePassword: PropTypes.func.isRequired, toggle: PropTypes.func.isRequired }; class UpdateWebdavPassword extends Component { constructor(props) { super(props); this.state = { password: this.props.password, isPasswordVisible: false, btnDisabled: false }; } submit = () => { this.setState({ btnDisabled: true }); this.props.updatePassword(this.state.password); } handleInputChange = (e) => { let passwd = e.target.value.trim(); this.setState({password: passwd}); } togglePasswordVisible = () => { this.setState({ isPasswordVisible: !this.state.isPasswordVisible }); } generatePassword = () => { let randomPassword = ''; const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; for (let i = 0; i < 8; i++) { randomPassword += possible.charAt(Math.floor(Math.random() * possible.length)); } this.setState({ password: randomPassword, isPasswordVisible: true }); } render() { const { toggle } = this.props; return ( {gettext('WebDav Password')} ); } } UpdateWebdavPassword.propTypes = propTypes; export default UpdateWebdavPassword;