1
0
mirror of https://github.com/sasjs/server.git synced 2025-12-11 19:44:35 +00:00

fix(log): fixed switching runtime

This commit is contained in:
Yury Shkoda
2023-04-11 16:10:52 +03:00
parent 02e2b060f9
commit c7a73991a7
3 changed files with 21 additions and 14 deletions

View File

@@ -24,6 +24,7 @@ import { usePrompt } from '../../utils/hooks'
import { getLanguageFromExtension } from './internal/helper' import { getLanguageFromExtension } from './internal/helper'
import useEditor from './internal/hooks/useEditor' import useEditor from './internal/hooks/useEditor'
import { RunTimeType } from '../../context/appContext' import { RunTimeType } from '../../context/appContext'
import { LogObject } from '../../utils'
const StyledTabPanel = styled(TabPanel)(() => ({ const StyledTabPanel = styled(TabPanel)(() => ({
padding: '10px' padding: '10px'
@@ -115,7 +116,8 @@ const SASjsEditor = ({
const logWithErrorsOrWarnings = const logWithErrorsOrWarnings =
selectedRunTime === RunTimeType.SAS && selectedRunTime === RunTimeType.SAS &&
log && log &&
(log.errors?.length !== 0 || log.warnings?.length !== 0) ((log as LogObject).errors?.length !== 0 ||
(log as LogObject).warnings?.length !== 0)
return ( return (
<Box sx={{ width: '100%', typography: 'body1', marginTop: '50px' }}> <Box sx={{ width: '100%', typography: 'body1', marginTop: '50px' }}>
@@ -158,7 +160,11 @@ const SASjsEditor = ({
label={logWithErrorsOrWarnings ? '' : 'log'} label={logWithErrorsOrWarnings ? '' : 'log'}
value="log" value="log"
icon={ icon={
logWithErrorsOrWarnings ? <LogTabWithIcons log={log} /> : '' logWithErrorsOrWarnings ? (
<LogTabWithIcons log={log as LogObject} />
) : (
''
)
} }
onClick={() => { onClick={() => {
const logWrapper = document.querySelector(`#logWrapper`) const logWrapper = document.querySelector(`#logWrapper`)

View File

@@ -30,12 +30,13 @@ const useStyles: any = makeStyles((theme: any) => ({
})) }))
interface LogComponentProps { interface LogComponentProps {
log: LogObject log: LogObject | string
selectedRunTime: RunTimeType selectedRunTime: RunTimeType
} }
const LogComponent = (props: LogComponentProps) => { const LogComponent = (props: LogComponentProps) => {
const { log, selectedRunTime } = props const { log, selectedRunTime } = props
const logObject = log as LogObject
const classes = useStyles() const classes = useStyles()
@@ -86,17 +87,17 @@ const LogComponent = (props: LogComponentProps) => {
defaultCollapseIcon={<ExpandMore />} defaultCollapseIcon={<ExpandMore />}
defaultExpandIcon={<ChevronRight />} defaultExpandIcon={<ChevronRight />}
> >
{log.errors && log.errors.length !== 0 && ( {logObject.errors && logObject.errors.length !== 0 && (
<TreeItem <TreeItem
nodeId="errors" nodeId="errors"
label={ label={
<Typography color="error"> <Typography color="error">
{`Errors (${log.errors.length})`} {`Errors (${logObject.errors.length})`}
</Typography> </Typography>
} }
> >
{log.errors && {logObject.errors &&
log.errors.map((error, ind) => ( logObject.errors.map((error, ind) => (
<TreeItem <TreeItem
nodeId={`error_${ind}`} nodeId={`error_${ind}`}
label={<ListItemText primary={error} />} label={<ListItemText primary={error} />}
@@ -106,15 +107,15 @@ const LogComponent = (props: LogComponentProps) => {
))} ))}
</TreeItem> </TreeItem>
)} )}
{log.warnings && log.warnings.length !== 0 && ( {logObject.warnings && logObject.warnings.length !== 0 && (
<TreeItem <TreeItem
nodeId="warnings" nodeId="warnings"
label={ label={
<Typography>{`Warnings (${log.warnings.length})`}</Typography> <Typography>{`Warnings (${logObject.warnings.length})`}</Typography>
} }
> >
{log.warnings && {logObject.warnings &&
log.warnings.map((warning, ind) => ( logObject.warnings.map((warning, ind) => (
<TreeItem <TreeItem
nodeId={`warning_${ind}`} nodeId={`warning_${ind}`}
label={<ListItemText primary={warning} />} label={<ListItemText primary={warning} />}
@@ -134,7 +135,7 @@ const LogComponent = (props: LogComponentProps) => {
className={classes.expansionDescription} className={classes.expansionDescription}
> >
<Highlight className={'html'} innerHTML={true}> <Highlight className={'html'} innerHTML={true}>
{decodeHtml(log?.body || '')} {decodeHtml(logObject?.body || '')}
</Highlight> </Highlight>
</Typography> </Typography>
</div> </div>
@@ -145,7 +146,7 @@ const LogComponent = (props: LogComponentProps) => {
id="log" id="log"
style={{ overflow: 'auto', height: 'calc(100vh - 220px)' }} style={{ overflow: 'auto', height: 'calc(100vh - 220px)' }}
> >
{log} {typeof log === 'string' ? log : log.body}
</pre> </pre>
</div> </div>
)} )}

View File

@@ -42,7 +42,7 @@ const useEditor = ({
const [prevFileContent, setPrevFileContent] = useStateWithCallback('') const [prevFileContent, setPrevFileContent] = useStateWithCallback('')
const [fileContent, setFileContent] = useState('') const [fileContent, setFileContent] = useState('')
const [log, setLog] = useState<LogObject>() const [log, setLog] = useState<LogObject | string>()
const [webout, setWebout] = useState('') const [webout, setWebout] = useState('')
const [runTimes, setRunTimes] = useState<string[]>([]) const [runTimes, setRunTimes] = useState<string[]>([])
const [selectedRunTime, setSelectedRunTime] = useState<RunTimeType>( const [selectedRunTime, setSelectedRunTime] = useState<RunTimeType>(