Skip to content

Commit

Permalink
fix(log): fixed switching runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
YuryShkoda committed Apr 11, 2023
1 parent 02e2b06 commit c7a7399
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
10 changes: 8 additions & 2 deletions web/src/containers/Studio/editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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 (
<Box sx={{ width: '100%', typography: 'body1', marginTop: '50px' }}>
Expand Down Expand Up @@ -158,7 +160,11 @@ const SASjsEditor = ({
label={logWithErrorsOrWarnings ? '' : 'log'}
value="log"
icon={
logWithErrorsOrWarnings ? <LogTabWithIcons log={log} /> : ''
logWithErrorsOrWarnings ? (
<LogTabWithIcons log={log as LogObject} />
) : (
''
)
}
onClick={() => {
const logWrapper = document.querySelector(`#logWrapper`)
Expand Down
23 changes: 12 additions & 11 deletions web/src/containers/Studio/internal/components/log/logComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -86,17 +87,17 @@ const LogComponent = (props: LogComponentProps) => {
defaultCollapseIcon={<ExpandMore />}
defaultExpandIcon={<ChevronRight />}
>
{log.errors && log.errors.length !== 0 && (
{logObject.errors && logObject.errors.length !== 0 && (
<TreeItem
nodeId="errors"
label={
<Typography color="error">
{`Errors (${log.errors.length})`}
{`Errors (${logObject.errors.length})`}
</Typography>
}
>
{log.errors &&
log.errors.map((error, ind) => (
{logObject.errors &&
logObject.errors.map((error, ind) => (
<TreeItem
nodeId={`error_${ind}`}
label={<ListItemText primary={error} />}
Expand All @@ -106,15 +107,15 @@ const LogComponent = (props: LogComponentProps) => {
))}
</TreeItem>
)}
{log.warnings && log.warnings.length !== 0 && (
{logObject.warnings && logObject.warnings.length !== 0 && (
<TreeItem
nodeId="warnings"
label={
<Typography>{`Warnings (${log.warnings.length})`}</Typography>
<Typography>{`Warnings (${logObject.warnings.length})`}</Typography>
}
>
{log.warnings &&
log.warnings.map((warning, ind) => (
{logObject.warnings &&
logObject.warnings.map((warning, ind) => (
<TreeItem
nodeId={`warning_${ind}`}
label={<ListItemText primary={warning} />}
Expand All @@ -134,7 +135,7 @@ const LogComponent = (props: LogComponentProps) => {
className={classes.expansionDescription}
>
<Highlight className={'html'} innerHTML={true}>
{decodeHtml(log?.body || '')}
{decodeHtml(logObject?.body || '')}
</Highlight>
</Typography>
</div>
Expand All @@ -145,7 +146,7 @@ const LogComponent = (props: LogComponentProps) => {
id="log"
style={{ overflow: 'auto', height: 'calc(100vh - 220px)' }}
>
{log}
{typeof log === 'string' ? log : log.body}
</pre>
</div>
)}
Expand Down
2 changes: 1 addition & 1 deletion web/src/containers/Studio/internal/hooks/useEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const useEditor = ({

const [prevFileContent, setPrevFileContent] = useStateWithCallback('')
const [fileContent, setFileContent] = useState('')
const [log, setLog] = useState<LogObject>()
const [log, setLog] = useState<LogObject | string>()
const [webout, setWebout] = useState('')
const [runTimes, setRunTimes] = useState<string[]>([])
const [selectedRunTime, setSelectedRunTime] = useState<RunTimeType>(
Expand Down

0 comments on commit c7a7399

Please sign in to comment.