diff --git a/web/src/containers/Studio/editor.tsx b/web/src/containers/Studio/editor.tsx index dca67b8..96c4a34 100644 --- a/web/src/containers/Studio/editor.tsx +++ b/web/src/containers/Studio/editor.tsx @@ -24,6 +24,7 @@ import { usePrompt } from '../../utils/hooks' import { getLanguageFromExtension } from './internal/helper' import useEditor from './internal/hooks/useEditor' import { RunTimeType } from '../../context/appContext' +import { LogObject } from '../../utils' const StyledTabPanel = styled(TabPanel)(() => ({ padding: '10px' @@ -115,7 +116,8 @@ const SASjsEditor = ({ const logWithErrorsOrWarnings = selectedRunTime === RunTimeType.SAS && log && - (log.errors?.length !== 0 || log.warnings?.length !== 0) + ((log as LogObject).errors?.length !== 0 || + (log as LogObject).warnings?.length !== 0) return ( @@ -158,7 +160,11 @@ const SASjsEditor = ({ label={logWithErrorsOrWarnings ? '' : 'log'} value="log" icon={ - logWithErrorsOrWarnings ? : '' + logWithErrorsOrWarnings ? ( + + ) : ( + '' + ) } onClick={() => { const logWrapper = document.querySelector(`#logWrapper`) diff --git a/web/src/containers/Studio/internal/components/log/logComponent.tsx b/web/src/containers/Studio/internal/components/log/logComponent.tsx index 25cac6e..eeb243d 100644 --- a/web/src/containers/Studio/internal/components/log/logComponent.tsx +++ b/web/src/containers/Studio/internal/components/log/logComponent.tsx @@ -30,12 +30,13 @@ const useStyles: any = makeStyles((theme: any) => ({ })) interface LogComponentProps { - log: LogObject + log: LogObject | string selectedRunTime: RunTimeType } const LogComponent = (props: LogComponentProps) => { const { log, selectedRunTime } = props + const logObject = log as LogObject const classes = useStyles() @@ -86,17 +87,17 @@ const LogComponent = (props: LogComponentProps) => { defaultCollapseIcon={} defaultExpandIcon={} > - {log.errors && log.errors.length !== 0 && ( + {logObject.errors && logObject.errors.length !== 0 && ( - {`Errors (${log.errors.length})`} + {`Errors (${logObject.errors.length})`} } > - {log.errors && - log.errors.map((error, ind) => ( + {logObject.errors && + logObject.errors.map((error, ind) => ( } @@ -106,15 +107,15 @@ const LogComponent = (props: LogComponentProps) => { ))} )} - {log.warnings && log.warnings.length !== 0 && ( + {logObject.warnings && logObject.warnings.length !== 0 && ( {`Warnings (${log.warnings.length})`} + {`Warnings (${logObject.warnings.length})`} } > - {log.warnings && - log.warnings.map((warning, ind) => ( + {logObject.warnings && + logObject.warnings.map((warning, ind) => ( } @@ -134,7 +135,7 @@ const LogComponent = (props: LogComponentProps) => { className={classes.expansionDescription} > - {decodeHtml(log?.body || '')} + {decodeHtml(logObject?.body || '')} @@ -145,7 +146,7 @@ const LogComponent = (props: LogComponentProps) => { id="log" style={{ overflow: 'auto', height: 'calc(100vh - 220px)' }} > - {log} + {typeof log === 'string' ? log : log.body} )} diff --git a/web/src/containers/Studio/internal/hooks/useEditor.ts b/web/src/containers/Studio/internal/hooks/useEditor.ts index a48fba2..d2be866 100644 --- a/web/src/containers/Studio/internal/hooks/useEditor.ts +++ b/web/src/containers/Studio/internal/hooks/useEditor.ts @@ -42,7 +42,7 @@ const useEditor = ({ const [prevFileContent, setPrevFileContent] = useStateWithCallback('') const [fileContent, setFileContent] = useState('') - const [log, setLog] = useState() + const [log, setLog] = useState() const [webout, setWebout] = useState('') const [runTimes, setRunTimes] = useState([]) const [selectedRunTime, setSelectedRunTime] = useState(