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);
|
2016-12-01 01:50:59 +00:00
|
|
|
trackEvent('Response', 'Preview Mode Change', previewMode);
|
2016-11-27 21:42:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
render () {
|
|
|
|
const {download, previewMode} = this.props;
|
|
|
|
return (
|
|
|
|
<Dropdown>
|
|
|
|
<DropdownButton className="tall">
|
|
|
|
<i className="fa fa-caret-down"></i>
|
|
|
|
</DropdownButton>
|
2016-12-21 23:37:48 +00:00
|
|
|
<DropdownDivider>Preview Mode</DropdownDivider>
|
2016-11-27 21:42:38 +00:00
|
|
|
{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-12-21 23:37:48 +00:00
|
|
|
<DropdownDivider>Actions</DropdownDivider>
|
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;
|