2016-11-27 21:42:38 +00:00
|
|
|
import React, {PureComponent, PropTypes} from 'react';
|
2016-11-11 22:01:21 +00:00
|
|
|
import {Dropdown, DropdownDivider, DropdownButton, DropdownItem} from '../base/dropdown';
|
2016-11-10 02:40:53 +00:00
|
|
|
import {PREVIEW_MODES, getPreviewModeName} from '../../../common/constants';
|
2016-11-23 19:33:24 +00:00
|
|
|
import {trackEvent} from '../../../analytics/index';
|
2016-04-30 05:01:57 +00:00
|
|
|
|
2016-11-27 21:42:38 +00:00
|
|
|
class PreviewModeDropdown extends PureComponent {
|
|
|
|
_handleClick = previewMode => {
|
|
|
|
this.props.updatePreviewMode(previewMode);
|
|
|
|
trackEvent('Response', 'Preview Mode Change', mode);
|
|
|
|
};
|
|
|
|
|
|
|
|
render () {
|
|
|
|
const {download, previewMode} = this.props;
|
|
|
|
return (
|
|
|
|
<Dropdown>
|
|
|
|
<DropdownButton className="tall">
|
|
|
|
<i className="fa fa-caret-down"></i>
|
|
|
|
</DropdownButton>
|
|
|
|
<DropdownDivider name="Preview Mode"/>
|
|
|
|
{PREVIEW_MODES.map(mode => (
|
|
|
|
<DropdownItem key={mode} onClick={this._handleClick} value={mode}>
|
|
|
|
{previewMode === mode ? <i className="fa fa-check"/> : <i className="fa fa-empty"/>}
|
|
|
|
{getPreviewModeName(mode)}
|
|
|
|
</DropdownItem>
|
|
|
|
))}
|
2016-11-29 21:28:22 +00:00
|
|
|
<DropdownDivider name="Actions"/>
|
2016-11-27 21:42:38 +00:00
|
|
|
<DropdownItem onClick={download}>
|
|
|
|
<i className="fa fa-save"></i>
|
|
|
|
Save to File
|
|
|
|
</DropdownItem>
|
|
|
|
</Dropdown>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
2016-04-30 05:01:57 +00:00
|
|
|
|
|
|
|
PreviewModeDropdown.propTypes = {
|
|
|
|
// Functions
|
|
|
|
updatePreviewMode: PropTypes.func.isRequired,
|
2016-10-28 17:51:08 +00:00
|
|
|
download: PropTypes.func.isRequired,
|
2016-07-28 20:10:26 +00:00
|
|
|
|
2016-04-30 05:01:57 +00:00
|
|
|
// Required
|
|
|
|
previewMode: PropTypes.string.isRequired
|
|
|
|
};
|
|
|
|
|
|
|
|
export default PreviewModeDropdown;
|