import React from 'react'
import PropTypes from 'prop-types'
import classNames from 'classnames'
import { useTranslation } from 'react-i18next'
import Icon from '../../../shared/components/icon'
function PreviewLogsToggleButton({
onToggle,
showLogs,
logsState: { nErrors, nWarnings }
}) {
const toggleButtonClasses = classNames('btn', 'btn-xs', 'btn-toggle-logs', {
'btn-danger': !showLogs && nErrors,
'btn-warning': !showLogs && !nErrors && nWarnings,
'btn-default': showLogs || (!nErrors && !nWarnings)
})
function handleOnClick(e) {
e.currentTarget.blur()
onToggle()
}
return (
)
}
function CompilationResultIndicator({ nErrors, nWarnings }) {
if (nErrors || nWarnings) {
return (
)
} else {
return
}
}
function LogsCompilationResultIndicator({ logType, nLogs }) {
const { t } = useTranslation()
const label =
logType === 'errors' ? t('your_project_has_errors') : t('view_warnings')
return (
<>
{`${label} (${nLogs > 9 ? '9+' : nLogs})`}
>
)
}
function ViewLogsButton() {
const { t } = useTranslation()
return (
<>
{t('view_logs')}
>
)
}
function ViewPdfButton() {
const { t } = useTranslation()
return (
<>
{t('view_pdf')}
>
)
}
PreviewLogsToggleButton.propTypes = {
onToggle: PropTypes.func.isRequired,
logsState: PropTypes.shape({
nErrors: PropTypes.number.isRequired,
nWarnings: PropTypes.number.isRequired,
nLogEntries: PropTypes.number.isRequired
}),
showLogs: PropTypes.bool.isRequired
}
LogsCompilationResultIndicator.propTypes = {
logType: PropTypes.string.isRequired,
nLogs: PropTypes.number.isRequired
}
export default PreviewLogsToggleButton