import React, { Component, Fragment } from 'react'; import { Input, InputGroup, InputGroupAddon, Button, Row, Col, Label } from 'reactstrap'; import PropTypes from 'prop-types'; import { gettext } from '../../utils/constants'; const propTypes = { value: PropTypes.string, domainVerified: PropTypes.bool, changeValue: PropTypes.func.isRequired, displayName: PropTypes.string.isRequired, }; class OrgSamlConfigInput extends Component { constructor(props) { super(props); this.state = { isBtnsShown: false, value: this.props.value, }; } componentWillReceiveProps(nextProps) { this.setState({value: nextProps.value,}); } toggleBtns = () => { this.setState({isBtnsShown: !this.state.isBtnsShown}); }; hideBtns = () => { if (!this.state.isBtnsShown) { return; } if (this.props.value != this.state.value) { this.setState({value: this.props.value}); } this.toggleBtns(); }; onInputChange = (e) => { this.setState({ value: e.target.value }); }; onSubmit = () => { const value = this.state.value.trim(); if (value != this.props.value) { this.props.changeValue(value); } this.toggleBtns(); }; render() { const { isBtnsShown, value } = this.state; const { displayName } = this.props; return ( {this.props.domainVerified && } {isBtnsShown && } ); } } OrgSamlConfigInput.propTypes = propTypes; export default OrgSamlConfigInput;