insomnia/app/ui/components/editors/body/url-encoded-editor.js
Gregory Schier e2c72987e8 Autocomplete for variables and tags (#112)
* Fixed duplication kve bug

* Autocomplete sort of works now

* Even better

* Styled autocomplete dropdown

* Minor tweaks

* Autocomplete looking pretty spiffy

* Bug fixes

* Apply dropdown to all editors

* Fixed key propagation when autocomplete open

* Fixed some modals

* Split up editor less

* Some css improvements

* Move filter help out of editor

* Fixed drag-n-drop

* Perfected autocomplete theme

* "fixed" one-line-editor hint click bug

* Better autocomplete and switch single line input on drag enter

* Don't autocomplete on Tab

* Better tag dnd

* Add constants completion API

* Autocomplete headers

* Fixed tests
2017-03-11 16:31:23 -08:00

62 lines
1.5 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';
@autobind
class UrlEncodedEditor extends PureComponent {
_handleTrackToggle (pair) {
trackEvent(
'Url Encoded Editor',
'Toggle',
pair.disabled ? 'Disable' : 'Enable'
);
}
_handleTrackCreate () {
trackEvent('Url Encoded Editor', 'Create');
}
_handleTrackDelete () {
trackEvent('Url Encoded Editor', 'Delete');
}
render () {
const {
parameters,
onChange,
handleRender,
handleGetRenderContext
} = this.props;
return (
<div className="scrollable-container tall wide">
<div className="scrollable">
<KeyValueEditor
sortable
namePlaceholder="name"
valuePlaceholder="value"
onChange={onChange}
handleRender={handleRender}
handleGetRenderContext={handleGetRenderContext}
onToggleDisable={this._handleTrackToggle}
onCreate={this._handleTrackCreate}
onDelete={this._handleTrackDelete}
pairs={parameters}
/>
</div>
</div>
);
}
}
UrlEncodedEditor.propTypes = {
// Required
onChange: PropTypes.func.isRequired,
parameters: PropTypes.arrayOf(PropTypes.object).isRequired,
handleRender: PropTypes.func.isRequired,
handleGetRenderContext: PropTypes.func.isRequired
};
export default UrlEncodedEditor;