import React, {PureComponent} from 'react';
import PropTypes from 'prop-types';
import autobind from 'autobind-decorator';
import {Dropdown, DropdownButton, DropdownDivider, DropdownItem} from '../base/dropdown';
import {getPreviewModeName, PREVIEW_MODES} from '../../../common/constants';
import {trackEvent} from '../../../analytics/index';
@autobind
class PreviewModeDropdown extends PureComponent {
_handleClick (previewMode) {
this.props.updatePreviewMode(previewMode);
trackEvent('Response', 'Preview Mode Change', previewMode);
}
renderPreviewMode (mode) {
const {previewMode} = this.props;
return (
{previewMode === mode ? : }
{getPreviewModeName(mode, true)}
);
}
render () {
const {download, fullDownload, previewMode} = this.props;
return (
{getPreviewModeName(previewMode)}
Preview Mode
{PREVIEW_MODES.map(this.renderPreviewMode)}
Actions
Save Response Body
Save Full Response
);
}
}
PreviewModeDropdown.propTypes = {
// Functions
updatePreviewMode: PropTypes.func.isRequired,
download: PropTypes.func.isRequired,
fullDownload: PropTypes.func.isRequired,
// Required
previewMode: PropTypes.string.isRequired
};
export default PreviewModeDropdown;