insomnia/app/components/RequestAuthEditor.js

39 lines
930 B
JavaScript
Raw Normal View History

2016-04-09 21:08:55 +00:00
import React, {Component, PropTypes} from 'react'
import KeyValueEditor from './base/KeyValueEditor'
class RequestAuthEditor extends Component {
render () {
2016-04-17 22:46:17 +00:00
const {request, onChange, ...other} = this.props;
2016-04-09 21:08:55 +00:00
const auth = request.authentication;
const pairs = [{
name: auth.username || '',
value: auth.password || ''
}];
return (
<KeyValueEditor
uniquenessKey={request._id}
2016-04-09 21:08:55 +00:00
pairs={pairs}
maxPairs={1}
namePlaceholder="Username"
valuePlaceholder="Password"
2016-04-09 21:08:55 +00:00
onChange={pairs => onChange({
2016-04-13 23:32:49 +00:00
username: pairs.length ? pairs[0].name : '',
password: pairs.length ? pairs[0].value : ''
2016-04-09 21:08:55 +00:00
})}
2016-04-17 22:46:17 +00:00
{...other}
2016-04-09 21:08:55 +00:00
/>
);
}
}
RequestAuthEditor.propTypes = {
onChange: PropTypes.func.isRequired,
request: PropTypes.shape({
authentication: PropTypes.object.isRequired
})
};
export default RequestAuthEditor;