import React from 'react'
import { OverlayTrigger, Tooltip } from 'react-bootstrap'
import PropTypes from 'prop-types'
import classNames from 'classnames'
import { useTranslation } from 'react-i18next'
import Icon from '../../../shared/components/icon'
function PreviewLogsToggleButton({
onToggle,
showLogs,
compileFailed = false,
logsState: { nErrors, nWarnings },
showText
}) {
const { t } = useTranslation()
const toggleButtonClasses = classNames(
'btn',
'btn-xs',
'btn-toggle-logs',
'toolbar-item',
{
'btn-danger': !showLogs && nErrors,
'btn-warning': !showLogs && !nErrors && nWarnings,
'btn-default': showLogs || (!nErrors && !nWarnings)
}
)
let textStyle = {}
if (!showText) {
textStyle = {
position: 'absolute',
right: '-100vw'
}
}
function handleOnClick(e) {
e.currentTarget.blur()
onToggle()
}
const buttonElement = (
)
return showText ? (
buttonElement
) : (
{showLogs ? t('view_pdf') : t('view_logs')}
}
>
{buttonElement}
)
}
function CompilationResultIndicator({ textStyle, nErrors, nWarnings }) {
if (nErrors || nWarnings) {
return (
)
} else {
return
}
}
function LogsCompilationResultIndicator({ textStyle, 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({ textStyle }) {
const { t } = useTranslation()
return (
<>
{t('view_logs')}
>
)
}
function ViewPdfButton({ textStyle }) {
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,
showText: PropTypes.bool.isRequired,
compileFailed: PropTypes.bool
}
LogsCompilationResultIndicator.propTypes = {
logType: PropTypes.string.isRequired,
nLogs: PropTypes.number.isRequired,
textStyle: PropTypes.object.isRequired
}
ViewLogsButton.propTypes = {
textStyle: PropTypes.object.isRequired
}
ViewPdfButton.propTypes = {
textStyle: PropTypes.object.isRequired
}
export default PreviewLogsToggleButton