2017-02-28 21:32:23 +00:00
|
|
|
import React, {PropTypes, PureComponent} from 'react';
|
2017-03-03 01:44:07 +00:00
|
|
|
import autobind from 'autobind-decorator';
|
2017-03-08 05:52:17 +00:00
|
|
|
import KeyValueEditor from '../../key-value-editor/editor';
|
2016-11-23 19:33:24 +00:00
|
|
|
import {trackEvent} from '../../../../analytics/index';
|
2016-11-22 19:42:10 +00:00
|
|
|
|
2017-03-03 01:44:07 +00:00
|
|
|
@autobind
|
2017-02-28 21:32:23 +00:00
|
|
|
class UrlEncodedEditor extends PureComponent {
|
2017-03-03 01:44:07 +00:00
|
|
|
_handleTrackToggle (pair) {
|
|
|
|
trackEvent(
|
|
|
|
'Url Encoded Editor',
|
|
|
|
'Toggle',
|
|
|
|
pair.disabled ? 'Disable' : 'Enable'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
_handleTrackCreate () {
|
|
|
|
trackEvent('Url Encoded Editor', 'Create');
|
|
|
|
}
|
|
|
|
|
|
|
|
_handleTrackDelete () {
|
|
|
|
trackEvent('Url Encoded Editor', 'Delete');
|
|
|
|
}
|
2016-11-29 22:28:55 +00:00
|
|
|
|
2016-11-22 19:42:10 +00:00
|
|
|
render () {
|
2017-03-12 00:31:23 +00:00
|
|
|
const {
|
|
|
|
parameters,
|
|
|
|
onChange,
|
|
|
|
handleRender,
|
|
|
|
handleGetRenderContext
|
|
|
|
} = this.props;
|
2016-11-22 19:42:10 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="scrollable-container tall wide">
|
|
|
|
<div className="scrollable">
|
2017-03-03 20:09:08 +00:00
|
|
|
<KeyValueEditor
|
|
|
|
sortable
|
|
|
|
namePlaceholder="name"
|
|
|
|
valuePlaceholder="value"
|
|
|
|
onChange={onChange}
|
|
|
|
handleRender={handleRender}
|
2017-03-12 00:31:23 +00:00
|
|
|
handleGetRenderContext={handleGetRenderContext}
|
2017-03-03 20:09:08 +00:00
|
|
|
onToggleDisable={this._handleTrackToggle}
|
|
|
|
onCreate={this._handleTrackCreate}
|
|
|
|
onDelete={this._handleTrackDelete}
|
|
|
|
pairs={parameters}
|
|
|
|
/>
|
2016-11-22 19:42:10 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2017-03-03 20:09:08 +00:00
|
|
|
);
|
2016-11-22 19:42:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
UrlEncodedEditor.propTypes = {
|
|
|
|
// Required
|
|
|
|
onChange: PropTypes.func.isRequired,
|
2017-02-27 21:00:13 +00:00
|
|
|
parameters: PropTypes.arrayOf(PropTypes.object).isRequired,
|
2017-03-12 00:31:23 +00:00
|
|
|
handleRender: PropTypes.func.isRequired,
|
|
|
|
handleGetRenderContext: PropTypes.func.isRequired
|
2016-11-22 19:42:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default UrlEncodedEditor;
|