insomnia/app/ui/components/editors/body/UrlEncodedEditor.js
Gregory Schier 1d45367aa1 Added eslint and fixed all problems (#101)
* Fixed duplication kve bug

* Added semistandard and updated code

* Actually got it working

* Even better

* I think it should work on Windows now
2017-03-03 12:09:08 -08:00

55 lines
1.4 KiB
JavaScript

import React, {PropTypes, PureComponent} from 'react';
import autobind from 'autobind-decorator';
import KeyValueEditor from '../../keyvalueeditor/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} = this.props;
return (
<div className="scrollable-container tall wide">
<div className="scrollable">
<KeyValueEditor
sortable
namePlaceholder="name"
valuePlaceholder="value"
onChange={onChange}
handleRender={handleRender}
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
};
export default UrlEncodedEditor;