mirror of
https://github.com/sasjs/server.git
synced 2025-12-10 19:34:34 +00:00
fix(log): fixed single chunk display
This commit is contained in:
@@ -4,6 +4,7 @@ import Highlight from 'react-highlight'
|
||||
import { ErrorOutline, Warning } from '@mui/icons-material'
|
||||
import ContentCopyIcon from '@mui/icons-material/ContentCopy'
|
||||
import ExpandMoreIcon from '@mui/icons-material/ExpandMore'
|
||||
import CheckIcon from '@mui/icons-material/Check'
|
||||
import { makeStyles } from '@mui/styles'
|
||||
import {
|
||||
defaultChunkSize,
|
||||
@@ -44,9 +45,9 @@ interface LogChunkProps {
|
||||
|
||||
const LogChunk = (props: LogChunkProps) => {
|
||||
const { id, text, logLineCount, scrollToLogInstance } = props
|
||||
|
||||
const classes = useStyles()
|
||||
const [expanded, setExpanded] = useState(props.expanded)
|
||||
const [copied, setCopied] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
setExpanded(props.expanded)
|
||||
@@ -107,16 +108,26 @@ const LogChunk = (props: LogChunkProps) => {
|
||||
? (id + 1) * defaultChunkSize
|
||||
: logLineCount
|
||||
}`}</span>
|
||||
<ContentCopyIcon
|
||||
style={{ fontSize: 20 }}
|
||||
onClick={(evt: SyntheticEvent) => {
|
||||
evt.stopPropagation()
|
||||
{copied ? (
|
||||
<CheckIcon style={{ fontSize: 20, color: 'green' }} />
|
||||
) : (
|
||||
<ContentCopyIcon
|
||||
style={{ fontSize: 20 }}
|
||||
onClick={(evt: SyntheticEvent) => {
|
||||
evt.stopPropagation()
|
||||
|
||||
navigator.clipboard.writeText(
|
||||
clearErrorsAndWarningsHtmlWrapping(text)
|
||||
)
|
||||
}}
|
||||
/>
|
||||
navigator.clipboard.writeText(
|
||||
clearErrorsAndWarningsHtmlWrapping(text)
|
||||
)
|
||||
|
||||
setCopied(true)
|
||||
|
||||
setTimeout(() => {
|
||||
setCopied(false)
|
||||
}, 1000)
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{errors && errors.length !== 0 && (
|
||||
<ErrorOutline color="error" style={{ fontSize: 20 }} />
|
||||
)}
|
||||
|
||||
@@ -47,7 +47,6 @@ const LogComponent = (props: LogComponentProps) => {
|
||||
const [logChunksState, setLogChunksState] = useState<boolean[]>(
|
||||
new Array(logChunks.length).fill(false)
|
||||
)
|
||||
|
||||
const [scrollToLogInstance, setScrollToLogInstance] = useState<LogInstance>()
|
||||
const [oldestExpandedChunk, setOldestExpandedChunk] = useState<number>(
|
||||
logChunksState.length - 1
|
||||
|
||||
@@ -81,11 +81,11 @@ export const isTheLastChunk = (
|
||||
}
|
||||
|
||||
export const splitIntoChunks = (log: string, chunkSize = defaultChunkSize) => {
|
||||
if (!log.length) return []
|
||||
if (!log) return []
|
||||
|
||||
const logLines: string[] = log.split(`\n`)
|
||||
|
||||
if (logLines.length <= chunkSize) return log
|
||||
if (logLines.length <= chunkSize) return [log]
|
||||
|
||||
const chunks: string[] = []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user