import React, { PureComponent } from 'react' import PropTypes from 'prop-types' import ConnectedSiteEntry from './connected-site-row' import TextField from '../../../components/ui/text-field' import Button from '../../../components/ui/button' export default class ConnectionsTab extends PureComponent { static contextTypes = { t: PropTypes.func, metricsEvent: PropTypes.func, } static defaultProps = { activeTab: {}, } static propTypes = { activeTab: PropTypes.object, approvedOrigins: PropTypes.object.isRequired, approveProviderRequestByOrigin: PropTypes.func.isRequired, rejectProviderRequestByOrigin: PropTypes.func.isRequired, showClearApprovalModal: PropTypes.func.isRequired, } state = { input: this.props.activeTab.origin || '', } handleAddOrigin = () => { const newOrigin = this.state.input this.setState({ input: '', }, () => { if (newOrigin && newOrigin.trim()) { this.props.approveProviderRequestByOrigin(newOrigin) } }) } renderNewOriginInput () { const { t } = this.context return (