2020-09-28 06:51:15 -04:00
|
|
|
import React from 'react'
|
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
import PreviewToolbar from './preview-toolbar'
|
|
|
|
import PreviewLogsPane from './preview-logs-pane'
|
|
|
|
|
|
|
|
function PreviewPane({
|
|
|
|
compilerState,
|
|
|
|
onRecompile,
|
|
|
|
onRunSyntaxCheckNow,
|
|
|
|
onSetAutoCompile,
|
|
|
|
onSetDraftMode,
|
|
|
|
onSetSyntaxCheck,
|
|
|
|
onToggleLogs,
|
2020-09-29 07:08:49 -04:00
|
|
|
showLogs
|
2020-09-28 06:51:15 -04:00
|
|
|
}) {
|
2020-09-29 07:08:49 -04:00
|
|
|
const nErrors =
|
|
|
|
compilerState.logEntries && compilerState.logEntries.errors
|
|
|
|
? compilerState.logEntries.errors.length
|
|
|
|
: 0
|
|
|
|
const nWarnings =
|
|
|
|
compilerState.logEntries && compilerState.logEntries.warnings
|
|
|
|
? compilerState.logEntries.warnings.length
|
|
|
|
: 0
|
|
|
|
const nLogEntries =
|
|
|
|
compilerState.logEntries && compilerState.logEntries.all
|
|
|
|
? compilerState.logEntries.all.length
|
|
|
|
: 0
|
|
|
|
|
2020-09-28 06:51:15 -04:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<PreviewToolbar
|
|
|
|
compilerState={compilerState}
|
2020-09-29 07:08:49 -04:00
|
|
|
logsState={{ nErrors, nWarnings, nLogEntries }}
|
|
|
|
showLogs={showLogs}
|
2020-09-28 06:51:15 -04:00
|
|
|
onRecompile={onRecompile}
|
|
|
|
onRunSyntaxCheckNow={onRunSyntaxCheckNow}
|
|
|
|
onSetAutoCompile={onSetAutoCompile}
|
|
|
|
onSetDraftMode={onSetDraftMode}
|
|
|
|
onSetSyntaxCheck={onSetSyntaxCheck}
|
|
|
|
onToggleLogs={onToggleLogs}
|
|
|
|
/>
|
2020-09-29 07:08:49 -04:00
|
|
|
{showLogs ? (
|
|
|
|
<PreviewLogsPane logEntries={compilerState.logEntries.all} />
|
|
|
|
) : null}
|
2020-09-28 06:51:15 -04:00
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
PreviewPane.propTypes = {
|
|
|
|
compilerState: PropTypes.shape({
|
|
|
|
isAutoCompileOn: PropTypes.bool.isRequired,
|
|
|
|
isCompiling: PropTypes.bool.isRequired,
|
|
|
|
isDraftModeOn: PropTypes.bool.isRequired,
|
2020-09-29 07:08:49 -04:00
|
|
|
isSyntaxCheckOn: PropTypes.bool.isRequired,
|
|
|
|
logEntries: PropTypes.object.isRequired
|
2020-09-28 06:51:15 -04:00
|
|
|
}),
|
|
|
|
onRecompile: PropTypes.func.isRequired,
|
|
|
|
onRunSyntaxCheckNow: PropTypes.func.isRequired,
|
|
|
|
onSetAutoCompile: PropTypes.func.isRequired,
|
|
|
|
onSetDraftMode: PropTypes.func.isRequired,
|
|
|
|
onSetSyntaxCheck: PropTypes.func.isRequired,
|
|
|
|
onToggleLogs: PropTypes.func.isRequired,
|
2020-09-29 07:08:49 -04:00
|
|
|
showLogs: PropTypes.bool.isRequired
|
2020-09-28 06:51:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
export default PreviewPane
|