@@ -7,6 +7,7 @@ import { Box, Button, Code, Container, Header, ListEmptyMessage, Loader, TextCon
77import { useLocalStorageState } from 'hooks/useLocalStorageState' ;
88import { useLazyGetProjectLogsQuery } from 'services/project' ;
99
10+ import { LogRow } from './components/LogRow' ;
1011import { decodeLogs } from './helpers' ;
1112
1213import { IProps } from './types' ;
@@ -27,7 +28,7 @@ export const Logs: React.FC<IProps> = ({ className, projectName, runName, jobSub
2728 const [ isLoading , setIsLoading ] = useState ( false ) ;
2829 const [ getProjectLogs ] = useLazyGetProjectLogsQuery ( ) ;
2930 const [ isEnabledDecoding , setIsEnabledDecoding ] = useLocalStorageState ( 'enable-encode-logs' , false ) ;
30- // const [isShowTimestamp, setIsShowTimestamp] = useLocalStorageState('enable-showing-timestamp-logs', false);
31+ const [ isShowTimestamp , setIsShowTimestamp ] = useLocalStorageState ( 'enable-showing-timestamp-logs' , false ) ;
3132
3233 const logsForView = useMemo ( ( ) => {
3334 if ( isEnabledDecoding ) {
@@ -105,6 +106,10 @@ export const Logs: React.FC<IProps> = ({ className, projectName, runName, jobSub
105106 setIsEnabledDecoding ( ! isEnabledDecoding ) ;
106107 } ;
107108
109+ const toggleShowingTimestamp = ( ) => {
110+ setIsShowTimestamp ( ! isShowTimestamp ) ;
111+ } ;
112+
108113 useEffect ( ( ) => {
109114 getLogItems ( ) ;
110115 } , [ ] ) ;
@@ -178,11 +183,15 @@ export const Logs: React.FC<IProps> = ({ className, projectName, runName, jobSub
178183 />
179184 </ Box >
180185
181- { /*<Box>*/ }
182- { /* <Toggle onChange={({ detail }) => setIsShowTimestamp(detail.checked)} checked={isShowTimestamp}>*/ }
183- { /* Show timestamp*/ }
184- { /* </Toggle>*/ }
185- { /*</Box>*/ }
186+ < Box >
187+ < Button
188+ ariaLabel = "Show timestamp"
189+ formAction = "none"
190+ iconName = "status-pending"
191+ variant = { isShowTimestamp ? 'primary' : 'icon' }
192+ onClick = { toggleShowingTimestamp }
193+ />
194+ </ Box >
186195 </ div >
187196 </ div >
188197 }
@@ -199,12 +208,13 @@ export const Logs: React.FC<IProps> = ({ className, projectName, runName, jobSub
199208
200209 { Boolean ( logsForView . length ) && (
201210 < Code className = { styles . terminal } ref = { codeRef } >
202- { logsForView . map ( ( log , i ) => (
203- < p key = { i } >
204- { /*{isShowTimestamp && <span className={styles.timestamp}>{log.timestamp}</span> }*/ }
205- { log . message }
206- </ p >
207- ) ) }
211+ < table >
212+ < tbody >
213+ { logsForView . map ( ( log , i ) => (
214+ < LogRow logItem = { log } key = { i } isShowTimestamp = { isShowTimestamp } />
215+ ) ) }
216+ </ tbody >
217+ </ table >
208218 </ Code >
209219 ) }
210220 </ TextContent >
0 commit comments