mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 14:49:53 +00:00
2cdd4761c8
* Add digest auth and response timeline * Some css fixes * Fixed Button * More auth methods, fixed URL regex, and fix gzip * Get rid of negotiate auth * Fix proxy * Fixed GA tracking * Some very small changes and fixes * Fix content type names * Even better auth switching and timeline syntax * Some auth tweaks * CSS tweaks * Reworked toasts * Fixed timer rounding quirk * Request settings and render errors * Fixed tests * Vertical dragging and stuff * Remove beta
76 lines
2.0 KiB
JavaScript
76 lines
2.0 KiB
JavaScript
import React, {PropTypes, PureComponent} from 'react';
|
|
import autobind from 'autobind-decorator';
|
|
import KeyValueEditor from '../../key-value-editor/editor';
|
|
import {trackEvent} from '../../../../analytics/index';
|
|
import {AUTH_BASIC} from '../../../../common/constants';
|
|
|
|
@autobind
|
|
class BasicAuth extends PureComponent {
|
|
_handleOnCreate () {
|
|
trackEvent('Basic Auth Editor', 'Create');
|
|
}
|
|
|
|
_handleOnDelete () {
|
|
trackEvent('Basic Auth Editor', 'Delete');
|
|
}
|
|
|
|
_handleToggleDisable (pair) {
|
|
const label = pair.disabled ? 'Disable' : 'Enable';
|
|
trackEvent('Basic Auth Editor', 'Toggle', label);
|
|
}
|
|
|
|
_handleChange (pairs) {
|
|
const pair = {
|
|
type: AUTH_BASIC,
|
|
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,
|
|
handleGetRenderContext
|
|
} = this.props;
|
|
|
|
const pairs = [{
|
|
name: authentication.username || '',
|
|
value: authentication.password || '',
|
|
disabled: authentication.disabled || false
|
|
}];
|
|
|
|
return (
|
|
<KeyValueEditor
|
|
pairs={pairs}
|
|
maxPairs={1}
|
|
disableDelete
|
|
handleRender={handleRender}
|
|
handleGetRenderContext={handleGetRenderContext}
|
|
namePlaceholder="Username"
|
|
valuePlaceholder="•••••••••••"
|
|
valueInputType={showPasswords ? 'text' : 'password'}
|
|
onToggleDisable={this._handleToggleDisable}
|
|
onCreate={this._handleOnCreate}
|
|
onDelete={this._handleOnDelete}
|
|
onChange={this._handleChange}
|
|
/>
|
|
);
|
|
}
|
|
}
|
|
|
|
BasicAuth.propTypes = {
|
|
handleRender: PropTypes.func.isRequired,
|
|
handleGetRenderContext: PropTypes.func.isRequired,
|
|
handleUpdateSettingsShowPasswords: PropTypes.func.isRequired,
|
|
onChange: PropTypes.func.isRequired,
|
|
authentication: PropTypes.object.isRequired,
|
|
showPasswords: PropTypes.bool.isRequired
|
|
};
|
|
|
|
export default BasicAuth;
|