11import Collapse from "@/assets/icons/collapse-text.svg?react" ;
22import Expand from "@/assets/icons/expand-full.svg?react" ;
3- import { LogEntry as LogEntryType , LogPage } from "@/types/logs" ; // Assuming types are in src/types/logs.ts
3+ import { LogPage } from "@/types/logs" ; // Assuming types are in src/types/logs.ts
44import { Button } from "@zenml-io/react-component-library/components/server" ;
55import React , { useState } from "react" ;
66import { EmptyStateLogs } from "./empty-state-logs" ;
@@ -13,9 +13,10 @@ import { useLogSearch } from "./use-log-search";
1313interface EnhancedLogsViewerProps {
1414logPage : LogPage ;
1515itemsPerPage ?: number ;
16+ downloadLink ?: string ;
1617}
1718
18- export function EnhancedLogsViewer ( { logPage } : EnhancedLogsViewerProps ) {
19+ export function EnhancedLogsViewer ( { logPage, downloadLink } : EnhancedLogsViewerProps ) {
1920const { currentPage, setCurrentPage } = useLogViewerContext ( ) ;
2021const [ textWrapEnabled , setTextWrapEnabled ] = useState ( true ) ;
2122const { searchQuery, setSearchQuery } = useLogViewerContext ( ) ;
@@ -40,19 +41,6 @@ export function EnhancedLogsViewer({ logPage }: EnhancedLogsViewerProps) {
4041setCurrentPage ( 1 ) ;
4142} , [ searchQuery ] ) ;
4243
43- const handleDownloadLogs = ( ) => {
44- const logText = getOriginalLogText ( logsToDisplay ) ;
45- const blob = new Blob ( [ logText ] , { type : "text/plain" } ) ;
46- const url = URL . createObjectURL ( blob ) ;
47- const a = document . createElement ( "a" ) ;
48- a . href = url ;
49- a . download = `logs-${ new Date ( ) . toISOString ( ) . split ( "T" ) [ 0 ] } .txt` ;
50- document . body . appendChild ( a ) ;
51- a . click ( ) ;
52- document . body . removeChild ( a ) ;
53- URL . revokeObjectURL ( url ) ;
54- } ;
55-
5644const handleToggleTextWrap = ( ) => {
5745setTextWrapEnabled ( ( prev ) => ! prev ) ;
5846} ;
@@ -62,8 +50,8 @@ export function EnhancedLogsViewer({ logPage }: EnhancedLogsViewerProps) {
6250return (
6351< div className = "flex h-full flex-col space-y-5" >
6452< LogToolbar
53+ downloadLink = { downloadLink }
6554onSearchChange = { setSearchQuery }
66- onDownload = { handleDownloadLogs }
6755searchQuery = { searchQuery }
6856currentMatchIndex = { currentMatchIndex }
6957totalMatches = { totalMatches }
@@ -81,8 +69,8 @@ export function EnhancedLogsViewer({ logPage }: EnhancedLogsViewerProps) {
8169return (
8270< div className = "flex h-full flex-col space-y-5" >
8371< LogToolbar
72+ downloadLink = { downloadLink }
8473onSearchChange = { setSearchQuery }
85- onDownload = { handleDownloadLogs }
8674searchQuery = { searchQuery }
8775currentMatchIndex = { currentMatchIndex }
8876totalMatches = { totalMatches }
@@ -159,7 +147,3 @@ export function EnhancedLogsViewer({ logPage }: EnhancedLogsViewerProps) {
159147</ div >
160148) ;
161149}
162-
163- function getOriginalLogText ( logs : LogEntryType [ ] ) {
164- return logs . map ( ( log ) => log . message ) . join ( "\n" ) ;
165- }
0 commit comments