import React from 'react' import PropTypes from 'prop-types' import { Dropdown, MenuItem } from 'react-bootstrap' import { useTranslation } from 'react-i18next' import Icon from '../../../shared/components/icon' function PreviewRecompileButton({ compilerState: { isAutoCompileOn, isClearingCache, isCompiling, isDraftModeOn, isSyntaxCheckOn }, onClearCache, onRecompile, onRunSyntaxCheckNow, onSetAutoCompile, onSetDraftMode, onSetSyntaxCheck }) { const { t } = useTranslation() function handleRecompileFromScratch() { onClearCache() .then(() => { onRecompile() }) .catch(error => { console.error(error) }) } function handleSelectAutoCompileOn() { onSetAutoCompile(true) } function handleSelectAutoCompileOff() { onSetAutoCompile(false) } function handleSelectDraftModeOn() { onSetDraftMode(true) } function handleSelectDraftModeOff() { onSetDraftMode(false) } function handleSelectSyntaxCheckOn() { onSetSyntaxCheck(true) } function handleSelectSyntaxCheckOff() { onSetSyntaxCheck(false) } return ( {t('auto_compile')} {t('on')} {t('off')} {t('compile_mode')} {t('normal')} {t('fast')} [draft] Syntax Checks {t('stop_on_validation_error')} {t('ignore_validation_errors')} {t('run_syntax_check_now')} {t('recompile_from_scratch')} ) } PreviewRecompileButton.propTypes = { compilerState: PropTypes.shape({ isAutoCompileOn: PropTypes.bool.isRequired, isClearingCache: PropTypes.bool.isRequired, isCompiling: PropTypes.bool.isRequired, isDraftModeOn: PropTypes.bool.isRequired, isSyntaxCheckOn: PropTypes.bool.isRequired, logEntries: PropTypes.object.isRequired }), onClearCache: PropTypes.func.isRequired, onRecompile: PropTypes.func.isRequired, onRunSyntaxCheckNow: PropTypes.func.isRequired, onSetAutoCompile: PropTypes.func.isRequired, onSetDraftMode: PropTypes.func.isRequired, onSetSyntaxCheck: PropTypes.func.isRequired } export default PreviewRecompileButton