2016-04-29 04:57:03 +00:00
|
|
|
import React, {PropTypes} from 'react'
|
2016-04-09 21:08:55 +00:00
|
|
|
import KeyValueEditor from './base/KeyValueEditor'
|
|
|
|
|
2016-04-29 04:57:03 +00:00
|
|
|
const RequestAuthEditor = ({request, onChange, ...other}) => {
|
|
|
|
const auth = request.authentication;
|
|
|
|
const pairs = [{
|
|
|
|
name: auth.username || '',
|
|
|
|
value: auth.password || ''
|
|
|
|
}];
|
2016-04-09 21:08:55 +00:00
|
|
|
|
2016-04-29 04:57:03 +00:00
|
|
|
return (
|
|
|
|
<KeyValueEditor
|
|
|
|
uniquenessKey={request._id}
|
|
|
|
pairs={pairs}
|
|
|
|
maxPairs={1}
|
|
|
|
namePlaceholder="Username"
|
|
|
|
valuePlaceholder="Password"
|
|
|
|
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-29 04:57:03 +00:00
|
|
|
{...other}
|
|
|
|
/>
|
|
|
|
);
|
2016-05-01 20:46:11 +00:00
|
|
|
};
|
2016-04-09 21:08:55 +00:00
|
|
|
|
|
|
|
RequestAuthEditor.propTypes = {
|
|
|
|
onChange: PropTypes.func.isRequired,
|
|
|
|
request: PropTypes.shape({
|
|
|
|
authentication: PropTypes.object.isRequired
|
|
|
|
})
|
|
|
|
};
|
|
|
|
|
|
|
|
export default RequestAuthEditor;
|