import React, {PropTypes, PureComponent} from 'react'; import KeyValueEditor from '../keyvalueeditor/Editor'; import {trackEvent} from '../../../analytics/index'; class AuthEditor extends PureComponent { _handleOnCreate = () => trackEvent('Auth Editor', 'Create'); _handleOnDelete = () => trackEvent('Auth Editor', 'Delete'); _handleToggleDisable = pair => { const label = pair.disabled ? 'Disable' : 'Enable'; trackEvent('Auth Editor', 'Toggle', label); }; _handleChange = pairs => { const pair = { username: pairs.length ? pairs[0].name : '', password: pairs.length ? pairs[0].value : '', disabled: pairs.length ? pairs[0].disabled : false, }; this.props.onChange(pair); }; render () { const {authentication, showPasswords, handleRender} = this.props; const pairs = [{ name: authentication.username || '', value: authentication.password || '', disabled: authentication.disabled || false, }]; return ( ); } } AuthEditor.propTypes = { handleRender: PropTypes.func.isRequired, handleUpdateSettingsShowPasswords: PropTypes.func.isRequired, onChange: PropTypes.func.isRequired, authentication: PropTypes.object.isRequired, showPasswords: PropTypes.bool.isRequired, }; export default AuthEditor;