mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 23:00:30 +00:00
6a136bd76a
* Add multi-part form support * tests for form and multipart * Better Analytics Tracking
42 lines
1.2 KiB
JavaScript
42 lines
1.2 KiB
JavaScript
import React, {PropTypes} from 'react';
|
|
import KeyValueEditor from '../base/KeyValueEditor';
|
|
import {trackEvent} from '../../../analytics/index';
|
|
|
|
const AuthEditor = ({request, showPasswords, onChange, ...other}) => {
|
|
const auth = request.authentication;
|
|
const pairs = [{
|
|
name: auth.username || '',
|
|
value: auth.password || '',
|
|
disabled: auth.disabled || false,
|
|
}];
|
|
|
|
return (
|
|
<KeyValueEditor
|
|
pairs={pairs}
|
|
maxPairs={1}
|
|
namePlaceholder="Username"
|
|
valuePlaceholder="********"
|
|
valueInputType={showPasswords ? 'text' : 'password'}
|
|
onToggleDisable={pair => trackEvent('Auth Editor', 'Toggle', pair.disabled ? 'Disable' : 'Enable')}
|
|
onCreate={() => trackEvent('Auth Editor', 'Create')}
|
|
onDelete={() => trackEvent('Auth Editor', 'Delete')}
|
|
onChange={pairs => onChange({
|
|
username: pairs.length ? pairs[0].name : '',
|
|
password: pairs.length ? pairs[0].value : '',
|
|
disabled: pairs.length ? pairs[0].disabled : false,
|
|
})}
|
|
{...other}
|
|
/>
|
|
);
|
|
};
|
|
|
|
AuthEditor.propTypes = {
|
|
onChange: PropTypes.func.isRequired,
|
|
request: PropTypes.shape({
|
|
authentication: PropTypes.object.isRequired
|
|
}),
|
|
showPasswords: PropTypes.bool.isRequired
|
|
};
|
|
|
|
export default AuthEditor;
|