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